osmacro.inc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2002 Marco van de Voort
  4. member of the Free Pascal development team.
  5. The "linux" posixy macro's that are used both in the Baseunix unit as the
  6. system unit. Not aliased via public names because I want these to be
  7. inlined as much as possible in the future.
  8. See the file COPYING.FPC, included in this distribution,
  9. for details about the copyright.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. **********************************************************************}
  14. function FpS_ISDIR(m : TMode): boolean;
  15. begin
  16. FpS_ISDIR:=((m and S_IFMT) = S_IFDIR);
  17. end;
  18. function FpS_ISCHR(m : TMode): boolean;
  19. begin
  20. FpS_ISCHR:=((m and S_IFMT) = S_IFCHR);
  21. end;
  22. function FpS_ISBLK(m : TMode): boolean;
  23. begin
  24. FpS_ISBLK:=((m and S_IFMT) = S_IFBLK);
  25. end;
  26. function FpS_ISREG(m : TMode): boolean;
  27. begin
  28. FpS_ISREG:=((m and S_IFMT) = S_IFREG);
  29. end;
  30. function FpS_ISFIFO(m : TMode): boolean;
  31. begin
  32. FpS_ISFIFO:=((m and S_IFMT) = S_IFIFO);
  33. end;
  34. Function FPS_ISLNK(m:TMode):boolean;
  35. begin
  36. FPS_ISLNK:=((m and S_IFMT) = S_IFLNK);
  37. end;
  38. Function FPS_ISSOCK(m:TMode):boolean;
  39. begin
  40. FPS_ISSOCK:=((m and S_IFMT) = S_IFSOCK);
  41. end;
  42. function wifexited(status : cint): boolean;
  43. begin
  44. wifexited:=(status AND $7f) =0;
  45. end;
  46. function wexitstatus(status : cint): cint;
  47. begin
  48. wexitstatus:=(status and $FF00) shr 8;
  49. end;
  50. function wstopsig(status : cint): cint;
  51. begin
  52. wstopsig:=(status and $FF00) shr 8;
  53. end;
  54. const wstopped=127;
  55. function wifsignaled(status : cint): boolean;
  56. begin
  57. wifsignaled:=((status and $FF)<>wstopped) and ((status and 127)<>0);
  58. end;
  59. function wtermsig(status : cint):cint;
  60. begin
  61. wtermsig:=cint(status and 127);
  62. end;
  63. {$ifdef FPC_USE_LIBC}
  64. function __fxstat(__ver,filedes : cint; var __stat: tstat): cint; cdecl; external clib name '__fxstat'+suffix64bit;
  65. function __xstat(__ver : cint;FileName: PChar; var __stat: tstat): cint; cdecl; external clib name '__xstat'+suffix64bit;
  66. function __lxstat(__ver : cint; FileName: PChar; var __stat: tstat): cint; cdecl; external clib name '__lxstat'+suffix64bit;
  67. {
  68. function __fxstat64(__ver : cint; FileDes: Integer; var __stat: tstat): cint; cdecl; external clib name '__fxstat64';
  69. function __xstat64(__ver : cint; FileName: PChar; var __stat: tstat): cint; cdecl; external clib name '__xstat64';
  70. function __lxstat64(__ver : cint; FileName: PChar; var __stat: tstat): cint; cdecl; external clib name '__lxstat64';
  71. function __xmknod(__ver : cint; Pathname: PChar; Mode: mode_t; var Device: dev_t): cint; cdecl; external clib name '__xmknod';
  72. }
  73. {$define FPC_HAS_BASEUNIX_STAT}
  74. function FpFstat(fd : cint; var sb : stat): cint;inline;
  75. begin
  76. FpFstat:=__fxstat(_STAT_VER,fd,sb);
  77. end;
  78. function fpLstat(path:pchar;Info:pstat):cint;inline;
  79. begin
  80. fpLstat:=__lxstat(_STAT_VER,path,Info^);
  81. end;
  82. function FpStat(path: pchar; var buf : stat): cint;inline;
  83. begin
  84. FpStat:=__xstat(_STAT_VER,path,buf);
  85. end;
  86. {$endif FPC_USE_LIBC}