ptypes.inc 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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. dev_t = cuint64; { used for device numbers }
  29. TDev = dev_t;
  30. pDev = ^dev_t;
  31. kDev_t = cushort; // Linux has two different device conventions
  32. TkDev = KDev_t; // kernel and glibc. This is kernel.
  33. pkDev = ^kdev_t;
  34. ino_t = clong; { used for file serial numbers }
  35. TIno = ino_t;
  36. pIno = ^ino_t;
  37. ino64_t = cuint64;
  38. TIno64 = ino64_t;
  39. pIno64 = ^ino64_t;
  40. {$ifdef cpu64}
  41. mode_t = cint; { used for file attributes }
  42. {$else cpu64}
  43. mode_t = cuint32; { used for file attributes }
  44. {$endif cpu64}
  45. TMode = mode_t;
  46. pMode = ^mode_t;
  47. nlink_t = cuint32; { used for link counts }
  48. TnLink = nlink_t;
  49. pnLink = ^nlink_t;
  50. {$if not defined(fs32bit)}
  51. off_t = cint64; { used for file sizes }
  52. {$else}
  53. off_t = cint;
  54. {$endif}
  55. TOff = off_t;
  56. pOff = ^off_t;
  57. off64_t = cint64;
  58. TOff64 = off64_t;
  59. pOff64 = ^off64_t;
  60. pid_t = cint; { 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; // Not allowed in system unit, -> unixtype
  83. pTime = ^time_t;
  84. ptime_t = ^time_t;
  85. wchar_t = cint32;
  86. pwchar_t = ^wchar_t;
  87. {$ifdef cpu64}
  88. uid_t = cuint32; { used for user ID type }
  89. gid_t = cuint32; { used for group IDs }
  90. ipc_pid_t = cint;
  91. {$else cpu64}
  92. uid_t = cuint32; { used for user ID type }
  93. gid_t = cuint32; { used for group IDs }
  94. ipc_pid_t = cushort; // still 16-bit
  95. {$endif cpu64}
  96. TUid = uid_t;
  97. pUid = ^uid_t;
  98. TGid = gid_t;
  99. pGid = ^gid_t;
  100. TIOCtlRequest = cInt;
  101. socklen_t= cuint32;
  102. TSockLen = socklen_t;
  103. pSockLen = ^socklen_t;
  104. timeval = packed record
  105. tv_sec:time_t;
  106. tv_usec:clong;
  107. end;
  108. ptimeval = ^timeval;
  109. TTimeVal = timeval;
  110. timespec = packed record
  111. tv_sec : time_t;
  112. tv_nsec : clong;
  113. end;
  114. ptimespec = ^timespec;
  115. TTimeSpec = timespec;
  116. {$ifdef cpu64}
  117. TStatfs = packed record
  118. fstype, { File system type }
  119. bsize : clong; { Optimal block trensfer size }
  120. blocks, { Data blocks in system }
  121. bfree, { free blocks in system }
  122. bavail, { Available free blocks to non-root users }
  123. files, { File nodes in system }
  124. ffree : culong; { Free file nodes in system }
  125. fsid : array[0..1] of cint; { File system ID }
  126. namelen : clong; { Maximum name length in system }
  127. frsize : clong;
  128. spare : array [0..4] of clong; { For later use }
  129. end;
  130. {$else}
  131. TStatfs = packed record
  132. fstype, { File system type }
  133. bsize : cint; { Optimal block trensfer size }
  134. blocks, { Data blocks in system }
  135. bfree, { free blocks in system }
  136. bavail, { Available free blocks to non-root users }
  137. files, { File nodes in system }
  138. ffree : culong; { Free file nodes in system }
  139. fsid : array[0..1] of cint; { File system ID }
  140. namelen, { Maximum name length in system }
  141. frsize : cint;
  142. spare : array [0..4] of cint; { For later use }
  143. end;
  144. {$endif}
  145. PStatFS=^TStatFS;
  146. mbstate_value_t = record
  147. case byte of
  148. 0: (__wch: wint_t);
  149. 1: (__wchb: array[0..3] of char);
  150. end;
  151. mbstate_t = record
  152. __count: cint;
  153. __value: mbstate_value_t;
  154. end;
  155. pmbstate_t = ^mbstate_t;
  156. pthread_t = culong;
  157. sched_param = record
  158. __sched_priority: cint;
  159. end;
  160. pthread_attr_t = record
  161. __detachstate: cint;
  162. __schedpolicy: cint;
  163. __schedparam: sched_param;
  164. __inheritsched: cint;
  165. __scope: cint;
  166. __guardsize: size_t;
  167. __stackaddr_set: cint;
  168. __stackaddr: pointer;
  169. __stacksize: size_t;
  170. end;
  171. _pthread_fastlock = record
  172. __status: clong;
  173. __spinlock: cint;
  174. end;
  175. pthread_mutex_t = record
  176. __m_reserved: cint;
  177. __m_count: cint;
  178. __m_owner: pointer;
  179. __m_kind: cint;
  180. __m_lock: _pthread_fastlock;
  181. end;
  182. pthread_mutexattr_t = record
  183. __mutexkind: cint;
  184. end;
  185. pthread_cond_t = record
  186. __c_lock: _pthread_fastlock;
  187. __c_waiting: pointer;
  188. __padding: array[0..48-1-sizeof(_pthread_fastlock)-sizeof(pointer)-sizeof(clonglong)] of byte;
  189. __align: clonglong;
  190. end;
  191. pthread_condattr_t = record
  192. __dummy: cint;
  193. end;
  194. pthread_key_t = cuint;
  195. pthread_rwlock_t = record
  196. __rw_readers: cint;
  197. __rw_writer: pointer;
  198. __rw_read_waiting: pointer;
  199. __rw_write_waiting: pointer;
  200. __rw_kind: cint;
  201. __rw_pshared: cint;
  202. end;
  203. pthread_rwlockattr_t = record
  204. __lockkind: cint;
  205. __pshared: cint;
  206. end;
  207. sem_t = record
  208. __sem_lock: _pthread_fastlock;
  209. __sem_value: cint;
  210. __sem_waiting: pointer;
  211. end;
  212. CONST
  213. _PTHREAD_MUTEX_TIMED_NP = 0;
  214. _PTHREAD_MUTEX_RECURSIVE_NP = 1;
  215. _PTHREAD_MUTEX_ERRORCHECK_NP = 2;
  216. _PTHREAD_MUTEX_ADAPTIVE_NP = 3;
  217. _PTHREAD_MUTEX_NORMAL = _PTHREAD_MUTEX_TIMED_NP;
  218. _PTHREAD_MUTEX_RECURSIVE = _PTHREAD_MUTEX_RECURSIVE_NP;
  219. _PTHREAD_MUTEX_ERRORCHECK = _PTHREAD_MUTEX_ERRORCHECK_NP;
  220. _PTHREAD_MUTEX_DEFAULT = _PTHREAD_MUTEX_NORMAL;
  221. _PTHREAD_MUTEX_FAST_NP = _PTHREAD_MUTEX_ADAPTIVE_NP;
  222. { System limits, POSIX value in parentheses, used for buffer and stack allocation }
  223. { took idefix' values}
  224. ARG_MAX = 131072; {4096} { Maximum number of argument size }
  225. NAME_MAX = 255; {14} { Maximum number of bytes in filename }
  226. PATH_MAX = 4095; {255} { Maximum number of bytes in pathname }
  227. SYS_NMLN = 65;
  228. {$ifdef FPC_USE_LIBC}
  229. SIG_MAXSIG = 1024; // highest signal version
  230. {$else}
  231. SIG_MAXSIG = 128; // highest signal version
  232. {$endif}
  233. { For getting/setting priority }
  234. Prio_Process = 0;
  235. Prio_PGrp = 1;
  236. Prio_User = 2;