posmacro.inc 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. {
  2. $Id$
  3. Copyright (c) 2000-2002 by Marco van de Voort
  4. The "linux" POSIX macro's that are used both in the POSIX unit as the
  5. system unit. Not aliased via public names because I want these to
  6. be inlined as much as possible in the future.
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. ****************************************************************************
  19. }
  20. CONST
  21. _S_IFDIR = $4000;
  22. _S_IFCHR = $2000;
  23. _S_IFBLK = $6000;
  24. _S_IFREG = $8000;
  25. _S_IFMT = $f000;
  26. _S_IFIFO = $1000;
  27. function S_ISDIR(m : mode_t): boolean;
  28. begin
  29. S_ISDIR:=((m and _S_IFMT) = _S_IFDIR);
  30. end;
  31. function S_ISCHR(m : mode_t): boolean;
  32. begin
  33. S_ISCHR:=((m and _S_IFMT) = _S_IFCHR);
  34. end;
  35. function S_ISBLK(m : mode_t): boolean;
  36. begin
  37. S_ISBLK:=((m and _S_IFMT) = _S_IFBLK);
  38. end;
  39. function S_ISREG(m : mode_t): boolean;
  40. begin
  41. S_ISREG:=((m and _S_IFMT) = _S_IFREG);
  42. end;
  43. function S_ISFIFO(m : mode_t): boolean;
  44. begin
  45. S_ISFIFO:=((m and _S_IFMT) = _S_IFIFO);
  46. end;
  47. function wifexited(status : cint): cint;
  48. begin
  49. wifexited:=cint((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): cint;
  61. begin
  62. wifsignaled:=cint(((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. {
  69. $Log$
  70. Revision 1.2 2002-11-12 15:31:33 marco
  71. * Killed octal codes for 1.0.x compilability.
  72. Revision 1.1 2002/11/12 14:37:59 marco
  73. * Parts of new unix rtl
  74. }