osmacro.inc 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. {
  2. Copyright (c) 2000-2002 by Marco van de Voort
  3. The "linux" posixy macro's that are used both in the Baseunx unit as the
  4. system unit. Not aliased via public names because I want these to be
  5. inlined as much as possible in the future.
  6. This program is free software; you can redistribute it and/or modify it
  7. under the terms of the GNU General Public License as published by the
  8. Free Software Foundation; either version 2 of the License, or (at your
  9. option) any later version.
  10. This program is distributed in the hope that it will be useful, but
  11. WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. General Public License for more details.
  14. You should have received a copy of the GNU General Public License along
  15. with this program; if not, write to the Free Software Foundation, Inc.,
  16. 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. }
  19. function FpS_ISDIR(m : TMode): boolean;
  20. begin
  21. FpS_ISDIR:=((m and S_IFMT) = S_IFDIR);
  22. end;
  23. function FpS_ISCHR(m : TMode): boolean;
  24. begin
  25. FpS_ISCHR:=((m and S_IFMT) = S_IFCHR);
  26. end;
  27. function FpS_ISBLK(m : TMode): boolean;
  28. begin
  29. FpS_ISBLK:=((m and S_IFMT) = S_IFBLK);
  30. end;
  31. function FpS_ISREG(m : TMode): boolean;
  32. begin
  33. FpS_ISREG:=((m and S_IFMT) = S_IFREG);
  34. end;
  35. function FpS_ISFIFO(m : TMode): boolean;
  36. begin
  37. FpS_ISFIFO:=((m and S_IFMT) = S_IFIFO);
  38. end;
  39. Function FPS_ISLNK(m:TMode):boolean;
  40. begin
  41. FPS_ISLNK:=((m and S_IFMT) = S_IFLNK);
  42. end;
  43. Function FPS_ISSOCK(m:TMode):boolean;
  44. begin
  45. FPS_ISSOCK:=((m and S_IFMT) = S_IFSOCK);
  46. end;
  47. function wifexited(status : cint): boolean;
  48. begin
  49. wifexited:=(status AND $7f) =0;
  50. end;
  51. function wexitstatus(status : cint): cint;
  52. begin
  53. wexitstatus:=(status and $FF00) shr 8;
  54. end;
  55. function wstopsig(status : cint): cint;
  56. begin
  57. wstopsig:=(status and $FF00) shr 8;
  58. end;
  59. const wstopped=127;
  60. function wifsignaled(status : cint): boolean;
  61. begin
  62. wifsignaled:=((status and $FF)<>wstopped) and ((status and 127)<>0);
  63. end;
  64. function wtermsig(status : cint):cint;
  65. begin
  66. wtermsig:=cint(status and 127);
  67. end;
  68. {$ifdef FPC_USE_LIBC}
  69. function __fxstat(__ver,filedes : cint; var __stat: tstat): cint; cdecl; external clib name '__fxstat'+suffix64bit;
  70. function __xstat(__ver : cint;FileName: PChar; var __stat: tstat): cint; cdecl; external clib name '__xstat'+suffix64bit;
  71. function __lxstat(__ver : cint; FileName: PChar; var __stat: tstat): cint; cdecl; external clib name '__lxstat'+suffix64bit;
  72. {
  73. function __fxstat64(__ver : cint; FileDes: Integer; var __stat: tstat): cint; cdecl; external clib name '__fxstat64';
  74. function __xstat64(__ver : cint; FileName: PChar; var __stat: tstat): cint; cdecl; external clib name '__xstat64';
  75. function __lxstat64(__ver : cint; FileName: PChar; var __stat: tstat): cint; cdecl; external clib name '__lxstat64';
  76. function __xmknod(__ver : cint; Pathname: PChar; Mode: mode_t; var Device: dev_t): cint; cdecl; external clib name '__xmknod';
  77. }
  78. {$define FPC_HAS_BASEUNIX_STAT}
  79. function FpFstat(fd : cint; var sb : stat): cint;inline;
  80. begin
  81. __fxstat(_STAT_VER,fd,sb);
  82. end;
  83. function fpLstat(path:pchar;Info:pstat):cint;inline;
  84. begin
  85. __lxstat(_STAT_VER,path,Info^);
  86. end;
  87. function FpStat(path: pchar; var buf : stat): cint;inline;
  88. begin
  89. __xstat(_STAT_VER,path,buf);
  90. end;
  91. {$ifndef fs32bit}
  92. function FpOpen (path: pchar; flags : cint; mode: TMode):cint; inline;
  93. begin
  94. FpOpen:=__fpopen(path, flags or O_LARGEFILE, mode);
  95. end;
  96. {$endif}
  97. {$endif FPC_USE_LIBC}