ostypes.inc 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2001 by Free Pascal development team
  4. Types and structures for the BaseUnix unit.
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. ***********************************************************************}
  11. {***********************************************************************}
  12. { Base Unix Structures }
  13. {***********************************************************************}
  14. {$IFDEF FPC_IS_SYSTEM}
  15. {$i ptypes.inc}
  16. {$ENDIF}
  17. { note: all constants/types are taken from the case that the headers are parsed
  18. with:
  19. -D_LARGE_FILES
  20. -U_POSIX_SOURCE
  21. -U_ANSI_C_SOURCE
  22. }
  23. CONST
  24. FD_MAXFDSET = 65534;
  25. BITSINWORD = 8*sizeof(clong);
  26. wordsinsigset = (SIG_MAXSIG+1+BITSINWORD-1) DIV BITSINWORD; // words in sigset_t
  27. wordsinfdset = (FD_MAXFDSET+1+BITSINWORD-1) DIV BITSINWORD; // words in fdset_t
  28. {$ifdef cpu64}
  29. ln2bitsinword = 6; { 64bit : ln(64)/ln(2)=5 }
  30. {$else}
  31. ln2bitsinword = 5; { 32bit : ln(32)/ln(2)=5 }
  32. {$endif}
  33. ln2bitmask = 1 shl ln2bitsinword - 1;
  34. UTSNAME_LENGTH = 31;
  35. UTSNAME_NODENAME_LENGTH = 31;
  36. TYPE
  37. blksize_t = {$ifdef cpu64}clong{$else}cint{$endif};
  38. blkcnt_t = {$ifdef cpu64}clong{$else}cint{$endif};
  39. { file characteristics services }
  40. stat = record
  41. st_dev : dev_t;
  42. st_ino : ino_t;
  43. st_mode : mode_t;
  44. st_nlink : nlink_t;
  45. st_flag : cushort;
  46. st_uid : uid_t;
  47. st_gid : gid_t;
  48. st_rdev : dev_t;
  49. st_ssize : cint;
  50. st_atime : time_t;
  51. st_atimens : cint; { access time nanosecond field }
  52. st_mtime : time_t;
  53. st_mtimens : cint; { modification time nanosecond field }
  54. st_ctime : time_t;
  55. st_ctimens : cint; { modification time nanosecond field }
  56. st_blksize : blksize_t;
  57. st_blocks : blkcnt_t;
  58. st_vfstype: cint; { Type of fs (see vnode.h) }
  59. st_vfs : cuint; { Vfs number }
  60. st_type : cuint; { Vnode type }
  61. st_gen : cuint; { Inode generation number }
  62. st_reserved : array [0..9] of cuint;
  63. st_size : off_t; { 64 bit file size in bytes }
  64. end;
  65. TStat = Stat;
  66. PStat = ^Stat;
  67. flock = record
  68. l_type : cshort; { lock type: read/write, etc. }
  69. l_whence: cshort; { type of l_start }
  70. l_sysid : cuint;
  71. l_pid : pid_t; { lock owner }
  72. l_vfs : cint;
  73. l_start : off_t;
  74. l_len : off_t;
  75. end;
  76. TFlock = flock;
  77. pFlock = ^flock;
  78. TFDSetEl = culong;
  79. TFDSet = array[0..wordsinfdset-1] of TFDSetEl;
  80. pFDSet = ^TFDSet;
  81. timezone = record
  82. tz_minuteswest,tz_dsttime:cint;
  83. end;
  84. ptimezone =^timezone;
  85. TTimeZone = timezone;
  86. { system information services }
  87. utsname = record
  88. sysname : array[0..UTSNAME_LENGTH] of AnsiChar;
  89. nodename : array[0..UTSNAME_LENGTH] of AnsiChar;
  90. release : array[0..UTSNAME_LENGTH] of AnsiChar;
  91. version : array[0..UTSNAME_LENGTH] of AnsiChar;
  92. machine : array[0..UTSNAME_LENGTH] of AnsiChar;
  93. end;
  94. UTimBuf = Record
  95. actime : time_t;
  96. modtime : time_t;
  97. end;
  98. TUtimBuf = UtimBuf;
  99. pUtimBuf = ^UtimBuf;
  100. { directory services }
  101. pdirent = ^dirent;
  102. { actually dirent64 }
  103. dirent = record { directory entry record }
  104. case integer of
  105. 1 : (
  106. d_off : cuint64; {* offset of disk directory entry *}
  107. d_ino : ino64_t; {* "inode number" of entry *}
  108. d_reclen : cushort; {* length of this record *}
  109. d_namelen : cushort;
  110. d_name : array[0..255] of AnsiChar; { name of file }
  111. );
  112. { overlay with alias }
  113. 2 : (
  114. dummy : cuint64;
  115. d_fileno : ino64_t;
  116. );
  117. end;
  118. pdir = ^dir;
  119. dir = record
  120. case integer of
  121. 1 : (
  122. d_fd : cint; {* file descriptor *}
  123. d_loc : cint; {* offset in block *}
  124. d_size : cint; {* amount of valid data *}
  125. d_buf : PAnsiChar; { directory block }
  126. );
  127. { overlay for posix compatibility }
  128. 2 : (
  129. dd_fd : cint; {* file descriptor *}
  130. dd_loc : cint; {* offset in block *}
  131. dd_size : cint; {* amount of valid data *}
  132. dd_buf : PAnsiChar; { directory block }
  133. );
  134. end;
  135. {***********************************************************************}
  136. { POSIX CONSTANT ROUTINE DEFINITIONS }
  137. {***********************************************************************}
  138. CONST
  139. { access routine - these maybe OR'ed together }
  140. F_OK = 0; { test for existence of file }
  141. R_OK = 4; { test for read permission on file }
  142. W_OK = 2; { test for write permission on file }
  143. X_OK = 1; { test for execute or search permission }
  144. { seek routine }
  145. SEEK_SET = 0; { seek from beginning of file }
  146. SEEK_CUR = 1; { seek from current position }
  147. SEEK_END = 2; { seek from end of file }
  148. { open routine }
  149. { File access modes for `open' and `fcntl'. }
  150. O_RDONLY = 0; { Open read-only. }
  151. O_WRONLY = 1; { Open write-only. }
  152. O_RDWR = 2; { Open read/write. }
  153. { Bits OR'd into the second argument to open. }
  154. O_CREAT = $100; { Create file if it doesn't exist. }
  155. O_EXCL = $400; { Fail if file already ??????. }
  156. O_TRUNC = $200; { Truncate file to zero length. }
  157. O_NOCTTY = $800; { Don't assign a controlling terminal. }
  158. { File status flags for `open' and `fcntl'. }
  159. O_APPEND = $08; { Writes append to the file. }
  160. O_NONBLOCK = $04; { Non-blocking I/O. }
  161. { mode_t possible values }
  162. S_ISUID = &4000; { set user id on execution }
  163. S_ISGID = &2000; { set group id on execution }
  164. S_IRUSR = $100; { Read permission for owner }
  165. S_IWUSR = $080; { Write permission for owner }
  166. S_IXUSR = $040; { Exec permission for owner }
  167. S_IRGRP = $020; { Read permission for group }
  168. S_IWGRP = $010; { Write permission for group }
  169. S_IXGRP = $008; { Exec permission for group }
  170. S_IROTH = $004; { Read permission for world }
  171. S_IWOTH = $002; { Write permission for world }
  172. S_IXOTH = $001; { Exec permission for world }
  173. { Used for waitpid }
  174. WNOHANG = $01; { don't block waiting }
  175. WUNTRACED = $02; { report status of stopped children }
  176. Const
  177. S_IFMT = $F000;
  178. S_IFIFO = $1000;
  179. S_IFCHR = $2000;
  180. S_IFDIR = $4000;
  181. S_IFBLK = $6000;
  182. S_IFREG = $8000;
  183. S_IFLNK = $A000;
  184. S_IFSOCK= $C000;
  185. // S_IFWHT = 57344;
  186. S_ISVTX = $200;
  187. { For File control mechanism }
  188. F_GetFd = 1;
  189. F_SetFd = 2;
  190. F_GetFl = 3;
  191. F_SetFl = 4;
  192. F_GetLk = 5;
  193. F_SetLk = 6;
  194. F_SetLkW = 7;
  195. F_SetOwn = 9;
  196. F_GetOwn = 8;
  197. Const
  198. { Constansts for MMAP }
  199. {$ifdef FPC_IS_SYSTEM}
  200. MAP_PRIVATE =2;
  201. {$endif}
  202. MAP_ANONYMOUS =$10;
  203. type
  204. rlim_t = cULong;
  205. PRLimit = ^TRLimit;
  206. TRLimit = record
  207. rlim_cur : rlim_t;
  208. rlim_max : rlim_t;
  209. end;
  210. {$i signal.inc}
  211. iovec = record
  212. iov_base : pointer;
  213. iov_len : size_t;
  214. end;
  215. tiovec=iovec;
  216. piovec=^tiovec;
  217. tms = packed record
  218. tms_utime : clock_t; { User CPU time }
  219. tms_stime : clock_t; { System CPU time }
  220. tms_cutime : clock_t; { User CPU time of terminated child procs }
  221. tms_cstime : clock_t; { System CPU time of terminated child procs }
  222. end;
  223. TTms= tms;
  224. pTms= ^tms;
  225. const
  226. POLLIN = $0001;
  227. POLLPRI = $0004;
  228. POLLOUT = $0002;
  229. POLLERR = $4000;
  230. POLLHUP = $2000;
  231. POLLNVAL = $8000;
  232. { XOpen, XPG 4.2 }
  233. POLLRDNORM = $0010;
  234. POLLRDBAND = $0020;
  235. POLLWRNORM = POLLOUT;
  236. POLLWRBAND = $0040;
  237. type
  238. pollfd = record
  239. { int on 64 bit = long on 32 bit, but this is how the C header does it }
  240. {$ifdef cpu64}
  241. fd: cint;
  242. {$else}
  243. fd: clong;
  244. {$endif}
  245. events: cshort;
  246. revents: cshort;
  247. end;
  248. tpollfd = pollfd;
  249. ppollfd = ^pollfd;
  250. type
  251. TTimespecArr = array[0..1] of ttimespec;