ostypes.inc 8.4 KB

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