ptypes.inc 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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;
  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 = pointer;
  93. pthread_attr_t = pointer;
  94. pthread_mutex_t = {$i pmutext.inc}
  95. pthread_mutexattr_t = pointer;
  96. pthread_cond_t = pointer;
  97. pthread_condattr_t = pointer;
  98. pthread_key_t = cint;
  99. pthread_rwlock_t = pointer;
  100. pthread_rwlockattr_t = pointer;
  101. sem_t = pointer;
  102. rlim_t = int64;
  103. TRlim = rlim_t;
  104. {
  105. Mutex types (Single UNIX Specification, Version 2, 1997).
  106. Note that a mutex attribute with one of the following types:
  107. PTHREAD_MUTEX_NORMAL
  108. PTHREAD_MUTEX_RECURSIVE
  109. MUTEX_TYPE_FAST (deprecated)
  110. MUTEX_TYPE_COUNTING_FAST (deprecated)
  111. will deviate from POSIX specified semantics.
  112. }
  113. pthread_mutextype = (
  114. { Default POSIX mutex }
  115. _PTHREAD_MUTEX_ERRORCHECK := 1,
  116. { Recursive mutex }
  117. _PTHREAD_MUTEX_RECURSIVE := 2,
  118. { No error checking }
  119. _PTHREAD_MUTEX_NORMAL := 3,
  120. _MUTEX_TYPE_MAX
  121. );
  122. Const
  123. MNAMLEN = 88-2*sizeof(clong); // slightly machine specific.
  124. MFSNamLen = 16;
  125. type
  126. fsid_t = array[0..1] of cint;
  127. // Kernel statfs
  128. TStatfs = packed record
  129. spare2, { place holder}
  130. bsize, { fundamental block size}
  131. iosize, { optimal block size }
  132. blocks, { total blocks}
  133. bfree, { blocks free}
  134. bavail, { block available for mortal users}
  135. files, { Total file nodes}
  136. ffree : clong ; { file nodes free}
  137. fsid : fsid_t;
  138. fowner : tuid; {mounter uid}
  139. ftype : cint;
  140. fflags : cint; {copy of mount flags}
  141. fsyncwrites,
  142. fasyncwrites : clong;
  143. fstypename : array[0..MFSNamLen-1] of char;
  144. mountpoint : array[0..MNAMLEN-1] of char;
  145. fsyncreads, { count of sync reads since mount }
  146. fasyncreads : clong;
  147. fspares1 : cshort;
  148. mnfromname : array[0..MNAMLEN-1] of char;
  149. fspares2 : cshort;
  150. fspare3 : array[0..1] of clong;
  151. end;
  152. PStatFS=^TStatFS;
  153. mbstate_t = record
  154. case byte of
  155. 0: (__mbstate8: array[0..127] of char);
  156. 1: (_mbstateL: cint64); { for alignment }
  157. end;
  158. pmbstate_t = ^mbstate_t;
  159. ITimerVal= Record
  160. It_Interval,
  161. It_Value : TimeVal;
  162. end;
  163. const
  164. _PTHREAD_MUTEX_DEFAULT = _PTHREAD_MUTEX_ERRORCHECK;
  165. _MUTEX_TYPE_FAST = _PTHREAD_MUTEX_NORMAL;
  166. _MUTEX_TYPE_COUNTING_FAST = _PTHREAD_MUTEX_RECURSIVE;
  167. _PTHREAD_KEYS_MAX = 256;
  168. _PTHREAD_STACK_MIN = 1024;
  169. { System limits, POSIX value in parentheses, used for buffer and stack allocation }
  170. {$ifdef CPU64}
  171. ARG_MAX = 262144; {4096} { Maximum number of argument size }
  172. {$else}
  173. ARG_MAX = 65536; {4096} { Maximum number of argument size }
  174. {$endif}
  175. NAME_MAX = 255; {14} { Maximum number of bytes in filename }
  176. PATH_MAX = 1024; {255} { Maximum number of bytes in pathname }
  177. SYS_NMLN = 32; {BSD utsname struct limit, kernel mode}
  178. SIG_MAXSIG = 128; // highest signal version
  179. // wordsinsigset = 4; // words in sigset_t
  180. { For getting/setting priority }
  181. Prio_Process = 0;
  182. Prio_PGrp = 1;
  183. Prio_User = 2;