ptypes.inc 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. dev_t = cuint32; { used for device numbers }
  20. TDev = dev_t;
  21. pDev = ^dev_t;
  22. gid_t = cuint32; { used for group IDs }
  23. TGid = gid_t;
  24. pGid = ^gid_t;
  25. TIOCtlRequest = cuLong;
  26. {$ifdef CPU64}
  27. ino_t = cuint32; { used for file serial numbers }
  28. {$else}
  29. ino_t = clong; { used for file serial numbers }
  30. {$endif}
  31. TIno = ino_t;
  32. pIno = ^ino_t;
  33. mode_t = cuint16; { used for file attributes }
  34. TMode = mode_t;
  35. pMode = ^mode_t;
  36. nlink_t = cuint16; { used for link counts }
  37. TnLink = nlink_t;
  38. pnLink = ^nlink_t;
  39. off_t = cint64; { used for file sizes }
  40. TOff = off_t;
  41. pOff = ^off_t;
  42. pid_t = cint32; { used as process identifier }
  43. TPid = pid_t;
  44. pPid = ^pid_t;
  45. {$ifdef CPU64}
  46. size_t = cuint64;
  47. {$else}
  48. size_t = cuint32; { as definied in the C standard}
  49. {$endif}
  50. TSize = size_t;
  51. pSize = ^size_t;
  52. pSize_t = ^size_t;
  53. {$ifdef CPU64}
  54. ssize_t = cint64; { used by function for returning number of bytes }
  55. {$else}
  56. ssize_t = cint32; { used by function for returning number of bytes}
  57. {$endif}
  58. TsSize = ssize_t;
  59. psSize = ^ssize_t;
  60. uid_t = cuint32; { used for user ID type }
  61. TUid = Uid_t;
  62. pUid = ^Uid_t;
  63. wint_t = cint32;
  64. wchar_t = cint32;
  65. pwchar_t = ^wchar_t;
  66. {$ifdef CPU64}
  67. clock_t = cuint32; // 32-bit even on Athlon64
  68. {$else}
  69. clock_t = culong;
  70. {$endif}
  71. TClock = clock_t;
  72. pClock = ^clock_t;
  73. time_t = clong; { used for returning the time, clong
  74. is 64-bit on AMD64}
  75. // TTime = time_t; // Not allowed in system unit, -> unixtype
  76. pTime = ^time_t;
  77. ptime_t = ^time_t;
  78. socklen_t= cuint32;
  79. TSocklen = socklen_t;
  80. pSocklen = ^socklen_t;
  81. timeval = packed record
  82. tv_sec,tv_usec:clong;
  83. end;
  84. ptimeval = ^timeval;
  85. TTimeVal = timeval;
  86. timespec = packed record
  87. tv_sec : time_t; // should be time_t, bug compability
  88. tv_nsec : clong;
  89. end;
  90. ptimespec= ^timespec;
  91. Ttimespec= timespec;
  92. pthread_t_rec = record end;
  93. pthread_attr_t_rec = record end;
  94. // pthread_mutex_t_rec = record end;
  95. pthread_mutexattr_t_rec = record end;
  96. pthread_cond_t_rec = record end;
  97. pthread_condattr_t_rec = record end;
  98. pthread_rwlock_t_rec = record end;
  99. pthread_rwlockattr_t_rec = record end;
  100. pthread_t = ^pthread_t_rec;
  101. pthread_attr_t = ^pthread_attr_t_rec;
  102. pthread_mutex_t = {$i pmutext.inc}
  103. pthread_mutexattr_t = ^pthread_mutexattr_t_rec;
  104. pthread_cond_t = ^pthread_cond_t_rec;
  105. pthread_condattr_t = ^pthread_condattr_t_rec;
  106. pthread_key_t = cint;
  107. pthread_rwlock_t = ^pthread_rwlock_t_rec;
  108. pthread_rwlockattr_t = ^pthread_rwlock_t_rec;
  109. sem_t = pointer;
  110. rlim_t = int64;
  111. TRlim = rlim_t;
  112. {
  113. Mutex types (Single UNIX Specification, Version 2, 1997).
  114. Note that a mutex attribute with one of the following types:
  115. PTHREAD_MUTEX_NORMAL
  116. PTHREAD_MUTEX_RECURSIVE
  117. MUTEX_TYPE_FAST (deprecated)
  118. MUTEX_TYPE_COUNTING_FAST (deprecated)
  119. will deviate from POSIX specified semantics.
  120. }
  121. pthread_mutextype = (
  122. { Default POSIX mutex }
  123. _PTHREAD_MUTEX_ERRORCHECK := 1,
  124. { Recursive mutex }
  125. _PTHREAD_MUTEX_RECURSIVE := 2,
  126. { No error checking }
  127. _PTHREAD_MUTEX_NORMAL := 3,
  128. _MUTEX_TYPE_MAX
  129. );
  130. Const
  131. MNAMLEN = 88-2*sizeof(clong); // slightly machine specific.
  132. MFSNamLen = 16;
  133. type
  134. fsid_t = array[0..1] of cint;
  135. // Kernel statfs
  136. TStatfs = packed record
  137. spare2, { place holder}
  138. bsize, { fundamental block size}
  139. iosize, { optimal block size }
  140. blocks, { total blocks}
  141. bfree, { blocks free}
  142. bavail, { block available for mortal users}
  143. files, { Total file nodes}
  144. ffree : clong ; { file nodes free}
  145. fsid : fsid_t;
  146. fowner : tuid; {mounter uid}
  147. ftype : cint;
  148. fflags : cint; {copy of mount flags}
  149. fsyncwrites,
  150. fasyncwrites : clong;
  151. fstypename : array[0..MFSNamLen-1] of char;
  152. mountpoint : array[0..MNAMLEN-1] of char;
  153. fsyncreads, { count of sync reads since mount }
  154. fasyncreads : clong;
  155. fspares1 : cshort;
  156. mnfromname : array[0..MNAMLEN-1] of char;
  157. fspares2 : cshort;
  158. fspare3 : array[0..1] of clong;
  159. end;
  160. PStatFS=^TStatFS;
  161. mbstate_t = record
  162. case byte of
  163. 0: (__mbstate8: array[0..127] of char);
  164. 1: (_mbstateL: cint64); { for alignment }
  165. end;
  166. pmbstate_t = ^mbstate_t;
  167. ITimerVal= Record
  168. It_Interval,
  169. It_Value : TimeVal;
  170. end;
  171. const
  172. _PTHREAD_MUTEX_DEFAULT = _PTHREAD_MUTEX_ERRORCHECK;
  173. _MUTEX_TYPE_FAST = _PTHREAD_MUTEX_NORMAL;
  174. _MUTEX_TYPE_COUNTING_FAST = _PTHREAD_MUTEX_RECURSIVE;
  175. _PTHREAD_KEYS_MAX = 256;
  176. _PTHREAD_STACK_MIN = 1024;
  177. { System limits, POSIX value in parentheses, used for buffer and stack allocation }
  178. {$ifdef CPU64}
  179. ARG_MAX = 262144; {4096} { Maximum number of argument size }
  180. {$else}
  181. ARG_MAX = 65536; {4096} { Maximum number of argument size }
  182. {$endif}
  183. NAME_MAX = 255; {14} { Maximum number of bytes in filename }
  184. PATH_MAX = 1024; {255} { Maximum number of bytes in pathname }
  185. SYS_NMLN = 32; {BSD utsname struct limit, kernel mode}
  186. SIG_MAXSIG = 128; // highest signal version
  187. // wordsinsigset = 4; // words in sigset_t
  188. { For getting/setting priority }
  189. Prio_Process = 0;
  190. Prio_PGrp = 1;
  191. Prio_User = 2;