ptypes.inc 7.3 KB

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