ptypes.inc 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2001 by Free Pascal development team
  5. This file implements all the base types and limits required
  6. for a minimal POSIX compliant subset required to port the compiler
  7. to a new OS.
  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. {***********************************************************************}
  15. { POSIX TYPE DEFINITIONS }
  16. {***********************************************************************}
  17. { Introduced defines
  18. - 64bitfs (should be on if libc switches to a 64-bit system.
  19. All three tested systems (PPC,Alpha,2x i386) gave the same POSIX limits,
  20. and all three 32-bit systems returned completely identical types too
  21. (everything 32-bit except dev_t, which is assumed to be a result of devfs
  22. introduction)
  23. }
  24. {$I ctypes.inc}
  25. Type
  26. {$ifndef VER_1_0} // maybe wrong (kernel vs libc)
  27. dev_t = cuint64; { used for device numbers }
  28. {$else}
  29. dev_t = int64;
  30. {$endif}
  31. TDev = dev_t;
  32. pDev = ^dev_t;
  33. kDev_t = cushort; // Linux has two different device conventions
  34. TkDev = KDev_t; // kernel and glibc. This is kernel.
  35. pkDev = ^kdev_t;
  36. gid_t = cuint32; { used for group IDs }
  37. TGid = gid_t;
  38. pGid = ^gid_t;
  39. ino_t = clong; { used for file serial numbers }
  40. TIno = ino_t;
  41. pIno = ^ino_t;
  42. mode_t = cuint32; { used for file attributes }
  43. TMode = mode_t;
  44. pMode = ^mode_t;
  45. nlink_t = cuint32; { used for link counts }
  46. TnLink = nlink_t;
  47. pnLink = ^nlink_t;
  48. {$ifdef cpu64}
  49. off_t = cint64; { used for file sizes }
  50. {$else}
  51. {$ifdef 64BitFS}
  52. off_t = cint64;
  53. {$else}
  54. off_t = cint;
  55. {$endif}
  56. {$endif}
  57. TOff = off_t;
  58. pOff = ^off_t;
  59. pid_t = cint32; { used as process identifier }
  60. TPid = pid_t;
  61. pPid = ^pid_t;
  62. {$ifdef cpu64}
  63. size_t = cuint64; { as definied in the C standard}
  64. ssize_t = cint64; { used by function for returning number of bytes }
  65. clock_t = cuint64;
  66. time_t = cint64; { used for returning the time }
  67. {$else}
  68. size_t = cuint32; { as definied in the C standard}
  69. ssize_t = cint32; { used by function for returning number of bytes }
  70. clock_t = culong;
  71. time_t = clong; { used for returning the time }
  72. {$endif}
  73. TSize = size_t;
  74. pSize = ^size_t;
  75. TSSize = ssize_t;
  76. pSSize = ^ssize_t;
  77. TClock = clock_t;
  78. pClock = ^clock_t;
  79. TTime = time_t;
  80. pTime = ^time_t;
  81. ptime_t = ^time_t;
  82. uid_t = cuint32; { used for user ID type }
  83. TUid = uid_t;
  84. pUid = ^uid_t;
  85. socklen_t= cuint32;
  86. TSockLen = socklen_t;
  87. pSockLen = ^socklen_t;
  88. timeval = packed record
  89. tv_sec,
  90. tv_usec:clong;
  91. end;
  92. ptimeval = ^timeval;
  93. TTimeVal = timeval;
  94. timespec = packed record
  95. tv_sec : time_t;
  96. tv_nsec : clong;
  97. end;
  98. ptimespec = ^timespec;
  99. TTimeSpec = timespec;
  100. TStatfs = packed record
  101. fstype, { File system type }
  102. bsize : cint; { Optimal block trensfer size }
  103. blocks, { Data blocks in system }
  104. bfree, { free blocks in system }
  105. bavail, { Available free blocks to non-root users }
  106. files, { File nodes in system }
  107. ffree : clong; { Free file nodes in system }
  108. fsid : array[0..1] of cint; { File system ID }
  109. namelen : clong; { Maximum name length in system }
  110. spare : array [0..5] of clong; { For later use }
  111. end;
  112. PStatFS=^TStatFS;
  113. CONST
  114. { System limits, POSIX value in parentheses, used for buffer and stack allocation }
  115. { took idefix' values}
  116. ARG_MAX = 131072; {4096} { Maximum number of argument size }
  117. NAME_MAX = 255; {14} { Maximum number of bytes in filename }
  118. PATH_MAX = 4095; {255} { Maximum number of bytes in pathname }
  119. SYS_NMLN = 65;
  120. {$ifdef FPC_USE_LIBC}
  121. SIG_MAXSIG = 1024; // highest signal version
  122. {$else}
  123. SIG_MAXSIG = 128; // highest signal version
  124. {$endif}
  125. {
  126. $Log$
  127. Revision 1.10 2004-05-02 01:00:07 peter
  128. * statfs fixed
  129. Revision 1.9 2004/04/26 16:53:19 peter
  130. * use cpu64
  131. Revision 1.8 2004/03/04 22:15:16 marco
  132. * UnixType changes. Please report problems to me.
  133. Revision 1.7 2004/01/11 09:56:20 jonas
  134. * moved tstatfs from systypes.inc to ptypes.inc to fix make cycle with
  135. -dFPC_USE_LIBC (systypes.inc is now completely commented out)
  136. Revision 1.6 2003/12/30 12:46:40 marco
  137. * ptime_t
  138. Revision 1.5 2003/09/27 13:45:58 peter
  139. * fpnanosleep exported in baseunix
  140. * fpnanosleep has pointer arguments to be C compliant
  141. Revision 1.4 2003/09/14 20:15:01 marco
  142. * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
  143. Revision 1.3 2002/12/18 16:43:26 marco
  144. * new unix rtl, linux part.....
  145. Revision 1.2 2002/11/12 14:28:40 marco
  146. * some updates
  147. Revision 1.1 2002/10/29 16:47:17 marco
  148. * Linux versions
  149. }