ostypes.inc 8.5 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. { 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. TFDSet = array[0..wordsinfdset-1] of culong;
  79. pFDSet = ^TFDSet;
  80. timezone = record
  81. tz_minuteswest,tz_dsttime:cint;
  82. end;
  83. ptimezone =^timezone;
  84. TTimeZone = timezone;
  85. { system information services }
  86. utsname = record
  87. sysname : array[0..UTSNAME_LENGTH] of char;
  88. nodename : array[0..UTSNAME_LENGTH] of char;
  89. release : array[0..UTSNAME_LENGTH] of char;
  90. version : array[0..UTSNAME_LENGTH] of char;
  91. machine : array[0..UTSNAME_LENGTH] of char;
  92. end;
  93. UTimBuf = Record
  94. actime : time_t;
  95. modtime : time_t;
  96. end;
  97. TUtimBuf = UtimBuf;
  98. pUtimBuf = ^UtimBuf;
  99. { directory services }
  100. pdirent = ^dirent;
  101. { actually dirent64 }
  102. dirent = record { directory entry record }
  103. case integer of
  104. 1 : (
  105. d_off : cuint64; {* offset of disk directory entry *}
  106. d_ino : ino64_t; {* "inode number" of entry *}
  107. d_reclen : cushort; {* length of this record *}
  108. d_namelen : cushort;
  109. d_name : array[0..255] of char; { name of file }
  110. );
  111. { overlay with alias }
  112. 2 : (
  113. dummy : cuint64;
  114. d_fileno : ino64_t;
  115. );
  116. end;
  117. pdir = ^dir;
  118. dir = 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. { Bits OR'd into the second argument to open. }
  153. O_CREAT = $100; { Create file if it doesn't exist. }
  154. O_EXCL = $400; { Fail if file already ??????. }
  155. O_TRUNC = $200; { Truncate file to zero length. }
  156. O_NOCTTY = $800; { Don't assign a controlling terminal. }
  157. { File status flags for `open' and `fcntl'. }
  158. O_APPEND = $08; { Writes append to the file. }
  159. O_NONBLOCK = $04; { Non-blocking I/O. }
  160. { mode_t possible values }
  161. S_IRUSR = $100; { Read permission for owner }
  162. S_IWUSR = $080; { Write permission for owner }
  163. S_IXUSR = $040; { Exec permission for owner }
  164. S_IRGRP = $020; { Read permission for group }
  165. S_IWGRP = $010; { Write permission for group }
  166. S_IXGRP = $008; { Exec permission for group }
  167. S_IROTH = $004; { Read permission for world }
  168. S_IWOTH = $002; { Write permission for world }
  169. S_IXOTH = $001; { Exec permission for world }
  170. { Used for waitpid }
  171. WNOHANG = $01; { don't block waiting }
  172. WUNTRACED = $02; { report status of stopped children }
  173. Const
  174. S_IFMT = $F000;
  175. S_IFIFO = $1000;
  176. S_IFCHR = $2000;
  177. S_IFDIR = $4000;
  178. S_IFBLK = $6000;
  179. S_IFREG = $8000;
  180. S_IFLNK = $A000;
  181. S_IFSOCK= $C000;
  182. // S_IFWHT = 57344;
  183. S_ISVTX = $200;
  184. { For File control mechanism }
  185. F_GetFd = 1;
  186. F_SetFd = 2;
  187. F_GetFl = 3;
  188. F_SetFl = 4;
  189. F_GetLk = 5;
  190. F_SetLk = 6;
  191. F_SetLkW = 7;
  192. F_SetOwn = 9;
  193. F_GetOwn = 8;
  194. Const
  195. { Constansts for MMAP }
  196. {$ifdef FPC_IS_SYSTEM}
  197. MAP_PRIVATE =2;
  198. {$endif}
  199. MAP_ANONYMOUS =$10;
  200. type
  201. rlim_t = cULong;
  202. PRLimit = ^TRLimit;
  203. TRLimit = record
  204. rlim_cur : rlim_t;
  205. rlim_max : rlim_t;
  206. end;
  207. {$i signal.inc}
  208. iovec = record
  209. iov_base : pointer;
  210. iov_len : size_t;
  211. end;
  212. tiovec=iovec;
  213. piovec=^tiovec;
  214. tms = packed record
  215. tms_utime : clock_t; { User CPU time }
  216. tms_stime : clock_t; { System CPU time }
  217. tms_cutime : clock_t; { User CPU time of terminated child procs }
  218. tms_cstime : clock_t; { System CPU time of terminated child procs }
  219. end;
  220. TTms= tms;
  221. pTms= ^tms;
  222. const
  223. POLLIN = $0001;
  224. POLLPRI = $0004;
  225. POLLOUT = $0002;
  226. POLLERR = $4000;
  227. POLLHUP = $2000;
  228. POLLNVAL = $8000;
  229. { XOpen, XPG 4.2 }
  230. POLLRDNORM = $0010;
  231. POLLRDBAND = $0020;
  232. POLLWRNORM = POLLOUT;
  233. POLLWRBAND = $0040;
  234. type
  235. pollfd = record
  236. { int on 64 bit = long on 32 bit, but this is how the C header does it }
  237. {$ifdef cpu64}
  238. fd: cint;
  239. {$else}
  240. fd: clong;
  241. {$endif}
  242. events: cshort;
  243. revents: cshort;
  244. end;
  245. tpollfd = pollfd;
  246. ppollfd = ^pollfd;