ptypes.inc 6.4 KB

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