ptypes.inc 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. - fs32bit, should be on if libc only supports sizeof(off_t)=4
  18. we assume one typically compiles C applications with
  19. #define _FILE_OFFSET_BITS 64
  20. All three tested systems (PPC,Alpha,2x i386) gave the same POSIX limits,
  21. and all three 32-bit systems returned completely identical types too
  22. (everything 32-bit except dev_t, which is assumed to be a result of devfs
  23. introduction)
  24. }
  25. {$I ctypes.inc}
  26. {$packrecords c}
  27. Type
  28. {$ifndef VER_1_0} // maybe wrong (kernel vs libc)
  29. dev_t = cuint64; { used for device numbers }
  30. {$else}
  31. dev_t = int64;
  32. {$endif}
  33. TDev = dev_t;
  34. pDev = ^dev_t;
  35. kDev_t = cushort; // Linux has two different device conventions
  36. TkDev = KDev_t; // kernel and glibc. This is kernel.
  37. pkDev = ^kdev_t;
  38. gid_t = cuint32; { used for group IDs }
  39. TGid = gid_t;
  40. pGid = ^gid_t;
  41. ino_t = clong; { used for file serial numbers }
  42. TIno = ino_t;
  43. pIno = ^ino_t;
  44. ino64_t = cuint64;
  45. TIno64 = ino64_t;
  46. pIno64 = ^ino64_t;
  47. mode_t = cuint32; { used for file attributes }
  48. TMode = mode_t;
  49. pMode = ^mode_t;
  50. nlink_t = cuint32; { used for link counts }
  51. TnLink = nlink_t;
  52. pnLink = ^nlink_t;
  53. {$if not defined(fs32bit)}
  54. off_t = cint64; { used for file sizes }
  55. {$else}
  56. off_t = cint;
  57. {$endif}
  58. TOff = off_t;
  59. pOff = ^off_t;
  60. pid_t = cint32; { used as process identifier }
  61. TPid = pid_t;
  62. pPid = ^pid_t;
  63. {$ifdef cpu64}
  64. size_t = cuint64; { as definied in the C standard}
  65. ssize_t = cint64; { used by function for returning number of bytes }
  66. clock_t = cuint64;
  67. time_t = cint64; { used for returning the time }
  68. {$else}
  69. size_t = cuint32; { as definied in the C standard}
  70. ssize_t = cint32; { used by function for returning number of bytes }
  71. clock_t = culong;
  72. time_t = clong; { used for returning the time }
  73. {$endif}
  74. wint_t = cint32;
  75. TSize = size_t;
  76. pSize = ^size_t;
  77. psize_t = pSize;
  78. TSSize = ssize_t;
  79. pSSize = ^ssize_t;
  80. TClock = clock_t;
  81. pClock = ^clock_t;
  82. TTime = time_t;
  83. pTime = ^time_t;
  84. ptime_t = ^time_t;
  85. wchar_t = widechar;
  86. pwchar_t = ^wchar_t;
  87. uid_t = cuint32; { used for user ID type }
  88. TUid = uid_t;
  89. pUid = ^uid_t;
  90. socklen_t= cuint32;
  91. TSockLen = socklen_t;
  92. pSockLen = ^socklen_t;
  93. timeval = packed record
  94. tv_sec,
  95. tv_usec:clong;
  96. end;
  97. ptimeval = ^timeval;
  98. TTimeVal = timeval;
  99. timespec = packed record
  100. tv_sec : time_t;
  101. tv_nsec : clong;
  102. end;
  103. ptimespec = ^timespec;
  104. TTimeSpec = timespec;
  105. TStatfs = packed record
  106. fstype, { File system type }
  107. bsize : cint; { Optimal block trensfer size }
  108. blocks, { Data blocks in system }
  109. bfree, { free blocks in system }
  110. bavail, { Available free blocks to non-root users }
  111. files, { File nodes in system }
  112. ffree : clong; { Free file nodes in system }
  113. fsid : array[0..1] of cint; { File system ID }
  114. namelen : clong; { Maximum name length in system }
  115. spare : array [0..5] of clong; { For later use }
  116. end;
  117. PStatFS=^TStatFS;
  118. pthread_t = culong;
  119. sched_param = record
  120. __sched_priority: cint;
  121. end;
  122. pthread_attr_t = record
  123. __detachstate: cint;
  124. __schedpolicy: cint;
  125. __schedparam: sched_param;
  126. __inheritsched: cint;
  127. __scope: cint;
  128. __guardsize: size_t;
  129. __stackaddr_set: cint;
  130. __stackaddr: pointer;
  131. __stacksize: size_t;
  132. end;
  133. _pthread_fastlock = record
  134. __status: clong;
  135. __spinlock: cint;
  136. end;
  137. pthread_mutex_t = record
  138. __m_reserved: cint;
  139. __m_count: cint;
  140. __m_owner: pointer;
  141. __m_kind: cint;
  142. __m_lock: _pthread_fastlock;
  143. end;
  144. pthread_mutexattr_t = record
  145. __mutexkind: cint;
  146. end;
  147. pthread_cond_t = record
  148. __c_lock: _pthread_fastlock;
  149. __c_waiting: pointer;
  150. __padding: array[0..48-1-sizeof(_pthread_fastlock)-sizeof(pointer)-sizeof(clonglong)] of byte;
  151. __align: clonglong;
  152. end;
  153. pthread_condattr_t = record
  154. __dummy: cint;
  155. end;
  156. pthread_key_t = cuint;
  157. pthread_rwlock_t = record
  158. __rw_readers: cint;
  159. __rw_writer: pointer;
  160. __rw_read_waiting: pointer;
  161. __rw_write_waiting: pointer;
  162. __rw_kind: cint;
  163. __rw_pshared: cint;
  164. end;
  165. pthread_rwlockattr_t = record
  166. __lockkind: cint;
  167. __pshared: cint;
  168. end;
  169. sem_t = record
  170. __sem_lock: _pthread_fastlock;
  171. __sem_value: cint;
  172. __sem_waiting: pointer;
  173. end;
  174. CONST
  175. _PTHREAD_MUTEX_TIMED_NP = 0;
  176. _PTHREAD_MUTEX_RECURSIVE_NP = 1;
  177. _PTHREAD_MUTEX_ERRORCHECK_NP = 2;
  178. _PTHREAD_MUTEX_ADAPTIVE_NP = 3;
  179. _PTHREAD_MUTEX_NORMAL = _PTHREAD_MUTEX_TIMED_NP;
  180. _PTHREAD_MUTEX_RECURSIVE = _PTHREAD_MUTEX_RECURSIVE_NP;
  181. _PTHREAD_MUTEX_ERRORCHECK = _PTHREAD_MUTEX_ERRORCHECK_NP;
  182. _PTHREAD_MUTEX_DEFAULT = _PTHREAD_MUTEX_NORMAL;
  183. _PTHREAD_MUTEX_FAST_NP = _PTHREAD_MUTEX_ADAPTIVE_NP;
  184. { System limits, POSIX value in parentheses, used for buffer and stack allocation }
  185. { took idefix' values}
  186. ARG_MAX = 131072; {4096} { Maximum number of argument size }
  187. NAME_MAX = 255; {14} { Maximum number of bytes in filename }
  188. PATH_MAX = 4095; {255} { Maximum number of bytes in pathname }
  189. SYS_NMLN = 65;
  190. {$ifdef FPC_USE_LIBC}
  191. SIG_MAXSIG = 1024; // highest signal version
  192. {$else}
  193. SIG_MAXSIG = 128; // highest signal version
  194. {$endif}
  195. { For getting/setting priority }
  196. Prio_Process = 0;
  197. Prio_PGrp = 1;
  198. Prio_User = 2;