ptypes.inc 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2001 by Free Pascal development team
  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. {$ifndef VER_1_0} // maybe wrong (kernel vs libc)
  28. dev_t = cuint64; { used for device numbers }
  29. {$else}
  30. dev_t = int64;
  31. {$endif}
  32. TDev = dev_t;
  33. pDev = ^dev_t;
  34. kDev_t = cushort; // Linux has two different device conventions
  35. TkDev = KDev_t; // kernel and glibc. This is kernel.
  36. pkDev = ^kdev_t;
  37. gid_t = cuint32; { used for group IDs }
  38. TGid = gid_t;
  39. pGid = ^gid_t;
  40. ino_t = clong; { used for file serial numbers }
  41. TIno = ino_t;
  42. pIno = ^ino_t;
  43. mode_t = cuint32; { used for file attributes }
  44. TMode = mode_t;
  45. pMode = ^mode_t;
  46. nlink_t = cuint32; { used for link counts }
  47. TnLink = nlink_t;
  48. pnLink = ^nlink_t;
  49. {$ifdef cpu64}
  50. off_t = cint64; { used for file sizes }
  51. {$else}
  52. {$ifdef 64BitFS}
  53. off_t = cint64;
  54. {$else}
  55. off_t = cint;
  56. {$endif}
  57. {$endif}
  58. TOff = off_t;
  59. pOff = ^off_t;
  60. pid_t = cint32; { 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. TSize = size_t;
  75. pSize = ^size_t;
  76. TSSize = ssize_t;
  77. pSSize = ^ssize_t;
  78. TClock = clock_t;
  79. pClock = ^clock_t;
  80. TTime = time_t;
  81. pTime = ^time_t;
  82. ptime_t = ^time_t;
  83. uid_t = cuint32; { used for user ID type }
  84. TUid = uid_t;
  85. pUid = ^uid_t;
  86. socklen_t= cuint32;
  87. TSockLen = socklen_t;
  88. pSockLen = ^socklen_t;
  89. timeval = packed record
  90. tv_sec,
  91. tv_usec:clong;
  92. end;
  93. ptimeval = ^timeval;
  94. TTimeVal = timeval;
  95. timespec = packed record
  96. tv_sec : time_t;
  97. tv_nsec : clong;
  98. end;
  99. ptimespec = ^timespec;
  100. TTimeSpec = timespec;
  101. TStatfs = packed record
  102. fstype, { File system type }
  103. bsize : cint; { Optimal block trensfer size }
  104. blocks, { Data blocks in system }
  105. bfree, { free blocks in system }
  106. bavail, { Available free blocks to non-root users }
  107. files, { File nodes in system }
  108. ffree : clong; { Free file nodes in system }
  109. fsid : array[0..1] of cint; { File system ID }
  110. namelen : clong; { Maximum name length in system }
  111. spare : array [0..5] of clong; { For later use }
  112. end;
  113. PStatFS=^TStatFS;
  114. pthread_t = culong;
  115. sched_param = record
  116. __sched_priority: cint;
  117. end;
  118. pthread_attr_t = record
  119. __detachstate: cint;
  120. __schedpolicy: cint;
  121. __schedparam: sched_param;
  122. __inheritsched: cint;
  123. __scope: cint;
  124. __guardsize: size_t;
  125. __stackaddr_set: cint;
  126. __stackaddr: pointer;
  127. __stacksize: size_t;
  128. end;
  129. _pthread_fastlock = record
  130. __status: clong;
  131. __spinlock: cint;
  132. end;
  133. pthread_mutex_t = record
  134. __m_reserved: cint;
  135. __m_count: cint;
  136. __m_owner: pointer;
  137. __m_kind: cint;
  138. __m_lock: _pthread_fastlock;
  139. end;
  140. pthread_mutexattr_t = record
  141. __mutexkind: cint;
  142. end;
  143. pthread_cond_t = record
  144. __c_lock: _pthread_fastlock;
  145. __c_waiting: pointer;
  146. __padding: array[0..48-1-sizeof(_pthread_fastlock)-sizeof(pointer)-sizeof(clonglong)] of byte;
  147. __align: clonglong;
  148. end;
  149. pthread_condattr_t = record
  150. __dummy: cint;
  151. end;
  152. pthread_key_t = cuint;
  153. pthread_rwlock_t = record
  154. __rw_readers: cint;
  155. __rw_writer: pointer;
  156. __rw_read_waiting: pointer;
  157. __rw_write_waiting: pointer;
  158. __rw_kind: cint;
  159. __rw_pshared: cint;
  160. end;
  161. pthread_rwlockattr_t = record
  162. __lockkind: cint;
  163. __pshared: cint;
  164. end;
  165. sem_t = record
  166. __sem_lock: _pthread_fastlock;
  167. __sem_value: cint;
  168. __sem_waiting: pointer;
  169. end;
  170. CONST
  171. _PTHREAD_MUTEX_TIMED_NP = 0;
  172. _PTHREAD_MUTEX_RECURSIVE_NP = 1;
  173. _PTHREAD_MUTEX_ERRORCHECK_NP = 2;
  174. _PTHREAD_MUTEX_ADAPTIVE_NP = 3;
  175. _PTHREAD_MUTEX_NORMAL = _PTHREAD_MUTEX_TIMED_NP;
  176. _PTHREAD_MUTEX_RECURSIVE = _PTHREAD_MUTEX_RECURSIVE_NP;
  177. _PTHREAD_MUTEX_ERRORCHECK = _PTHREAD_MUTEX_ERRORCHECK_NP;
  178. _PTHREAD_MUTEX_DEFAULT = _PTHREAD_MUTEX_NORMAL;
  179. _PTHREAD_MUTEX_FAST_NP = _PTHREAD_MUTEX_ADAPTIVE_NP;
  180. { System limits, POSIX value in parentheses, used for buffer and stack allocation }
  181. { took idefix' values}
  182. ARG_MAX = 131072; {4096} { Maximum number of argument size }
  183. NAME_MAX = 255; {14} { Maximum number of bytes in filename }
  184. PATH_MAX = 4095; {255} { Maximum number of bytes in pathname }
  185. SYS_NMLN = 65;
  186. {$ifdef FPC_USE_LIBC}
  187. SIG_MAXSIG = 1024; // highest signal version
  188. {$else}
  189. SIG_MAXSIG = 128; // highest signal version
  190. {$endif}
  191. { For getting/setting priority }
  192. Prio_Process = 0;
  193. Prio_PGrp = 1;
  194. Prio_User = 2;
  195. {
  196. $Log$
  197. Revision 1.12 2004-11-14 12:21:08 marco
  198. * moved some calls from unix to baseunix. Darwin untested.
  199. Revision 1.11 2004/09/09 20:29:06 jonas
  200. * fixed definition of pthread_mutex_t for non-linux targets (and for
  201. linux as well, actually).
  202. * base libpthread definitions are now in ptypes.inc, included in unixtype
  203. They sometimes have an extra underscore in front of their name, in
  204. case they were also exported by the packages/base/pthreads unit, so
  205. they can keep their original name there
  206. * cthreadds unit now imports systuils, because it uses exceptions (it
  207. already did so before as well)
  208. * fixed many linux definitions of libpthread functions in pthrlinux.inc
  209. (integer -> cint etc)
  210. + added culonglong type to ctype.inc
  211. Revision 1.10 2004/05/02 01:00:07 peter
  212. * statfs fixed
  213. Revision 1.9 2004/04/26 16:53:19 peter
  214. * use cpu64
  215. Revision 1.8 2004/03/04 22:15:16 marco
  216. * UnixType changes. Please report problems to me.
  217. Revision 1.7 2004/01/11 09:56:20 jonas
  218. * moved tstatfs from systypes.inc to ptypes.inc to fix make cycle with
  219. -dFPC_USE_LIBC (systypes.inc is now completely commented out)
  220. Revision 1.6 2003/12/30 12:46:40 marco
  221. * ptime_t
  222. Revision 1.5 2003/09/27 13:45:58 peter
  223. * fpnanosleep exported in baseunix
  224. * fpnanosleep has pointer arguments to be C compliant
  225. Revision 1.4 2003/09/14 20:15:01 marco
  226. * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
  227. Revision 1.3 2002/12/18 16:43:26 marco
  228. * new unix rtl, linux part.....
  229. Revision 1.2 2002/11/12 14:28:40 marco
  230. * some updates
  231. Revision 1.1 2002/10/29 16:47:17 marco
  232. * Linux versions
  233. }