ostypes.inc 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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. // SYS_NMLM = 65;
  19. UTSNAME_LENGTH = SYS_NMLN;
  20. UTSNAME_NODENAME_LENGTH = UTSNAME_LENGTH;
  21. {$ifdef usedomain}
  22. UTSNAME_DOMAIN_LENGTH = UTSNAME_LENGTH;
  23. {$endif}
  24. FD_MAXFDSET = 1024;
  25. BITSINWORD = 8*sizeof(longint);
  26. wordsinsigset = SIG_MAXSIG DIV BITSINWORD; // words in sigset_t
  27. wordsinfdset = FD_MAXFDSET DIV BITSINWORD; // words in fdset_t
  28. ln2bitsinword = 5; { 32bit : ln(32)/ln(2)=5 }
  29. ln2bitmask = 1 shl ln2bitsinword - 1;
  30. TYPE
  31. Blksize_t = cuint;
  32. Blkcnt_t = cuint;
  33. Ino64_t = cint64;
  34. Off64_t = cint64;
  35. TBlkSize = BlkSize_t;
  36. PBlkSize = ^BlkSize_t;
  37. TBlkCnt = Blkcnt_t;
  38. PBlkCnt = ^Blkcnt_t;
  39. TIno64 = Ino64_t;
  40. PIno64 = ^Ino64_t;
  41. TOff64 = Off64_t;
  42. POff64 = ^Off64_t;
  43. { system information services }
  44. UtsName = Record
  45. Sysname : Array[0..UTSNAME_LENGTH -1] OF Char; // Name of this OS
  46. Nodename: Array[0..UTSNAME_NODENAME_LENGTH-1] OF Char; // Name of this network node.
  47. Release : Array[0..UTSNAME_LENGTH -1] OF Char; // Release level.
  48. Version : Array[0..UTSNAME_LENGTH -1] OF Char; // Version level.
  49. Machine : Array[0..UTSNAME_LENGTH -1] OF Char; // Hardware type.
  50. {$ifdef usedomain}
  51. Domain : array[0..UTSNAME_DOMAIN_LENGTH-1] of char; // Linux addition "Domain"
  52. {$endif}
  53. end;
  54. TUtsName = UtsName;
  55. PUtsName = TUtsName;
  56. { Definition of (kernel) stat type }
  57. { see kernel/include/asm-<cpu>/stat.h, include/linux/types.h and }
  58. { include /include/asm-<cpu>/posix-types.h }
  59. const
  60. _STAT_VER_LINUX_OLD = 1;
  61. _STAT_VER_KERNEL = 1;
  62. _STAT_VER_SVR4 = 2;
  63. _STAT_VER_LINUX = 3;
  64. _STAT_VER = _STAT_VER_LINUX;
  65. type
  66. {$i stat.inc}
  67. TStat = Stat;
  68. PStat = ^Stat;
  69. {$ifdef notused} // 64-bit support needs some work still :-)
  70. { file characteristics services }
  71. stat64 = record
  72. st_dev : dev_t; // inode's device
  73. pad1 : cushort;
  74. {$ifdef 64bitfs} // ??
  75. __st_ino : ino_t;
  76. {$else}
  77. st_ino : ino_t; // inode's number
  78. {$endif}
  79. st_mode : mode_t; // inode protection mode
  80. st_nlink : nlink_t; // number of hard links
  81. st_uid : uid_t; // user ID of the file's owner
  82. st_gid : gid_t; // group ID of the file's group
  83. st_rdev : dev_t; // device type
  84. pad2 : cushort;
  85. {$ifdef 64bitfs}
  86. st_size : off64_t; // file size, in bytes
  87. {$else}
  88. st_size : off_t; // file size, in bytes
  89. {$endif}
  90. st_blksize : blksize_t; // optimal blocksize for I/O
  91. {$ifdef 64bitfs}
  92. st_blocks : blkcnt64_t; // blocks allocated for file
  93. {$else}
  94. st_blocks : blkcnt_t; // blocks allocated for file
  95. {$endif}
  96. st_atime : time_t; // time of last access
  97. unused1 : culong;
  98. st_mtime : time_t; // time of last data modification
  99. unused2 : culong;
  100. st_ctime : time_t; // time of last file status change
  101. unused3 : culong;
  102. {$ifdef 64bitfs}
  103. st_ino : ino64_t
  104. {$else}
  105. unused4 : culong;
  106. unused5 : culong;
  107. {$endif}
  108. end;
  109. {$endif}
  110. { directory services }
  111. Dirent = packed record
  112. {$ifndef 64bitfs}
  113. d_fileno : ino_t; // file number of entry
  114. d_off : off_t;
  115. {$else}
  116. d_fileno : ino64_t; // file number of entry
  117. d_off : off64_t;
  118. {$endif}
  119. d_reclen : cushort; // length of string in d_name
  120. {$ifdef Uselibc} // Libc different from kernel record!
  121. d_type : cuchar; // file type, see below
  122. {$endif}
  123. d_name : array[0..(255 + 1)-1] of char; // name must be no longer than this
  124. end;
  125. TDirent = Dirent;
  126. pDirent = ^Dirent;
  127. {$ifdef oldreaddir}
  128. { Still old one. This is a userland struct}
  129. Dir = record
  130. dd_fd : integer;
  131. dd_loc : longint;
  132. dd_size : integer;
  133. dd_buf : pdirent;
  134. {The following are used in libc, but NOT in the linux kernel sources ??}
  135. dd_nextoff: longint;
  136. dd_max : integer; {size of buf. Irrelevant, as buf is of type dirent}
  137. dd_lock : pointer;
  138. end;
  139. {$else}
  140. // new libc one. NOTE that off_t must be real, so 64-bit ifdef
  141. // 64bitsfs
  142. Dir = Record // packing doesn't matter. This is a userland struct.
  143. fd : cint;
  144. data : pchar;
  145. allocation: size_t;
  146. _size : size_t;
  147. offset : size_t;
  148. filepos : off_t;
  149. end;
  150. {$endif}
  151. TDir = Dir;
  152. pDir = ^Dir;
  153. UTimBuf = Record
  154. actime : time_t;
  155. modtime : time_t;
  156. end;
  157. TUtimBuf = UtimBuf;
  158. pUtimBuf = ^UtimBuf;
  159. FLock = Record
  160. l_type : cshort; { lock type: read/write, etc. }
  161. l_whence: cshort; { type of l_start }
  162. {$ifdef 64bitfs}
  163. l_start : off64_t; { starting offset }
  164. l_len : off64_t; { len = 0 means until end of file }
  165. {$else}
  166. l_start : off_t; { starting offset }
  167. l_len : off_t; { len = 0 means until end of file }
  168. {$endif}
  169. l_pid : pid_t; { lock owner }
  170. End;
  171. tms = packed Record
  172. tms_utime : clock_t; { User CPU time }
  173. tms_stime : clock_t; { System CPU time }
  174. tms_cutime : clock_t; { User CPU time of terminated child procs }
  175. tms_cstime : clock_t; { System CPU time of terminated child procs }
  176. end;
  177. TTms = tms;
  178. PTms = ^tms;
  179. TFDSet = ARRAY[0..(FD_MAXFDSET div BITSINWORD)-1] of cuLong;
  180. pFDSet = ^TFDSet;
  181. timezone = packed record
  182. tz_minuteswest,tz_dsttime:cint;
  183. end;
  184. ptimezone =^timezone;
  185. TTimeZone = timezone;
  186. {***********************************************************************}
  187. { POSIX CONSTANT ROUTINE DEFINITIONS }
  188. {***********************************************************************}
  189. CONST
  190. { access routine - these maybe OR'ed together }
  191. F_OK = 0; { test for existence of file }
  192. R_OK = 4; { test for read permission on file }
  193. W_OK = 2; { test for write permission on file }
  194. X_OK = 1; { test for execute or search permission }
  195. { seek routine }
  196. SEEK_SET = 0; { seek from beginning of file }
  197. SEEK_CUR = 1; { seek from current position }
  198. SEEK_END = 2; { seek from end of file }
  199. { open routine }
  200. { File access modes for `open' and `fcntl'. }
  201. O_RDONLY = 0; { Open read-only. }
  202. O_WRONLY = 1; { Open write-only. }
  203. O_RDWR = 2; { Open read/write. }
  204. {$ifdef sparc}
  205. O_APPEND = 8;
  206. O_CREAT = $200;
  207. O_TRUNC = $400;
  208. O_EXCL = $800;
  209. O_SYNC = $2000;
  210. O_NONBLOCK = $4000;
  211. O_NDELAY = O_NONBLOCK or 4;
  212. O_NOCTTY = $8000;
  213. O_DIRECTORY = $10000;
  214. O_NOFOLLOW = $20000;
  215. O_LARGEFILE = $40000;
  216. O_DIRECT = $100000;
  217. {$else sparc}
  218. O_CREAT = $40;
  219. O_EXCL = $80;
  220. O_NOCTTY = $100;
  221. O_TRUNC = $200;
  222. O_APPEND = $400;
  223. O_NONBLOCK = $800;
  224. O_NDELAY = O_NONBLOCK;
  225. O_SYNC = $1000;
  226. O_DIRECT = $4000;
  227. O_LARGEFILE = $8000;
  228. O_DIRECTORY = $10000;
  229. O_NOFOLLOW = $20000;
  230. {$endif sparc}
  231. { mode_t possible values }
  232. S_IRUSR = %0100000000; { Read permission for owner }
  233. S_IWUSR = %0010000000; { Write permission for owner }
  234. S_IXUSR = %0001000000; { Exec permission for owner }
  235. S_IRGRP = %0000100000; { Read permission for group }
  236. S_IWGRP = %0000010000; { Write permission for group }
  237. S_IXGRP = %0000001000; { Exec permission for group }
  238. S_IROTH = %0000000100; { Read permission for world }
  239. S_IWOTH = %0000000010; { Write permission for world }
  240. S_IXOTH = %0000000001; { Exec permission for world }
  241. S_IRWXU = S_IRUSR or S_IWUSR or S_IXUSR;
  242. { Used for waitpid }
  243. WNOHANG = 1; { don't block waiting }
  244. WUNTRACED = 2; { report status of stopped children }
  245. { File types }
  246. S_IFMT = 61440; { type of file mask}
  247. S_IFIFO = 4096; { named pipe (fifo)}
  248. S_IFCHR = 8192; { character special}
  249. S_IFDIR = 16384; { directory }
  250. S_IFBLK = 24576; { block special}
  251. S_IFREG = 32768; { regular }
  252. S_IFLNK = 40960; { symbolic link }
  253. S_IFSOCK= 49152; { socket }
  254. { Constansts for MMAP }
  255. MAP_PRIVATE =2;
  256. MAP_ANONYMOUS =$20;
  257. { For File control mechanism }
  258. F_GetFd = 1;
  259. F_SetFd = 2;
  260. F_GetFl = 3;
  261. F_SetFl = 4;
  262. F_GetLk = 5;
  263. F_SetLk = 6;
  264. F_SetLkW = 7;
  265. F_SetOwn = 8;
  266. F_GetOwn = 9;
  267. { getrlimit/ugetrlimit resource parameter constants }
  268. const
  269. RLIMIT_CPU = 0; { CPU time in ms }
  270. RLIMIT_FSIZE = 1; { Maximum filesize }
  271. RLIMIT_DATA = 2; { max data size }
  272. RLIMIT_STACK = 3; { max stack size }
  273. RLIMIT_CORE = 4; { max core file size }
  274. RLIMIT_RSS = 5; { max resident set size }
  275. RLIMIT_NPROC = 6; { max number of processes }
  276. RLIMIT_NOFILE = 7; { max number of open files }
  277. RLIMIT_MEMLOCK = 8; { max locked-in-memory address space }
  278. RLIMIT_AS = 9; { address space limit(?) }
  279. RLIMIT_LOCKS = 10; { maximum file locks held }
  280. type
  281. rlim_t = cULong;
  282. PRLimit = ^TRLimit;
  283. TRLimit = record
  284. rlim_cur : rlim_t;
  285. rlim_max : rlim_t;
  286. end;
  287. iovec = record
  288. iov_base : pointer;
  289. iov_len : size_t;
  290. end;
  291. tiovec=iovec;
  292. piovec=^tiovec;
  293. {*************************************************************************}
  294. { SIGNALS }
  295. {*************************************************************************}
  296. {$i signal.inc}