ptypes.inc 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2001 by Free Pascal development team
  4. This file implements all the base types and limits required
  5. for a minimal POSIX compliant subset required to port the compiler
  6. to a new OS.
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. {***********************************************************************}
  14. { POSIX TYPE DEFINITIONS }
  15. {***********************************************************************}
  16. { Introduced defines
  17. - 64bitfs (should be on if libc switches to a 64-bit system.
  18. All three tested systems (PPC,Alpha,2x i386) gave the same POSIX limits,
  19. and all three 32-bit systems returned completely identical types too
  20. (everything 32-bit except dev_t, which is assumed to be a result of devfs
  21. introduction)
  22. }
  23. {$I ctypes.inc}
  24. {$packrecords c}
  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. wint_t = cint32;
  74. TSize = size_t;
  75. pSize = ^size_t;
  76. psize_t = pSize;
  77. TSSize = ssize_t;
  78. pSSize = ^ssize_t;
  79. TClock = clock_t;
  80. pClock = ^clock_t;
  81. TTime = time_t;
  82. pTime = ^time_t;
  83. ptime_t = ^time_t;
  84. wchar_t = widechar;
  85. pwchar_t = ^wchar_t;
  86. uid_t = cuint32; { used for user ID type }
  87. TUid = uid_t;
  88. pUid = ^uid_t;
  89. socklen_t= cuint32;
  90. TSockLen = socklen_t;
  91. pSockLen = ^socklen_t;
  92. timeval = packed record
  93. tv_sec,
  94. tv_usec:clong;
  95. end;
  96. ptimeval = ^timeval;
  97. TTimeVal = timeval;
  98. timespec = packed record
  99. tv_sec : time_t;
  100. tv_nsec : clong;
  101. end;
  102. ptimespec = ^timespec;
  103. TTimeSpec = timespec;
  104. TStatfs = packed record
  105. fstype, { File system type }
  106. bsize : cint; { Optimal block trensfer size }
  107. blocks, { Data blocks in system }
  108. bfree, { free blocks in system }
  109. bavail, { Available free blocks to non-root users }
  110. files, { File nodes in system }
  111. ffree : clong; { Free file nodes in system }
  112. fsid : array[0..1] of cint; { File system ID }
  113. namelen : clong; { Maximum name length in system }
  114. spare : array [0..5] of clong; { For later use }
  115. end;
  116. PStatFS=^TStatFS;
  117. pthread_t = culong;
  118. sched_param = record
  119. __sched_priority: cint;
  120. end;
  121. pthread_attr_t = record
  122. __detachstate: cint;
  123. __schedpolicy: cint;
  124. __schedparam: sched_param;
  125. __inheritsched: cint;
  126. __scope: cint;
  127. __guardsize: size_t;
  128. __stackaddr_set: cint;
  129. __stackaddr: pointer;
  130. __stacksize: size_t;
  131. end;
  132. _pthread_fastlock = record
  133. __status: clong;
  134. __spinlock: cint;
  135. end;
  136. pthread_mutex_t = record
  137. __m_reserved: cint;
  138. __m_count: cint;
  139. __m_owner: pointer;
  140. __m_kind: cint;
  141. __m_lock: _pthread_fastlock;
  142. end;
  143. pthread_mutexattr_t = record
  144. __mutexkind: cint;
  145. end;
  146. pthread_cond_t = record
  147. __c_lock: _pthread_fastlock;
  148. __c_waiting: pointer;
  149. __padding: array[0..48-1-sizeof(_pthread_fastlock)-sizeof(pointer)-sizeof(clonglong)] of byte;
  150. __align: clonglong;
  151. end;
  152. pthread_condattr_t = record
  153. __dummy: cint;
  154. end;
  155. pthread_key_t = cuint;
  156. pthread_rwlock_t = record
  157. __rw_readers: cint;
  158. __rw_writer: pointer;
  159. __rw_read_waiting: pointer;
  160. __rw_write_waiting: pointer;
  161. __rw_kind: cint;
  162. __rw_pshared: cint;
  163. end;
  164. pthread_rwlockattr_t = record
  165. __lockkind: cint;
  166. __pshared: cint;
  167. end;
  168. sem_t = record
  169. __sem_lock: _pthread_fastlock;
  170. __sem_value: cint;
  171. __sem_waiting: pointer;
  172. end;
  173. CONST
  174. _PTHREAD_MUTEX_TIMED_NP = 0;
  175. _PTHREAD_MUTEX_RECURSIVE_NP = 1;
  176. _PTHREAD_MUTEX_ERRORCHECK_NP = 2;
  177. _PTHREAD_MUTEX_ADAPTIVE_NP = 3;
  178. _PTHREAD_MUTEX_NORMAL = _PTHREAD_MUTEX_TIMED_NP;
  179. _PTHREAD_MUTEX_RECURSIVE = _PTHREAD_MUTEX_RECURSIVE_NP;
  180. _PTHREAD_MUTEX_ERRORCHECK = _PTHREAD_MUTEX_ERRORCHECK_NP;
  181. _PTHREAD_MUTEX_DEFAULT = _PTHREAD_MUTEX_NORMAL;
  182. _PTHREAD_MUTEX_FAST_NP = _PTHREAD_MUTEX_ADAPTIVE_NP;
  183. { System limits, POSIX value in parentheses, used for buffer and stack allocation }
  184. { took idefix' values}
  185. ARG_MAX = 131072; {4096} { Maximum number of argument size }
  186. NAME_MAX = 255; {14} { Maximum number of bytes in filename }
  187. PATH_MAX = 4095; {255} { Maximum number of bytes in pathname }
  188. SYS_NMLN = 65;
  189. {$ifdef FPC_USE_LIBC}
  190. SIG_MAXSIG = 1024; // highest signal version
  191. {$else}
  192. SIG_MAXSIG = 128; // highest signal version
  193. {$endif}
  194. { For getting/setting priority }
  195. Prio_Process = 0;
  196. Prio_PGrp = 1;
  197. Prio_User = 2;