ptypes.inc 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2001 by Free Pascal development team
  4. Copyright (c) 2011 by Jonas Maebe
  5. This file implements all the base types and limits required
  6. for a minimal POSIX compliant subset required to port the compiler
  7. to a new OS.
  8. See the file COPYING.FPC, included in this distribution,
  9. for details about the copyright.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. **********************************************************************}
  14. {***********************************************************************}
  15. { POSIX TYPE DEFINITIONS }
  16. {***********************************************************************}
  17. { Introduced defines
  18. - 64bitfs (should be on if libc switches to a 64-bit system.
  19. All three tested systems (PPC,Alpha,2x i386) gave the same POSIX limits,
  20. and all three 32-bit systems returned completely identical types too
  21. (everything 32-bit except dev_t, which is assumed to be a result of devfs
  22. introduction)
  23. }
  24. {$I ctypes.inc}
  25. {$packrecords c}
  26. Type
  27. dev_t = {$ifdef cpu64}culong{$else}cuint{$endif};
  28. TDev = dev_t;
  29. pDev = ^dev_t;
  30. gid_t = cuint; { used for group IDs }
  31. TGid = gid_t;
  32. pGid = ^gid_t;
  33. TIOCtlRequest = cInt;
  34. ino_t = {$ifdef cpu64}culong{$else}cuint{$endif}; { used for file serial numbers }
  35. TIno = ino_t;
  36. pIno = ^ino_t;
  37. ino64_t = cuint64;
  38. mode_t = cuint; { used for file attributes }
  39. TMode = mode_t;
  40. pMode = ^mode_t;
  41. nlink_t = cshort; { used for link counts }
  42. TnLink = nlink_t;
  43. pnLink = ^nlink_t;
  44. off_t = clonglong; { used for file sizes }
  45. TOff = off_t;
  46. pOff = ^off_t;
  47. pid_t = cint; { used as process identifier }
  48. TPid = pid_t;
  49. pPid = ^pid_t;
  50. size_t = culong; { as definied in the C standard}
  51. ssize_t = clong; { used by function for returning number of bytes }
  52. clock_t = cint;
  53. time_t = {$ifdef cpu64}clong{$else}cint{$endif}; { used for returning the time }
  54. wint_t = cint;
  55. TSize = size_t;
  56. pSize = ^size_t;
  57. psize_t = pSize;
  58. TSSize = ssize_t;
  59. pSSize = ^ssize_t;
  60. TClock = clock_t;
  61. pClock = ^clock_t;
  62. // TTime = time_t; // Not allowed in system unit, -> unixtype
  63. pTime = ^time_t;
  64. ptime_t = ^time_t;
  65. clockid_t = clonglong;
  66. caddr_t = ^AnsiChar;
  67. uint32_t = cuint32;
  68. int32_t = cint32;
  69. // caddr32_t = uint32_t;
  70. daddr32_t = cint;
  71. // off32_t = cuint;
  72. ino32_t = cuint;
  73. blkcnt32_t = cint;
  74. // fsblkcnt32_t = uint32_t;
  75. // fsfilcnt32_t = uint32_t;
  76. // id32_t = int32_t;
  77. // major32_t = uint32_t;
  78. // minor32_t = uint32_t;
  79. // key32_t = int32_t;
  80. // mode32_t = uint32_t;
  81. // uid32_t = int32_t;
  82. // gid32_t = int32_t;
  83. // nlink32_t = uint32_t;
  84. dev32_t = cuint;
  85. pid32_t = cuint;
  86. // size32_t = uint32_t;
  87. // ssize32_t = int32_t;
  88. time32_t = cint;
  89. uint16_t = cuint16;
  90. // upad64_t = qword;
  91. uintptr_t = ^cuint;
  92. uint_t = cuint;
  93. fsid_t = record
  94. val: array[0..1] of cuint;
  95. end;
  96. fsid64_t = record
  97. val: array[0..1] of cuint64;
  98. end;
  99. {$ifdef cpu64}
  100. wchar_t = cuint;
  101. {$else cpu64}
  102. wchar_t = cushort; { utf-16! }
  103. {$endif cpu64}
  104. pwchar_t = ^wchar_t;
  105. uid_t = cuint; { used for user ID type }
  106. TUid = uid_t;
  107. pUid = ^uid_t;
  108. socklen_t= cuint32;
  109. TSockLen = socklen_t;
  110. pSockLen = ^socklen_t;
  111. suseconds_t = cint;
  112. timeval = record
  113. tv_sec : time_t;
  114. tv_usec : suseconds_t;
  115. end;
  116. ptimeval = ^timeval;
  117. TTimeVal = timeval;
  118. timespec = record
  119. tv_sec : time_t;
  120. tv_nsec : clong;
  121. end;
  122. ptimespec = ^timespec;
  123. TTimeSpec = timespec;
  124. fsblkcnt_t = culong;
  125. TStatfs = record
  126. f_version : cint; { version/type of statfs, 0 for now }
  127. f_type : cint; { type of info, zero for now }
  128. bsize : culong; { fundamental file system block size }
  129. blocks, { total data blocks in file system }
  130. bfree, { free blocks in fs }
  131. bavail, { free blocks avail to non-superuser }
  132. files, { total file nodes in file system }
  133. ffree : fsblkcnt_t; { free file nodes in fs }
  134. {$ifdef cpu64}
  135. fsid : fsid64_t;{ File system ID }
  136. {$else}
  137. fsid : fsid_t;
  138. {$endif}
  139. vfstype : cint; { what type of vfs this is }
  140. fsize : culong; { fundamental file system block size }
  141. vfsnumber : cint; { vfs indentifier number }
  142. vfsoff : cint; { reserved, for vfs specific data offset }
  143. vfslen : cint; { reserved, for len of vfs specific data }
  144. vfsvers : cint; { reserved, for vers of vfs specific data }
  145. fstr : array[0..31] of AnsiChar; { fname in C header, file system name (usually mount pt.) }
  146. fpack : array[0..31] of AnsiChar; { file system pack name }
  147. namelen : cint; { maximum component name length for posix }
  148. end;
  149. PStatFS=^TStatFS;
  150. mbstate_t = pointer;
  151. pmbstate_t = ^mbstate_t;
  152. // clock32_t = int32_t;
  153. timeval32 = record
  154. { seconds }
  155. tv_sec : int32_t;
  156. { and microseconds }
  157. tv_usec : int32_t;
  158. end;
  159. const
  160. { System limits, POSIX value in parentheses, used for buffer and stack allocation }
  161. { took idefix' values}
  162. ARG_MAX = 24576; { Maximum number of argument size }
  163. // depends on file system, must use pathconf() or fpathconf() instead of constant!
  164. NAME_MAX = 255; { Maximum number of bytes in filename }
  165. PATH_MAX = 1023; { Maximum number of bytes in pathname }
  166. SYS_NMLN = 32;
  167. {$ifdef cpu64}
  168. SIG_MAXSIG = 255; // highest signal number
  169. {$else}
  170. SIG_MAXSIG = 63; // highest signal number
  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 = pointer;
  179. pthread_mutexattr_t = pointer;
  180. pthread_cond_t = record
  181. {$ifdef cpu64}
  182. __co_word: array[0..5] of clong;
  183. {$else}
  184. __co_word: array[0..10] of cint;
  185. {$endif}
  186. end;
  187. pthread_condattr_t = pointer;
  188. pthread_key_t = cuint;
  189. pthread_mutex_t = record
  190. {$ifdef cpu64}
  191. __mt_word: array[0..7] of clong;
  192. {$else}
  193. __mt_word: array[0..12] of cint;
  194. {$endif}
  195. end;
  196. pthread_rwlock_t = record
  197. {$ifdef cpu64}
  198. __rw_word: array[0..9] of clong;
  199. {$else}
  200. __rw_word: array[0..51] of cint;
  201. {$endif}
  202. end;
  203. sem_t = cint;