ptypes.inc 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. {$i ctypes.inc}
  17. {$packrecords c}
  18. {$if defined(darwin) and (defined(cpuarm) or defined(cpuaarch64) or defined(iphonesim) or (defined(MAC_OS_X_VERSION_MIN_REQUIRED) and (MAC_OS_X_VERSION_MIN_REQUIRED >= 1060)))}
  19. {$define darwin_new_iostructs}
  20. {$endif}
  21. type
  22. { the following type definitions are compiler dependant }
  23. { and system dependant }
  24. dev_t = cuint32; { used for device numbers }
  25. TDev = dev_t;
  26. pDev = ^dev_t;
  27. gid_t = cuint32; { used for group IDs }
  28. TGid = gid_t;
  29. pGid = ^gid_t;
  30. TIOCtlRequest = cuLong;
  31. {$ifdef darwin_new_iostructs}
  32. ino_t = cuint64;
  33. {$else}
  34. ino_t = cuint32; { used for file serial numbers }
  35. {$endif}
  36. TIno = ino_t;
  37. pIno = ^ino_t;
  38. mode_t = cuint16; { used for file attributes }
  39. TMode = mode_t;
  40. pMode = ^mode_t;
  41. nlink_t = cuint16; { used for link counts }
  42. TnLink = nlink_t;
  43. pnLink = ^nlink_t;
  44. off_t = cint64; { used for file sizes }
  45. TOff = off_t;
  46. pOff = ^off_t;
  47. pid_t = cint32; { used as process identifier }
  48. TPid = pid_t;
  49. pPid = ^pid_t;
  50. size_t = culong; { as definied in the C standard}
  51. TSize = size_t;
  52. pSize = ^size_t;
  53. psize_t = ^size_t;
  54. ssize_t = clong; { used by function for returning number of bytes }
  55. TsSize = ssize_t;
  56. psSize = ^ssize_t;
  57. uid_t = cuint32; { used for user ID type }
  58. TUid = Uid_t;
  59. pUid = ^Uid_t;
  60. clock_t = culong;
  61. TClock = clock_t;
  62. pClock = ^clock_t;
  63. time_t = clong; { used for returning the time }
  64. // TTime = time_t; // Not allowed in system unit, -> unixtype
  65. pTime = ^time_t;
  66. ptime_t = ^time_t;
  67. wchar_t = cint32;
  68. pwchar_t = ^wchar_t;
  69. wint_t = cint32;
  70. socklen_t= cuint32;
  71. TSocklen = socklen_t;
  72. pSocklen = ^socklen_t;
  73. suseconds_t = cint32;
  74. timeval = record
  75. tv_sec: time_t;
  76. tv_usec: suseconds_t;
  77. end;
  78. ptimeval = ^timeval;
  79. TTimeVal = timeval;
  80. timespec = record
  81. tv_sec : time_t;
  82. tv_nsec : clong;
  83. end;
  84. ptimespec= ^timespec;
  85. Ttimespec= timespec;
  86. rlim_t = int64;
  87. TRlim = rlim_t;
  88. CONST
  89. { System limits, POSIX value in parentheses, used for buffer and stack allocation }
  90. ARG_MAX = 65536; {4096} { Maximum number of argument size }
  91. NAME_MAX = 255; {14} { Maximum number of bytes in filename }
  92. PATH_MAX = 1024; {255} { Maximum number of bytes in pathname }
  93. SYS_NMLN = 256; {BSD utsname struct limit}
  94. SIG_MAXSIG = 32; // highest signal version
  95. MFSTYPENAMELEN = 16;
  96. MFSNAMELEN = 15;
  97. MNAMELEN = 90;
  98. type
  99. pthread_mutextype = (
  100. _PTHREAD_MUTEX_NORMAL := 0,
  101. _PTHREAD_MUTEX_ERRORCHECK := 1,
  102. _PTHREAD_MUTEX_RECURSIVE := 2
  103. );
  104. const
  105. _PTHREAD_MUTEX_DEFAULT = _PTHREAD_MUTEX_NORMAL;
  106. _MUTEX_TYPE_FAST = _PTHREAD_MUTEX_NORMAL;
  107. _MUTEX_TYPE_COUNTING_FAST = _PTHREAD_MUTEX_RECURSIVE;
  108. _PTHREAD_KEYS_MAX = 128;
  109. _PTHREAD_STACK_MIN = 8192;
  110. type
  111. fsid_t = record
  112. val: array[0..1] of cint32;
  113. end;
  114. {$if defined(cpuarm) or defined(cpuaarch64) or defined(iphonesim)}
  115. { structure used on iPhoneOS and available on Mac OS X 10.6 and later }
  116. tstatfs = record
  117. bsize : cuint32;
  118. iosize : cint32;
  119. blocks : cuint64;
  120. bfree : cuint64;
  121. bavail : cuint64;
  122. files : cuint64;
  123. ffree : cuint64;
  124. fsid : fsid_t;
  125. owner : uid_t;
  126. ftype : cuint32;
  127. fflags : cuint32;
  128. fssubtype : cuint32;
  129. fstypename : array[0..(MFSTYPENAMELEN)-1] of AnsiChar;
  130. mountpoint : array[0..(PATH_MAX)-1] of AnsiChar;
  131. mntfromname : array[0..(PATH_MAX)-1] of AnsiChar;
  132. reserved: array[0..7] of cuint32;
  133. end;
  134. {$else}
  135. tstatfs = record
  136. otype : cint16;
  137. oflags : cint16;
  138. bsize : clong;
  139. iosize : clong;
  140. blocks : clong;
  141. bfree : clong;
  142. bavail : clong;
  143. files : clong;
  144. ffree : clong;
  145. fsid : fsid_t;
  146. fowner : uid_t;
  147. reserved1 : cint16;
  148. ftype : cint16;
  149. fflags : clong;
  150. reserved2 : array[0..1] of clong;
  151. fstypename : array[0..(MFSNAMELEN)-1] of AnsiChar;
  152. mountpoint : array[0..(MNAMELEN)-1] of AnsiChar;
  153. mntfromname : array[0..(MNAMELEN)-1] of AnsiChar;
  154. f_reserved3: AnsiChar;
  155. reserved4: array[0..3] of clong;
  156. end;
  157. {$endif}
  158. pstatfs = ^tstatfs;
  159. mbstate_t = record
  160. case byte of
  161. 0: (__mbstate8: array[0..127] of AnsiChar);
  162. 1: (_mbstateL: clonglong); { for alignment }
  163. end;
  164. pmbstate_t = ^mbstate_t;
  165. pthread_t = pointer;
  166. pthread_attr_t = record sig: clong; opaque: array[0..{$ifdef cpu64}56{$else}36{$endif}-1] of byte; end;
  167. pthread_mutex_t = {$i pmutext.inc}
  168. pthread_mutexattr_t = record sig: clong; opaque: array[0..8-1] of byte; end;
  169. pthread_cond_t = record sig: clong; opaque: array[0..{$ifdef cpu64}40{$else}24{$endif}-1] of byte; end;
  170. pthread_condattr_t = record sig: clong; opaque: array[0..{$ifdef cpu64}8{$else}4{$endif}-1] of byte; end;
  171. pthread_key_t = culong;
  172. pthread_rwlock_t = record sig: clong; opaque: array[0..{$ifdef cpu64}192{$else}124{$endif}-1] of byte; end;
  173. pthread_rwlockattr_t = record sig: clong; opaque: array[0..{$ifdef cpu64}16{$else}12{$endif}-1] of byte; end;
  174. sem_t = cint;
  175. // for get/setpriority
  176. Const
  177. { For getting/setting priority }
  178. Prio_Process = 0;
  179. Prio_PGrp = 1;
  180. Prio_User = 2;