ptypes.inc 7.3 KB

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