2
0

ostypes.inc 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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. CONST
  18. FD_MAXFDSET = 1024;
  19. BITSINWORD = 8*sizeof(longint);
  20. wordsinsigset = SIG_MAXSIG DIV BITSINWORD; // words in sigset_t
  21. wordsinfdset = FD_MAXFDSET DIV BITSINWORD; // words in fdset_t
  22. ln2bitsinword = 5; { 32bit : ln(32)/ln(2)=5 }
  23. ln2bitmask = 1 shl ln2bitsinword - 1;
  24. UTSNAME_LENGTH = 256; { 256 + 1 in pchar format }
  25. UTSNAME_NODENAME_LENGTH = 256;
  26. ST_FSTYPSZ = 16; {* array size for file system type name *}
  27. TYPE
  28. blksize_t = clong;
  29. blkcnt_t = clong;
  30. { file characteristics services }
  31. stat = packed record { verify the alignment of the members }
  32. st_dev : dev_t;
  33. {$ifndef CPU64}
  34. st_pad1 : array[1..3] of longint; { reserve for dev expansion }
  35. {$endif ndef CPU64}
  36. st_ino : ino_t;
  37. st_mode : mode_t;
  38. st_nlink : nlink_t;
  39. st_uid : uid_t;
  40. st_gid : gid_t;
  41. st_rdev : dev_t;
  42. {$ifndef CPU64}
  43. st_pad2 : array[1..2] of longint;
  44. {$endif ndef CPU64}
  45. st_size : off_t;
  46. {$ifndef CPU64}
  47. st_pad3 : longint; {* reserve pad for future off_t expansion *}
  48. {$endif ndef CPU64}
  49. st_atime : time_t;
  50. st_atimens : clong; { access time nanosecond field }
  51. st_mtime : time_t;
  52. st_mtimens : clong; { modification time nanosecond field }
  53. st_ctime : time_t;
  54. st_ctimens : clong; { modification time nanosecond field }
  55. st_blksize : blksize_t;
  56. st_blocks : blkcnt_t;
  57. st_fstype : array[0..ST_FSTYPSZ-1] of char;
  58. {$ifndef CPU64}
  59. st_pad4 : array[1..8] of longint;
  60. {$endif ndef CPU64}
  61. end;
  62. TStat = Stat;
  63. PStat = ^Stat;
  64. flock = record
  65. l_type : cshort; { lock type: read/write, etc. }
  66. l_whence: cshort; { type of l_start }
  67. {$ifdef 64bitfs}
  68. l_start : off64_t; { starting offset }
  69. l_len : off64_t; { len = 0 means until end of file }
  70. {$else}
  71. l_start : off_t; { starting offset }
  72. l_len : off_t; { len = 0 means until end of file }
  73. {$endif}
  74. l_sysid : cint;
  75. l_pid : pid_t; { lock owner }
  76. l_pas : array[0..3] of clong;
  77. end;
  78. TFlock = flock;
  79. pFlock = ^flock;
  80. TFDSetEl = Cardinal;
  81. TFDSet = array[0..(FD_MAXFDSET div 32)-1] of TFDSetEl;
  82. pFDSet = ^TFDSet;
  83. timezone = packed record
  84. tz_minuteswest,tz_dsttime:cint;
  85. end;
  86. ptimezone =^timezone;
  87. TTimeZone = timezone;
  88. { system information services }
  89. utsname = packed record { don't forget to verify the alignment }
  90. sysname : array[0..UTSNAME_LENGTH] of char;
  91. nodename : array[0..UTSNAME_LENGTH] of char;
  92. release : array[0..UTSNAME_LENGTH] of char;
  93. version : array[0..UTSNAME_LENGTH] of char;
  94. machine : array[0..UTSNAME_LENGTH] of char;
  95. end;
  96. UTimBuf = Record
  97. actime : time_t;
  98. modtime : time_t;
  99. end;
  100. TUtimBuf = UtimBuf;
  101. pUtimBuf = ^UtimBuf;
  102. { directory services }
  103. pdirent = ^dirent;
  104. dirent = packed record { directory entry record - verify alignment }
  105. case integer of
  106. 1 : (
  107. d_ino : ino_t; {* "inode number" of entry *}
  108. d_off : off_t; {* offset of disk directory entry *}
  109. d_reclen : word; {* length of this record *}
  110. d_name : array[0..255] of char; { name of file }
  111. );
  112. { overlay with alias }
  113. 2 : (
  114. d_fileno : ino_t;
  115. );
  116. end;
  117. pdir = ^dir;
  118. dir = packed record
  119. case integer of
  120. 1 : (
  121. d_fd : cint; {* file descriptor *}
  122. d_loc : cint; {* offset in block *}
  123. d_size : cint; {* amount of valid data *}
  124. d_buf : pchar; { directory block }
  125. );
  126. { overlay for posix compatibility }
  127. 2 : (
  128. dd_fd : cint; {* file descriptor *}
  129. dd_loc : cint; {* offset in block *}
  130. dd_size : cint; {* amount of valid data *}
  131. dd_buf : pchar; { directory block }
  132. );
  133. end;
  134. {***********************************************************************}
  135. { POSIX CONSTANT ROUTINE DEFINITIONS }
  136. {***********************************************************************}
  137. CONST
  138. { access routine - these maybe OR'ed together }
  139. F_OK = 0; { test for existence of file }
  140. R_OK = 4; { test for read permission on file }
  141. W_OK = 2; { test for write permission on file }
  142. X_OK = 1; { test for execute or search permission }
  143. { seek routine }
  144. SEEK_SET = 0; { seek from beginning of file }
  145. SEEK_CUR = 1; { seek from current position }
  146. SEEK_END = 2; { seek from end of file }
  147. { open routine }
  148. { File access modes for `open' and `fcntl'. }
  149. O_RDONLY = 0; { Open read-only. }
  150. O_WRONLY = 1; { Open write-only. }
  151. O_RDWR = 2; { Open read/write. }
  152. O_NDELAY = 4;
  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. O_XATTR = $4000;
  159. O_NOFOLLOW = $20000;
  160. O_NOLINKS = $40000;
  161. { File status flags for `open' and `fcntl'. }
  162. O_APPEND = $08; { Writes append to the file. }
  163. O_SYNC = $10;
  164. O_NONBLOCK = $80; { Non-blocking I/O. }
  165. O_LARGEFILE = $2000;
  166. { mode_t possible values }
  167. S_IRUSR = $100; { Read permission for owner }
  168. S_IWUSR = $080; { Write permission for owner }
  169. S_IXUSR = $040; { Exec permission for owner }
  170. S_IRGRP = $020; { Read permission for group }
  171. S_IWGRP = $010; { Write permission for group }
  172. S_IXGRP = $008; { Exec permission for group }
  173. S_IROTH = $004; { Read permission for world }
  174. S_IWOTH = $002; { Write permission for world }
  175. S_IXOTH = $001; { Exec permission for world }
  176. { Used for waitpid }
  177. WNOHANG = $40; { don't block waiting }
  178. WUNTRACED = $04; { report status of stopped children }
  179. Const
  180. S_IFMT = 61440;
  181. S_IFIFO = 4096;
  182. S_IFCHR = 8192;
  183. S_IFDIR = 16384;
  184. S_IFBLK = 24576;
  185. S_IFREG = 32768;
  186. S_IFLNK = 40960;
  187. S_IFSOCK= 49152;
  188. S_IFWHT = 57344;
  189. S_ISVTX = 512;
  190. { For File control mechanism }
  191. F_GetFd = 1;
  192. F_SetFd = 2;
  193. F_GetFl = 3;
  194. F_SetFl = 4;
  195. F_GetLk = 14;
  196. F_SetLk = 6;
  197. F_SetLkW = 7;
  198. F_SetOwn = 23;
  199. F_GetOwn = 24;
  200. Const
  201. { Constansts for MMAP }
  202. {$ifdef FPC_IS_SYSTEM}
  203. MAP_PRIVATE =2;
  204. {$endif}
  205. MAP_ANONYMOUS =$100;
  206. type
  207. rlim_t = cULong;
  208. PRLimit = ^TRLimit;
  209. TRLimit = record
  210. rlim_cur : rlim_t;
  211. rlim_max : rlim_t;
  212. end;
  213. {$i signal.inc}
  214. iovec = record
  215. iov_base : pointer;
  216. iov_len : size_t;
  217. end;
  218. tiovec=iovec;
  219. piovec=^tiovec;
  220. tms = packed record
  221. tms_utime : clock_t; { User CPU time }
  222. tms_stime : clock_t; { System CPU time }
  223. tms_cutime : clock_t; { User CPU time of terminated child procs }
  224. tms_cstime : clock_t; { System CPU time of terminated child procs }
  225. end;
  226. TTms= tms;
  227. pTms= ^tms;
  228. const
  229. POLLIN = $0001;
  230. POLLPRI = $0002;
  231. POLLOUT = $0004;
  232. POLLERR = $0008;
  233. POLLHUP = $0010;
  234. POLLNVAL = $0020;
  235. { XOpen, XPG 4.2 }
  236. POLLRDNORM = $0040;
  237. POLLRDBAND = $0080;
  238. POLLWRNORM = POLLOUT;
  239. POLLWRBAND = $0100;
  240. type
  241. pollfd = record
  242. fd: cint;
  243. events: cshort;
  244. revents: cshort;
  245. end;
  246. tpollfd = pollfd;
  247. ppollfd = ^pollfd;