ptypes.inc 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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 = cuint; { 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;
  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 = packed record
  122. tv_sec,
  123. tv_usec:clong;
  124. end;
  125. ptimeval = ^timeval;
  126. TTimeVal = timeval;
  127. timespec = packed record
  128. tv_sec : time_t;
  129. tv_nsec : clong;
  130. end;
  131. ptimespec = ^timespec;
  132. TTimeSpec = timespec;
  133. TStatfs = packed record
  134. fstype, { File system type }
  135. bsize : cint; { Optimal block trensfer size }
  136. blocks, { Data blocks in system }
  137. bfree, { free blocks in system }
  138. bavail, { Available free blocks to non-root users }
  139. files, { File nodes in system }
  140. ffree : clong; { Free file nodes in system }
  141. fsid : array[0..1] of cint; { File system ID }
  142. namelen : clong; { Maximum name length in system }
  143. spare : array [0..5] of clong; { For later use }
  144. end;
  145. PStatFS=^TStatFS;
  146. mbstate_t = record
  147. {$ifdef cpu64}
  148. __filler: array[0..3] of clong;
  149. {$else cpu64}
  150. __filler: array[0..5] of cint;
  151. {$endif cpu64}
  152. end;
  153. pmbstate_t = ^mbstate_t;
  154. clock32_t = int32_t;
  155. timeval32 = record
  156. { seconds }
  157. tv_sec : time32_t;
  158. { and microseconds }
  159. tv_usec : int32_t;
  160. end;
  161. timespec32 = record
  162. { seconds }
  163. tv_sec : time32_t;
  164. { and nanoseconds }
  165. tv_nsec : int32_t;
  166. end;
  167. timespec32_t = timespec32;
  168. itimerspec32 = record
  169. it_interval : timespec32;
  170. it_value : timespec32;
  171. end;
  172. itimerspec32_t = itimerspec32;
  173. const
  174. { System limits, POSIX value in parentheses, used for buffer and stack allocation }
  175. { took idefix' values}
  176. ARG_MAX = 131072; {4096} { Maximum number of argument size }
  177. NAME_MAX = 255; {14} { Maximum number of bytes in filename }
  178. PATH_MAX = 4095; {255} { Maximum number of bytes in pathname }
  179. SYS_NMLN = 65;
  180. SIG_MAXSIG = 128; // highest signal version
  181. { For getting/setting priority }
  182. Prio_Process = 0;
  183. Prio_PGrp = 1;
  184. Prio_User = 2;
  185. type
  186. pthread_t = cuint;
  187. pthread_attr_t = record
  188. __pthread_attrp : pointer;
  189. end;
  190. pthread_mutexattr_t = record
  191. __pthread_mutexattrp : pointer;
  192. end;
  193. pthread_cond_t = record
  194. __pthread_cond_flags : record
  195. __pthread_cond_flag : array[0..3] of byte;
  196. __pthread_cond_type : uint16_t;
  197. __pthread_cond_magic : uint16_t;
  198. end;
  199. __pthread_cond_data : upad64_t;
  200. end;
  201. pthread_condattr_t = record
  202. __pthread_condattrp : pointer;
  203. end;
  204. pthread_key_t = cuint;
  205. pthread_mutex_t = record
  206. __pthread_mutex_flags : record
  207. __pthread_mutex_flag1 : word;
  208. __pthread_mutex_flag2 : byte;
  209. __pthread_mutex_ceiling : byte;
  210. __pthread_mutex_type : word;
  211. __pthread_mutex_magic : word;
  212. end;
  213. __pthread_mutex_lock : record
  214. case longint of
  215. 0 : ( __pthread_mutex_lock64 : record
  216. __pthread_mutex_pad : array[0..7] of byte;
  217. end );
  218. 1 : ( __pthread_mutex_lock32 : record
  219. __pthread_ownerpid : dword;
  220. __pthread_lockword : dword;
  221. end );
  222. 2 : ( __pthread_mutex_owner64 : qword );
  223. end;
  224. __pthread_mutex_data : qword;
  225. end;
  226. pthread_rwlock_t = record
  227. __pthread_rwlock_readers : int32_t;
  228. __pthread_rwlock_type : uint16_t;
  229. __pthread_rwlock_magic : uint16_t;
  230. __pthread_rwlock_mutex : pthread_mutex_t;
  231. __pthread_rwlock_readercv : pthread_cond_t;
  232. __pthread_rwlock_writercv : pthread_cond_t;
  233. end;
  234. sem_t = record
  235. sem_count : uint32_t;
  236. sem_type : uint16_t;
  237. sem_magic : uint16_t;
  238. sem_pad1 : array[0..2] of upad64_t;
  239. sem_pad2 : array[0..1] of upad64_t;
  240. end;