ostypes.inc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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. Blkcnt64_t = cuint64;
  40. TBlkSize = BlkSize_t;
  41. PBlkSize = ^BlkSize_t;
  42. TBlkCnt = Blkcnt_t;
  43. PBlkCnt = ^Blkcnt_t;
  44. { system information services }
  45. UtsName = Record
  46. Sysname : Array[0..UTSNAME_LENGTH -1] OF Char; // Name of this OS
  47. Nodename: Array[0..UTSNAME_NODENAME_LENGTH-1] OF Char; // Name of this network node.
  48. Release : Array[0..UTSNAME_LENGTH -1] OF Char; // Release level.
  49. Version : Array[0..UTSNAME_LENGTH -1] OF Char; // Version level.
  50. Machine : Array[0..UTSNAME_LENGTH -1] OF Char; // Hardware type.
  51. {$ifdef usedomain}
  52. Domain : array[0..UTSNAME_DOMAIN_LENGTH-1] of char {$ifndef ver2_2} platform; {$endif} // Linux addition "Domain"
  53. {$endif}
  54. end;
  55. TUtsName = UtsName;
  56. PUtsName = ^TUtsName;
  57. { Definition of (kernel) stat type }
  58. { see kernel/include/asm-<cpu>/stat.h, include/linux/types.h and }
  59. { include /include/asm-<cpu>/posix-types.h }
  60. const
  61. _STAT_VER_LINUX_OLD = 1;
  62. _STAT_VER_KERNEL = 1;
  63. _STAT_VER_SVR4 = 2;
  64. _STAT_VER_LINUX = 3;
  65. _STAT_VER = _STAT_VER_LINUX;
  66. type
  67. {$i stat.inc}
  68. TStat = Stat;
  69. PStat = ^Stat;
  70. { directory services }
  71. Dirent = packed record
  72. d_fileno : ino64_t; // file number of entry
  73. d_off : off_t;
  74. d_reclen : cushort; // length of string in d_name
  75. d_type : cuchar; // file type, see below
  76. d_name : array[0..(255 + 1)-1] of char; // name must be no longer than this
  77. end;
  78. TDirent = Dirent;
  79. pDirent = ^Dirent;
  80. {$ifdef oldreaddir}
  81. { Still old one. This is a userland struct}
  82. Dir = record
  83. dd_fd : integer;
  84. dd_loc : longint;
  85. dd_size : integer;
  86. dd_buf : pdirent;
  87. {The following are used in libc, but NOT in the linux kernel sources ??}
  88. dd_nextoff: cardinal;
  89. dd_max : integer; {size of buf. Irrelevant, as buf is of type dirent}
  90. dd_lock : pointer;
  91. end;
  92. {$else}
  93. // new libc one. NOTE that off_t must be real, so 64-bit ifdef
  94. Dir = Record // packing doesn't matter. This is a userland struct.
  95. fd : cint;
  96. data : pchar;
  97. allocation: size_t;
  98. _size : size_t;
  99. offset : size_t;
  100. filepos : off_t;
  101. end;
  102. {$endif}
  103. TDir = Dir;
  104. pDir = ^Dir;
  105. UTimBuf = Record
  106. actime : time_t;
  107. modtime : time_t;
  108. end;
  109. TUtimBuf = UtimBuf;
  110. pUtimBuf = ^UtimBuf;
  111. kernel_off_t = clong;
  112. kernel_loff_t = clonglong;
  113. FLock = Record
  114. l_type : cshort; { lock type: read/write, etc. }
  115. l_whence: cshort; { type of l_start }
  116. l_start : kernel_off_t; { starting offset }
  117. l_len : kernel_off_t; { len = 0 means until end of file }
  118. l_pid : pid_t; { lock owner }
  119. {$ifdef cpusparc}
  120. __pad : cshort;
  121. {$endif}
  122. End;
  123. {$ifndef cpu64}
  124. FLock64 = Record
  125. l_type : cshort; { lock type: read/write, etc. }
  126. l_whence: cshort; { type of l_start }
  127. l_start : kernel_loff_t; { starting offset }
  128. l_len : kernel_loff_t; { len = 0 means until end of file }
  129. l_pid : pid_t; { lock owner }
  130. {$ifdef cpusparc}
  131. __pad : cshort;
  132. {$endif}
  133. End;
  134. {$endif}
  135. tms = packed Record
  136. tms_utime : clock_t; { User CPU time }
  137. tms_stime : clock_t; { System CPU time }
  138. tms_cutime : clock_t; { User CPU time of terminated child procs }
  139. tms_cstime : clock_t; { System CPU time of terminated child procs }
  140. end;
  141. TTms = tms;
  142. PTms = ^tms;
  143. TFDSet = ARRAY[0..(FD_MAXFDSET div BITSINWORD)-1] of cuLong;
  144. pFDSet = ^TFDSet;
  145. timezone = packed record
  146. tz_minuteswest,tz_dsttime:cint;
  147. end;
  148. ptimezone =^timezone;
  149. TTimeZone = timezone;
  150. const
  151. POLLIN = $0001;
  152. POLLPRI = $0002;
  153. POLLOUT = $0004;
  154. POLLERR = $0008;
  155. POLLHUP = $0010;
  156. POLLNVAL = $0020;
  157. { XOpen, XPG 4.2 }
  158. POLLRDNORM = $0040;
  159. POLLRDBAND = $0080;
  160. POLLWRNORM = $0100;
  161. POLLWRBAND = $0200;
  162. type
  163. pollfd = record
  164. fd: cint;
  165. events: cshort;
  166. revents: cshort;
  167. end;
  168. tpollfd = pollfd;
  169. ppollfd = ^pollfd;
  170. {***********************************************************************}
  171. { POSIX CONSTANT ROUTINE DEFINITIONS }
  172. {***********************************************************************}
  173. CONST
  174. { access routine - these maybe OR'ed together }
  175. F_OK = 0; { test for existence of file }
  176. R_OK = 4; { test for read permission on file }
  177. W_OK = 2; { test for write permission on file }
  178. X_OK = 1; { test for execute or search permission }
  179. { seek routine }
  180. SEEK_SET = 0; { seek from beginning of file }
  181. SEEK_CUR = 1; { seek from current position }
  182. SEEK_END = 2; { seek from end of file }
  183. { open routine }
  184. { File access modes for `open' and `fcntl'. }
  185. O_RDONLY = 0; { Open read-only. }
  186. O_WRONLY = 1; { Open write-only. }
  187. O_RDWR = 2; { Open read/write. }
  188. {$ifdef cpusparc}
  189. O_APPEND = 8;
  190. O_CREAT = $200;
  191. O_TRUNC = $400;
  192. O_EXCL = $800;
  193. O_SYNC = $2000;
  194. O_NONBLOCK = $4000;
  195. O_NDELAY = O_NONBLOCK or 4;
  196. O_NOCTTY = $8000;
  197. O_DIRECTORY = $10000;
  198. O_NOFOLLOW = $20000;
  199. O_DIRECT = $100000;
  200. {$else cpusparc}
  201. O_CREAT = $40;
  202. O_EXCL = $80;
  203. O_NOCTTY = $100;
  204. O_TRUNC = $200;
  205. O_APPEND = $400;
  206. O_NONBLOCK = $800;
  207. O_NDELAY = O_NONBLOCK;
  208. O_SYNC = $1000;
  209. O_DIRECT = $4000;
  210. O_DIRECTORY = $10000;
  211. O_NOFOLLOW = $20000;
  212. {$endif cpusparc}
  213. {$if defined(cpuarm) or defined(cpualpha) or defined(cpublackfin) or defined(cpum68k)}
  214. O_LARGEFILE = $20000;
  215. {$endif}
  216. {$if defined(cpusparc) or defined(cpusparc64)}
  217. O_LARGEFILE = $40000;
  218. {$endif}
  219. {$if defined(cpupowerpc)}
  220. O_LARGEFILE = $10000;
  221. {$endif}
  222. {$if defined(cpui386) or defined(cpux86_64) or defined(cpuia64)}
  223. O_LARGEFILE = $8000;
  224. {$endif}
  225. {$if defined(cpumips)}
  226. O_LARGEFILE = $2000;
  227. {$endif}
  228. { mode_t possible values }
  229. S_IRUSR = %0100000000; { Read permission for owner }
  230. S_IWUSR = %0010000000; { Write permission for owner }
  231. S_IXUSR = %0001000000; { Exec permission for owner }
  232. S_IRGRP = %0000100000; { Read permission for group }
  233. S_IWGRP = %0000010000; { Write permission for group }
  234. S_IXGRP = %0000001000; { Exec permission for group }
  235. S_IROTH = %0000000100; { Read permission for world }
  236. S_IWOTH = %0000000010; { Write permission for world }
  237. S_IXOTH = %0000000001; { Exec permission for world }
  238. S_IRWXU = S_IRUSR or S_IWUSR or S_IXUSR;
  239. S_IRWXG = S_IRGRP or S_IWGRP or S_IXGRP;
  240. S_IRWXO = S_IROTH or S_IWOTH or S_IXOTH;
  241. { Used for waitpid }
  242. WNOHANG = 1; { don't block waiting }
  243. WUNTRACED = 2; { report status of stopped children }
  244. { File types }
  245. S_IFMT = 61440; { type of file mask}
  246. S_IFIFO = 4096; { named pipe (fifo)}
  247. S_IFCHR = 8192; { character special}
  248. S_IFDIR = 16384; { directory }
  249. S_IFBLK = 24576; { block special}
  250. S_IFREG = 32768; { regular }
  251. S_IFLNK = 40960; { symbolic link }
  252. S_IFSOCK= 49152; { socket }
  253. { Constansts for MMAP }
  254. {$IFDEF FPC_IS_SYSTEM}
  255. MAP_PRIVATE =2;
  256. {$ENDIF}
  257. MAP_ANONYMOUS =$20;
  258. { For File control mechanism }
  259. F_GetFd = 1;
  260. F_SetFd = 2;
  261. F_GetFl = 3;
  262. F_SetFl = 4;
  263. F_GetLk = 5;
  264. F_SetLk = 6;
  265. F_SetLkW = 7;
  266. F_SetOwn = 8;
  267. F_GetOwn = 9;
  268. { getrlimit/ugetrlimit resource parameter constants }
  269. const
  270. RLIMIT_CPU = 0; { CPU time in ms }
  271. RLIMIT_FSIZE = 1; { Maximum filesize }
  272. RLIMIT_DATA = 2; { max data size }
  273. RLIMIT_STACK = 3; { max stack size }
  274. RLIMIT_CORE = 4; { max core file size }
  275. RLIMIT_RSS = 5; { max resident set size }
  276. RLIMIT_NPROC = 6; { max number of processes }
  277. RLIMIT_NOFILE = 7; { max number of open files }
  278. RLIMIT_MEMLOCK = 8; { max locked-in-memory address space }
  279. RLIMIT_AS = 9; { address space limit(?) }
  280. RLIMIT_LOCKS = 10; { maximum file locks held }
  281. type
  282. rlim_t = cULong;
  283. PRLimit = ^TRLimit;
  284. TRLimit = record
  285. rlim_cur : rlim_t;
  286. rlim_max : rlim_t;
  287. end;
  288. iovec = record
  289. iov_base : pointer;
  290. iov_len : size_t;
  291. end;
  292. tiovec=iovec;
  293. piovec=^tiovec;
  294. {$if defined(cpupowerpc)}
  295. const
  296. { FP exception related constants for prctl(); PowerPC specific }
  297. PR_GET_FPEXC = 11; { get floating point exception mode }
  298. PR_SET_FPEXC = 12; { set floating point exception mode }
  299. PR_FP_EXC_DISABLED = 0; { FP exceptions disabled }
  300. PR_FP_EXC_NONREC = 1; { async non-recoverable exc. mode }
  301. PR_FP_EXC_ASYNC = 2; { async recoverable exc. mode }
  302. PR_FP_EXC_PRECISE = 3; { precise exception mode }
  303. {$endif}
  304. {*************************************************************************}
  305. { SIGNALS }
  306. {*************************************************************************}
  307. {$i signal.inc}