ptypes.inc 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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. dev_t = culong; { used for device numbers }
  27. TDev = dev_t;
  28. pDev = ^dev_t;
  29. kDev_t = cushort; // Linux has two different device conventions
  30. TkDev = KDev_t; // kernel and glibc. This is kernel.
  31. pkDev = ^kdev_t;
  32. gid_t = cuint32; { used for group IDs }
  33. TGid = gid_t;
  34. pGid = ^gid_t;
  35. TIOCtlRequest = cInt;
  36. ino_t = clong; { used for file serial numbers }
  37. TIno = ino_t;
  38. pIno = ^ino_t;
  39. mode_t = cuint32; { used for file attributes }
  40. TMode = mode_t;
  41. pMode = ^mode_t;
  42. nlink_t = cuint32; { used for link counts }
  43. TnLink = nlink_t;
  44. pnLink = ^nlink_t;
  45. {$ifdef cpu64}
  46. off_t = cint64; { used for file sizes }
  47. {$else}
  48. {$ifdef 64BitFS}
  49. off_t = cint64;
  50. {$else}
  51. off_t = cint;
  52. {$endif}
  53. {$endif}
  54. TOff = off_t;
  55. pOff = ^off_t;
  56. pid_t = cint32; { used as process identifier }
  57. TPid = pid_t;
  58. pPid = ^pid_t;
  59. {$ifdef cpu64}
  60. size_t = cuint64; { as definied in the C standard}
  61. ssize_t = cint64; { used by function for returning number of bytes }
  62. clock_t = cuint64;
  63. time_t = cint64; { used for returning the time }
  64. {$else}
  65. size_t = cuint32; { as definied in the C standard}
  66. ssize_t = cint32; { used by function for returning number of bytes }
  67. clock_t = culong;
  68. time_t = clong; { used for returning the time }
  69. {$endif}
  70. wint_t = cint32;
  71. TSize = size_t;
  72. pSize = ^size_t;
  73. psize_t = pSize;
  74. TSSize = ssize_t;
  75. pSSize = ^ssize_t;
  76. TClock = clock_t;
  77. pClock = ^clock_t;
  78. // TTime = time_t; // Not allowed in system unit, -> unixtype
  79. pTime = ^time_t;
  80. ptime_t = ^time_t;
  81. clockid_t = cint;
  82. caddr_t = ^char;
  83. uint32_t = cuint32;
  84. int32_t = cint32;
  85. caddr32_t = uint32_t;
  86. daddr32_t = int32_t;
  87. off32_t = int32_t;
  88. ino32_t = uint32_t;
  89. blkcnt32_t = int32_t;
  90. fsblkcnt32_t = uint32_t;
  91. fsfilcnt32_t = uint32_t;
  92. id32_t = int32_t;
  93. major32_t = uint32_t;
  94. minor32_t = uint32_t;
  95. key32_t = int32_t;
  96. mode32_t = uint32_t;
  97. uid32_t = int32_t;
  98. gid32_t = int32_t;
  99. nlink32_t = uint32_t;
  100. dev32_t = uint32_t;
  101. pid32_t = int32_t;
  102. size32_t = uint32_t;
  103. ssize32_t = int32_t;
  104. time32_t = int32_t;
  105. uint16_t = cuint16;
  106. upad64_t = qword;
  107. uintptr_t = ^cuint;
  108. uint_t = cuint;
  109. {$ifdef cpu64}
  110. wchar_t = cint;
  111. {$else cpu64}
  112. wchar_t = clong;
  113. {$endif cpu64}
  114. pwchar_t = ^wchar_t;
  115. uid_t = cuint32; { used for user ID type }
  116. TUid = uid_t;
  117. pUid = ^uid_t;
  118. socklen_t= cuint32;
  119. TSockLen = socklen_t;
  120. pSockLen = ^socklen_t;
  121. timeval = record
  122. tv_sec,
  123. tv_usec:clong;
  124. end;
  125. ptimeval = ^timeval;
  126. TTimeVal = timeval;
  127. timespec = record
  128. tv_sec : time_t;
  129. tv_nsec : clong;
  130. end;
  131. ptimespec = ^timespec;
  132. TTimeSpec = timespec;
  133. {$ifdef cpu64}
  134. fsblkcnt_t = culonglong;
  135. {$else}
  136. fsblkcnt_t = culong;
  137. {$endif}
  138. { actually stavfs, statfs is deprecated on Solaris }
  139. TStatfs = packed record
  140. bsize, { fundamental file system block size }
  141. frsize : culong; { fragment size }
  142. blocks, { Data blocks in system }
  143. bfree, { free blocks in system }
  144. bavail, { Available free blocks to non-root users }
  145. files, { File nodes in system }
  146. ffree, { Free file nodes in system }
  147. favail : fsblkcnt_t; { free nodes avail to non-superuser}
  148. fsid : clong; { File system ID }
  149. basetype: array [0..15] of char; { null-terminated fs type name }
  150. flag : culong; { bit-mask of flags }
  151. namelen : culong; { Maximum name length in system }
  152. fstr : array[0..31] of char; { fs-specific string }
  153. {$ifndef cpu64}
  154. spare : array[0..15] of clong; { reserved for future use }
  155. {$endif}
  156. end;
  157. PStatFS=^TStatFS;
  158. mbstate_t = record
  159. {$ifdef cpu64}
  160. __filler: array[0..3] of clong;
  161. {$else cpu64}
  162. __filler: array[0..5] of cint;
  163. {$endif cpu64}
  164. end;
  165. pmbstate_t = ^mbstate_t;
  166. clock32_t = int32_t;
  167. timeval32 = record
  168. { seconds }
  169. tv_sec : time32_t;
  170. { and microseconds }
  171. tv_usec : int32_t;
  172. end;
  173. timespec32 = record
  174. { seconds }
  175. tv_sec : time32_t;
  176. { and nanoseconds }
  177. tv_nsec : int32_t;
  178. end;
  179. timespec32_t = timespec32;
  180. itimerspec32 = record
  181. it_interval : timespec32;
  182. it_value : timespec32;
  183. end;
  184. itimerspec32_t = itimerspec32;
  185. const
  186. { System limits, POSIX value in parentheses, used for buffer and stack allocation }
  187. { took idefix' values}
  188. ARG_MAX = 131072; {4096} { Maximum number of argument size }
  189. NAME_MAX = 255; {14} { Maximum number of bytes in filename }
  190. PATH_MAX = 4095; {255} { Maximum number of bytes in pathname }
  191. SYS_NMLN = 65;
  192. SIG_MAXSIG = 128; // highest signal version
  193. { For getting/setting priority }
  194. Prio_Process = 0;
  195. Prio_PGrp = 1;
  196. Prio_User = 2;
  197. type
  198. pthread_t = cuint;
  199. pthread_attr_t = record
  200. __pthread_attrp : pointer;
  201. end;
  202. pthread_mutexattr_t = record
  203. __pthread_mutexattrp : pointer;
  204. end;
  205. pthread_cond_t = record
  206. __pthread_cond_flags : record
  207. __pthread_cond_flag : array[0..3] of byte;
  208. __pthread_cond_type : uint16_t;
  209. __pthread_cond_magic : uint16_t;
  210. end;
  211. __pthread_cond_data : upad64_t;
  212. end;
  213. pthread_condattr_t = record
  214. __pthread_condattrp : pointer;
  215. end;
  216. pthread_key_t = cuint;
  217. pthread_mutex_t = record
  218. __pthread_mutex_flags : record
  219. __pthread_mutex_flag1 : word;
  220. __pthread_mutex_flag2 : byte;
  221. __pthread_mutex_ceiling : byte;
  222. __pthread_mutex_type : word;
  223. __pthread_mutex_magic : word;
  224. end;
  225. __pthread_mutex_lock : record
  226. case longint of
  227. 0 : ( __pthread_mutex_lock64 : record
  228. __pthread_mutex_pad : array[0..7] of byte;
  229. end );
  230. 1 : ( __pthread_mutex_lock32 : record
  231. __pthread_ownerpid : dword;
  232. __pthread_lockword : dword;
  233. end );
  234. 2 : ( __pthread_mutex_owner64 : qword );
  235. end;
  236. __pthread_mutex_data : qword;
  237. end;
  238. pthread_rwlock_t = record
  239. __pthread_rwlock_readers : int32_t;
  240. __pthread_rwlock_type : uint16_t;
  241. __pthread_rwlock_magic : uint16_t;
  242. __pthread_rwlock_mutex : pthread_mutex_t;
  243. __pthread_rwlock_readercv : pthread_cond_t;
  244. __pthread_rwlock_writercv : pthread_cond_t;
  245. end;
  246. sem_t = record
  247. sem_count : uint32_t;
  248. sem_type : uint16_t;
  249. sem_magic : uint16_t;
  250. sem_pad1 : array[0..2] of upad64_t;
  251. sem_pad2 : array[0..1] of upad64_t;
  252. end;