ostypes.inc 12 KB

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