ptypes.inc 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2001,2010 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. ino_t = clong; { used for file serial numbers }
  27. TIno = ino_t;
  28. pIno = ^ino_t;
  29. mode_t = cuint32; { used for file attributes }
  30. TMode = mode_t;
  31. pMode = ^mode_t;
  32. nlink_t = cuint32; { used for link counts }
  33. TnLink = nlink_t;
  34. pnLink = ^nlink_t;
  35. off_t = cint64; { used for file sizes }
  36. TOff = off_t;
  37. pOff = ^off_t;
  38. pid_t = cint32; { used as process identifier }
  39. TPid = pid_t;
  40. pPid = ^pid_t;
  41. size_t = cuint32; { as definied in the C standard}
  42. TSize = size_t;
  43. pSize = ^size_t;
  44. ssize_t = cint32; { used by function for returning number of bytes }
  45. TsSize = ssize_t;
  46. psSize = ^ssize_t;
  47. uid_t = cuint32; { used for user ID type }
  48. TUid = Uid_t;
  49. pUid = ^Uid_t;
  50. wint_t = cint32;
  51. wchar_t = cint32;
  52. pwchar_t = ^wchar_t;
  53. clock_t = culong;
  54. TClock = clock_t;
  55. pClock = ^clock_t;
  56. time_t = clong; { used for returning the time }
  57. // TTime = time_t; // Not allowed in system unit, -> unixtype
  58. pTime = ^time_t;
  59. ptime_t = ^time_t;
  60. socklen_t= cuint32;
  61. TSocklen = socklen_t;
  62. pSocklen = ^socklen_t;
  63. timeval = packed record
  64. tv_sec,
  65. tv_usec : clong;
  66. end;
  67. ptimeval= ^timeval;
  68. TTimeval= timeval;
  69. timespec = packed record
  70. tv_sec : time_t;
  71. tv_nsec : clong;
  72. end;
  73. ptimespec= ^timespec;
  74. Ttimespec= timespec;
  75. pthread_t_rec = record end;
  76. pthread_attr_t_rec = record end;
  77. // See pmutext.inc
  78. // pthread_mutex_t_rec = record end;
  79. pthread_mutexattr_t_rec = record end;
  80. pthread_cond_t_rec = record end;
  81. pthread_condattr_t_rec = record end;
  82. pthread_once_t_rec = record end;
  83. pthread_rwlock_t_rec = record end;
  84. pthread_rwlockattr_t_rec = record end;
  85. pthread_t = ^pthread_t_rec;
  86. pthread_attr_t = ^pthread_attr_t_rec;
  87. pthread_mutex_t = {$i pmutext.inc}
  88. pthread_mutexattr_t = ^pthread_mutexattr_t_rec;
  89. pthread_cond_t = ^pthread_cond_t_rec;
  90. pthread_condattr_t = ^pthread_condattr_t_rec;
  91. pthread_key_t = cint;
  92. pthread_once_t = ^pthread_once_t_rec;
  93. pthread_rwlock_t = ^pthread_rwlock_t_rec;
  94. pthread_rwlockattr_t = ^pthread_rwlockattr_t_rec;
  95. sem_t = pointer;
  96. rlim_t = int64;
  97. TRlim = rlim_t;
  98. {
  99. Mutex types (Single UNIX Specification, Version 2, 1997).
  100. Note that a mutex attribute with one of the following types:
  101. PTHREAD_MUTEX_NORMAL
  102. PTHREAD_MUTEX_RECURSIVE
  103. MUTEX_TYPE_FAST (deprecated)
  104. MUTEX_TYPE_COUNTING_FAST (deprecated)
  105. will deviate from POSIX specified semantics.
  106. }
  107. pthread_mutextype = (
  108. { Default POSIX mutex }
  109. _PTHREAD_MUTEX_ERRORCHECK := 1,
  110. { Recursive mutex }
  111. _PTHREAD_MUTEX_RECURSIVE := 2,
  112. { No error checking }
  113. _PTHREAD_MUTEX_NORMAL := 3,
  114. _MUTEX_TYPE_MAX
  115. );
  116. Const
  117. MNAMLEN = 90; // length of buffer for returned name
  118. MFSNamLen = 16; // length of fs type name, including nul
  119. type
  120. fsid_t = array[0..1] of cint;
  121. ufs_args_rec = record end;
  122. mfs_args_rec = record end;
  123. nfs_args_rec = record end;
  124. iso_args_rec = record end;
  125. procfs_args_rec = record end;
  126. msdosfs_args_rec = record end;
  127. ntfs_args_rec = record end;
  128. mountinfo = record
  129. case byte of
  130. 0: (ufs_args: ^ufs_args_rec);
  131. 1: (mfs_args: ^mfs_args_rec);
  132. 2: (ntfs_args: ^nfsfs_args_rec);
  133. 3: (isofs_args: ^isofs_args_rec);
  134. 4: (procfs_args: ^procfs_args_rec);
  135. 5: (msdosfs_args: ^msdosfs_args_rec);
  136. 6: (ntfs_args: ^ntfs_args_rec);
  137. 7: (__align: array[0..159] of char { 64-bit alignment and room to grow }
  138. end;
  139. // kernel statfs from mount.h
  140. TStatfs = packed record
  141. flags, { copy of mount flags }
  142. bsize, { filesystem block size}
  143. iosize : cint; { optimal transfr block size }
  144. blocks, { total data block in file system }
  145. bfree : clong; { blocks free in fs }
  146. bavail : cint64; { block available for non-superuser }
  147. files, { total file nodes in file system }
  148. ffree : clong; { free files nodes in fs }
  149. favail : cint64; { free file nodes avail to non-root }
  150. fsyncwrites, { count of sync writes since mount }
  151. fasyncwrites, { count of async writes since mount }
  152. fsyncreads, { count of sync reads since mount }
  153. fasyncreads : clong; { count of async reads since mount }
  154. fsid : fsid_t; { file system id }
  155. namemax : cint; { maximum fileystem length }
  156. fowner : tuid; { user that mounted the fileystem }
  157. ctime : cint; { last mount [-u] time }
  158. fspare3 : array[0..2] of cint; { spare for later }
  159. fstypename : array[0..MFSNamLen-1] of char; { fs type name }
  160. mountpoint : array[0..MNAMLEN-1] of char; { directory on which mounted}
  161. mnfromname : array[0..MNAMLEN-1] of char; { mounted file system }
  162. mount_info : mountinfo; { per-filesystem mount options }
  163. end;
  164. PStatFS=^TStatFS;
  165. mbstate_t = record
  166. case byte of
  167. 0: (__mbstate8: array[0..127] of char);
  168. 1: (_mbstateL: cint64); { for alignment }
  169. end;
  170. pmbstate_t = ^mbstate_t;
  171. ITimerVal= Record
  172. It_Interval,
  173. It_Value : TimeVal;
  174. end;
  175. const
  176. _PTHREAD_MUTEX_DEFAULT = _PTHREAD_MUTEX_ERRORCHECK;
  177. _MUTEX_TYPE_FAST = _PTHREAD_MUTEX_NORMAL;
  178. _MUTEX_TYPE_COUNTING_FAST = _PTHREAD_MUTEX_RECURSIVE;
  179. _PTHREAD_KEYS_MAX = 256;
  180. _PTHREAD_STACK_MIN = 1024;
  181. { System limits, POSIX value in parentheses, used for buffer and stack allocation }
  182. ARG_MAX = 256*1024; {4096} { Maximum number of argument size }
  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 = 256; {BSD utsname struct limit}
  186. SIG_MAXSIG = 33; // 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;