ptypes.inc 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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 = cuint64; { 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. {$ifdef CPU64}
  42. size_t = cuint64;
  43. {$else}
  44. size_t = cuint32; { as definied in the C standard}
  45. {$endif}
  46. TSize = size_t;
  47. pSize = ^size_t;
  48. pSize_t = ^size_t;
  49. ssize_t = cint32; { used by function for returning number of bytes }
  50. TsSize = ssize_t;
  51. psSize = ^ssize_t;
  52. uid_t = cuint32; { used for user ID type }
  53. TUid = Uid_t;
  54. pUid = ^Uid_t;
  55. wint_t = cint32;
  56. wchar_t = cint32;
  57. pwchar_t = ^wchar_t;
  58. clock_t = cint64;
  59. TClock = clock_t;
  60. pClock = ^clock_t;
  61. time_t = cint64; { used for returning the time }
  62. // TTime = time_t; // Not allowed in system unit, -> unixtype
  63. pTime = ^time_t;
  64. ptime_t = ^time_t;
  65. socklen_t= cuint32;
  66. TSocklen = socklen_t;
  67. pSocklen = ^socklen_t;
  68. timeval = packed record
  69. tv_sec : time_t;
  70. tv_usec : clong;
  71. end;
  72. ptimeval= ^timeval;
  73. TTimeval= timeval;
  74. timespec = packed record
  75. tv_sec : time_t;
  76. tv_nsec : clong;
  77. end;
  78. ptimespec= ^timespec;
  79. Ttimespec= timespec;
  80. pthread_t_rec = record end;
  81. pthread_attr_t_rec = record end;
  82. // See pmutext.inc
  83. // pthread_mutex_t_rec = record end;
  84. pthread_mutexattr_t_rec = record end;
  85. pthread_cond_t_rec = record end;
  86. pthread_condattr_t_rec = record end;
  87. pthread_once_t_rec = record end;
  88. pthread_rwlock_t_rec = record end;
  89. pthread_rwlockattr_t_rec = record end;
  90. pthread_t = ^pthread_t_rec;
  91. pthread_attr_t = ^pthread_attr_t_rec;
  92. pthread_mutex_t = {$i pmutext.inc}
  93. pthread_mutexattr_t = ^pthread_mutexattr_t_rec;
  94. pthread_cond_t = ^pthread_cond_t_rec;
  95. pthread_condattr_t = ^pthread_condattr_t_rec;
  96. pthread_key_t = cint;
  97. pthread_once_t = ^pthread_once_t_rec;
  98. pthread_rwlock_t = ^pthread_rwlock_t_rec;
  99. pthread_rwlockattr_t = ^pthread_rwlockattr_t_rec;
  100. sem_t = pointer;
  101. rlim_t = int64;
  102. TRlim = rlim_t;
  103. {
  104. Mutex types (Single UNIX Specification, Version 2, 1997).
  105. Note that a mutex attribute with one of the following types:
  106. PTHREAD_MUTEX_NORMAL
  107. PTHREAD_MUTEX_RECURSIVE
  108. MUTEX_TYPE_FAST (deprecated)
  109. MUTEX_TYPE_COUNTING_FAST (deprecated)
  110. will deviate from POSIX specified semantics.
  111. }
  112. pthread_mutextype = (
  113. { Default POSIX mutex }
  114. _PTHREAD_MUTEX_ERRORCHECK := 1,
  115. { Recursive mutex }
  116. _PTHREAD_MUTEX_RECURSIVE := 2,
  117. { No error checking }
  118. _PTHREAD_MUTEX_NORMAL := 3,
  119. _MUTEX_TYPE_MAX
  120. );
  121. Const
  122. MNAMLEN = 90; // length of buffer for returned name
  123. MFSNamLen = 16; // length of fs type name, including nul
  124. type
  125. fsid_t = array[0..1] of cint;
  126. ufs_args_rec = record end;
  127. mfs_args_rec = record end;
  128. nfs_args_rec = record end;
  129. isofs_args_rec = record end;
  130. procfs_args_rec = record end;
  131. msdosfs_args_rec = record end;
  132. ntfs_args_rec = record end;
  133. mountinfo = record
  134. case byte of
  135. 0: (ufs_args: ^ufs_args_rec);
  136. 1: (mfs_args: ^mfs_args_rec);
  137. 2: (nfs_args: ^nfs_args_rec);
  138. 3: (isofs_args: ^isofs_args_rec);
  139. 4: (procfs_args: ^procfs_args_rec);
  140. 5: (msdosfs_args: ^msdosfs_args_rec);
  141. 6: (ntfs_args: ^ntfs_args_rec);
  142. 7: (__align: array[0..159] of char); { 64-bit alignment and room to grow }
  143. end;
  144. // kernel statfs from mount.h
  145. TStatfs = record
  146. flags, { copy of mount flags }
  147. bsize, { filesystem block size}
  148. iosize : cint; { optimal transfr block size }
  149. blocks, { total data block in file system }
  150. bfree : cuint64; { blocks free in fs }
  151. bavail : cint64; { block available for non-superuser }
  152. files, { total file nodes in file system }
  153. ffree : cuint64; { free files nodes in fs }
  154. favail : cint64; { free file nodes avail to non-root }
  155. fsyncwrites, { count of sync writes since mount }
  156. fasyncwrites, { count of async writes since mount }
  157. fsyncreads, { count of sync reads since mount }
  158. fasyncreads : cuint64; { count of async reads since mount }
  159. fsid : fsid_t; { file system id }
  160. namemax : cint; { maximum fileystem length }
  161. fowner : tuid; { user that mounted the fileystem }
  162. ctime : cint; { last mount [-u] time }
  163. fspare3 : array[0..2] of cint; { spare for later }
  164. fstypename : array[0..MFSNamLen-1] of char; { fs type name }
  165. mountpoint : array[0..MNAMLEN-1] of char; { directory on which mounted}
  166. mnfromname : array[0..MNAMLEN-1] of char; { mounted file system }
  167. mount_info : mountinfo; { per-filesystem mount options }
  168. end;
  169. PStatFS=^TStatFS;
  170. mbstate_t = record
  171. case byte of
  172. 0: (__mbstate8: array[0..127] of char);
  173. 1: (_mbstateL: cint64); { for alignment }
  174. end;
  175. pmbstate_t = ^mbstate_t;
  176. ITimerVal= Record
  177. It_Interval,
  178. It_Value : TimeVal;
  179. end;
  180. const
  181. _PTHREAD_MUTEX_DEFAULT = _PTHREAD_MUTEX_ERRORCHECK;
  182. _MUTEX_TYPE_FAST = _PTHREAD_MUTEX_NORMAL;
  183. _MUTEX_TYPE_COUNTING_FAST = _PTHREAD_MUTEX_RECURSIVE;
  184. _PTHREAD_KEYS_MAX = 256;
  185. _PTHREAD_STACK_MIN = 1024;
  186. { System limits, POSIX value in parentheses, used for buffer and stack allocation }
  187. ARG_MAX = 256*1024; {4096} { Maximum number of argument size }
  188. NAME_MAX = 255; {14} { Maximum number of bytes in filename }
  189. PATH_MAX = 1024; {255} { Maximum number of bytes in pathname }
  190. SYS_NMLN = 256; {BSD utsname struct limit}
  191. SIG_MAXSIG = 33; // highest signal version
  192. // set in ostypes.inc wordsinsigset = 4; // words in sigset_t
  193. { For getting/setting priority }
  194. Prio_Process = 0;
  195. Prio_PGrp = 1;
  196. Prio_User = 2;
  197. { OpenBSD 5.5 specific variants }
  198. { file characteristics services }
  199. type
  200. stat_55 = record { the types are real}
  201. st_mode : mode_t; // inode protection mode
  202. st_dev : dev_t; // inode's device
  203. st_ino : ino_t; // inode's number
  204. st_nlink : nlink_t; // number of hard links
  205. st_uid : uid_t; // user ID of the file's owner
  206. st_gid : gid_t; // group ID of the file's group
  207. st_rdev : dev_t; // device type
  208. st_atime : time_t; // time of last access
  209. st_atimensec : clong; // nsec of last access
  210. st_mtime : time_t; // time of last data modification
  211. st_mtimensec : clong; // nsec of last data modification
  212. st_ctime : time_t; // time of last file status change
  213. st_ctimensec : clong; // nsec of last file status change
  214. st_size : off_t; // file size, in bytes
  215. st_blocks : cint64; // blocks allocated for file
  216. st_blksize : cuint32; // optimal blocksize for I/O
  217. st_flags : cuint32; // user defined flags for file
  218. st_gen : cuint32; // file generation number
  219. st_birthtime : time_t; // File creation time
  220. st_birthtimensec : clong; // nsec of file creation time
  221. st_qspare : array[0..1] Of cint64;
  222. end;
  223. TStat_55 = stat_55;
  224. pStat_55 = ^stat_55;
  225. { directory services }
  226. dirent_55 = record
  227. d_fileno : ino_t;
  228. d_off : off_t;
  229. d_reclen : cuint16; // length of this record
  230. d_type : cuint8; // file type, see below
  231. d_namlen : cuint8; // length of string in d_name
  232. d_padding : array[1..4] of cuint8;
  233. d_name : array[0..(255 + 1)-1] of char; // name must be no longer than this
  234. end;
  235. TDirent_55 = dirent_55;
  236. pDirent_55 = ^dirent_55;
  237. dir_55 = record
  238. dd_fd : cint; // file descriptor associated with directory
  239. dd_loc : clong; // offset in current buffer
  240. dd_size : clong; // amount of data returned by getdirentries
  241. dd_buf : pchar; // data buffer
  242. dd_len : cint; // size of data buffer
  243. dd_curpos : off_t;
  244. dd_lock : pointer;
  245. dd_rewind : clong;
  246. end;
  247. TDir_55 = dir_55;
  248. pDir_55 = ^dir_55;