ptypes.inc 7.6 KB

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