ptypes.inc 6.7 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. - fs64bit (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. ino64_t = cuint64;
  43. TIno64 = ino64_t;
  44. pIno64 = ^ino64_t;
  45. mode_t = cuint32; { used for file attributes }
  46. TMode = mode_t;
  47. pMode = ^mode_t;
  48. nlink_t = cuint32; { used for link counts }
  49. TnLink = nlink_t;
  50. pnLink = ^nlink_t;
  51. {$if not defined(FPC_USE_LIBC) or defined(fs64bit)}
  52. off_t = cint64; { used for file sizes }
  53. {$else}
  54. off_t = cint;
  55. {$endif}
  56. TOff = off_t;
  57. pOff = ^off_t;
  58. pid_t = cint32; { used as process identifier }
  59. TPid = pid_t;
  60. pPid = ^pid_t;
  61. {$ifdef cpu64}
  62. size_t = cuint64; { as definied in the C standard}
  63. ssize_t = cint64; { used by function for returning number of bytes }
  64. clock_t = cuint64;
  65. time_t = cint64; { used for returning the time }
  66. {$else}
  67. size_t = cuint32; { as definied in the C standard}
  68. ssize_t = cint32; { used by function for returning number of bytes }
  69. clock_t = culong;
  70. time_t = clong; { used for returning the time }
  71. {$endif}
  72. wint_t = cint32;
  73. TSize = size_t;
  74. pSize = ^size_t;
  75. psize_t = pSize;
  76. TSSize = ssize_t;
  77. pSSize = ^ssize_t;
  78. TClock = clock_t;
  79. pClock = ^clock_t;
  80. TTime = time_t;
  81. pTime = ^time_t;
  82. ptime_t = ^time_t;
  83. wchar_t = widechar;
  84. pwchar_t = ^wchar_t;
  85. uid_t = cuint32; { used for user ID type }
  86. TUid = uid_t;
  87. pUid = ^uid_t;
  88. socklen_t= cuint32;
  89. TSockLen = socklen_t;
  90. pSockLen = ^socklen_t;
  91. timeval = packed record
  92. tv_sec,
  93. tv_usec:clong;
  94. end;
  95. ptimeval = ^timeval;
  96. TTimeVal = timeval;
  97. timespec = packed record
  98. tv_sec : time_t;
  99. tv_nsec : clong;
  100. end;
  101. ptimespec = ^timespec;
  102. TTimeSpec = timespec;
  103. TStatfs = packed record
  104. fstype, { File system type }
  105. bsize : cint; { Optimal block trensfer size }
  106. blocks, { Data blocks in system }
  107. bfree, { free blocks in system }
  108. bavail, { Available free blocks to non-root users }
  109. files, { File nodes in system }
  110. ffree : clong; { Free file nodes in system }
  111. fsid : array[0..1] of cint; { File system ID }
  112. namelen : clong; { Maximum name length in system }
  113. spare : array [0..5] of clong; { For later use }
  114. end;
  115. PStatFS=^TStatFS;
  116. pthread_t = culong;
  117. sched_param = record
  118. __sched_priority: cint;
  119. end;
  120. pthread_attr_t = record
  121. __detachstate: cint;
  122. __schedpolicy: cint;
  123. __schedparam: sched_param;
  124. __inheritsched: cint;
  125. __scope: cint;
  126. __guardsize: size_t;
  127. __stackaddr_set: cint;
  128. __stackaddr: pointer;
  129. __stacksize: size_t;
  130. end;
  131. _pthread_fastlock = record
  132. __status: clong;
  133. __spinlock: cint;
  134. end;
  135. pthread_mutex_t = record
  136. __m_reserved: cint;
  137. __m_count: cint;
  138. __m_owner: pointer;
  139. __m_kind: cint;
  140. __m_lock: _pthread_fastlock;
  141. end;
  142. pthread_mutexattr_t = record
  143. __mutexkind: cint;
  144. end;
  145. pthread_cond_t = record
  146. __c_lock: _pthread_fastlock;
  147. __c_waiting: pointer;
  148. __padding: array[0..48-1-sizeof(_pthread_fastlock)-sizeof(pointer)-sizeof(clonglong)] of byte;
  149. __align: clonglong;
  150. end;
  151. pthread_condattr_t = record
  152. __dummy: cint;
  153. end;
  154. pthread_key_t = cuint;
  155. pthread_rwlock_t = record
  156. __rw_readers: cint;
  157. __rw_writer: pointer;
  158. __rw_read_waiting: pointer;
  159. __rw_write_waiting: pointer;
  160. __rw_kind: cint;
  161. __rw_pshared: cint;
  162. end;
  163. pthread_rwlockattr_t = record
  164. __lockkind: cint;
  165. __pshared: cint;
  166. end;
  167. sem_t = record
  168. __sem_lock: _pthread_fastlock;
  169. __sem_value: cint;
  170. __sem_waiting: pointer;
  171. end;
  172. CONST
  173. _PTHREAD_MUTEX_TIMED_NP = 0;
  174. _PTHREAD_MUTEX_RECURSIVE_NP = 1;
  175. _PTHREAD_MUTEX_ERRORCHECK_NP = 2;
  176. _PTHREAD_MUTEX_ADAPTIVE_NP = 3;
  177. _PTHREAD_MUTEX_NORMAL = _PTHREAD_MUTEX_TIMED_NP;
  178. _PTHREAD_MUTEX_RECURSIVE = _PTHREAD_MUTEX_RECURSIVE_NP;
  179. _PTHREAD_MUTEX_ERRORCHECK = _PTHREAD_MUTEX_ERRORCHECK_NP;
  180. _PTHREAD_MUTEX_DEFAULT = _PTHREAD_MUTEX_NORMAL;
  181. _PTHREAD_MUTEX_FAST_NP = _PTHREAD_MUTEX_ADAPTIVE_NP;
  182. { System limits, POSIX value in parentheses, used for buffer and stack allocation }
  183. { took idefix' values}
  184. ARG_MAX = 131072; {4096} { Maximum number of argument size }
  185. NAME_MAX = 255; {14} { Maximum number of bytes in filename }
  186. PATH_MAX = 4095; {255} { Maximum number of bytes in pathname }
  187. SYS_NMLN = 65;
  188. {$ifdef FPC_USE_LIBC}
  189. SIG_MAXSIG = 1024; // highest signal version
  190. {$else}
  191. SIG_MAXSIG = 128; // highest signal version
  192. {$endif}
  193. { For getting/setting priority }
  194. Prio_Process = 0;
  195. Prio_PGrp = 1;
  196. Prio_User = 2;