ostypes.inc 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  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 baseunix unit, also used in system.
  5. This file implements all the types/constants which must
  6. be defined to port FPC to a new POSIX compliant OS.
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. {***********************************************************************}
  14. { POSIX STRUCTURES }
  15. {***********************************************************************}
  16. {$ifdef FPC_IS_SYSTEM}
  17. {$i ptypes.inc}
  18. {$ENDIF}
  19. {$ifdef cpupowerpc}
  20. {$ifdef netbsd}
  21. {$define netbsdpowerpc}
  22. {$endif}
  23. {$endif}
  24. {$if defined(darwin) and (defined(cpuarm) or defined(cpuaarch64) or defined(iphonesim) or (defined(MAC_OS_X_VERSION_MIN_REQUIRED) and (MAC_OS_X_VERSION_MIN_REQUIRED >= 1060))) }
  25. {$define darwin_new_iostructs}
  26. {$endif}
  27. // CONST SYS_NMLN=65;
  28. // Can't find these two in Posix and in FreeBSD
  29. //CONST
  30. // _UTSNAME_LENGTH = ;
  31. // _UTSNAME_NODENAME_LENGTH = ;
  32. CONST // OS specific parameters for general<fd,sig>set behaviour
  33. BITSINWORD = 8*sizeof(longint);
  34. FD_MAXFDSET = 1024;
  35. ln2bitsinword = 5; { 32bit : ln(32)/ln(2)=5 }
  36. ln2bitmask = 1 shl ln2bitsinword - 1;
  37. wordsinfdset = FD_MAXFDSET DIV BITSINWORD; // words in fdset_t
  38. wordsinsigset = SIG_MAXSIG DIV BITSINWORD;
  39. TYPE
  40. { system information services }
  41. utsname = record
  42. sysname : Array[0..SYS_NMLN-1] OF AnsiChar; // Name of this OS
  43. nodename: Array[0..SYS_NMLN-1] OF AnsiChar; // Name of this network node.
  44. release : Array[0..SYS_NMLN-1] OF AnsiChar; // Release level.
  45. version : Array[0..SYS_NMLN-1] OF AnsiChar; // Version level.
  46. machine : Array[0..SYS_NMLN-1] OF AnsiChar; // Hardware type.
  47. end;
  48. TUtsName= utsname;
  49. pUtsName= ^utsname;
  50. { file characteristics services }
  51. stat = record { the types are real}
  52. {$if defined(darwin)}
  53. st_dev : dev_t; // inode's device
  54. {$ifdef darwin_new_iostructs}
  55. st_mode : mode_t; // inode protection mode
  56. st_nlink : nlink_t; // number of hard links
  57. st_ino : ino_t; // inode's number
  58. {$else not darwin_new_iostructs}
  59. st_ino : ino_t; // inode's number
  60. st_mode : mode_t; // inode protection mode
  61. st_nlink : nlink_t; // number of hard links
  62. {$endif not darwin_new_iostructs}
  63. st_uid : uid_t; // user ID of the file's owner
  64. st_gid : gid_t; // group ID of the file's group
  65. st_rdev : dev_t; // device type
  66. st_atime : time_t; // time of last access
  67. st_atimensec : clong; // nsec of last access
  68. st_mtime : time_t; // time of last data modification
  69. st_mtimensec : clong; // nsec of last data modification
  70. st_ctime : time_t; // time of last file status change
  71. st_ctimensec : clong; // nsec of last file status change
  72. {$ifdef darwin_new_iostructs}
  73. st_birthtime : time_t; // File creation time
  74. st_birthtimensec : clong; // nsec of file creation time
  75. {$endif}
  76. st_size : off_t; // file size, in bytes
  77. st_blocks : cint64; // blocks allocated for file
  78. st_blksize : cuint32; // optimal blocksize for I/O
  79. st_flags : cuint32; // user defined flags for file
  80. st_gen : cuint32; // file generation number
  81. st_lspare : cuint32; // RESERVED: DO NOT USE!
  82. st_qspare : array[0..1] Of cint64;
  83. {$elseif defined(dragonfly)}
  84. st_ino : ino_t; // inode's number
  85. st_nlink : nlink_t; // number of hard links
  86. st_dev : dev_t; // inode's device
  87. st_mode : mode_t; // inode protection mode
  88. st_padd1 : cuint16;
  89. st_uid : uid_t; // user ID of the file's owner
  90. st_gid : gid_t; // group ID of the file's group
  91. st_rdev : dev_t; // device type
  92. st_atime : time_t; // time of last access (half timespec)
  93. st_atimensec : clong; // nsec of last access (half timespec)
  94. st_mtime : time_t; // time of last data modification
  95. st_mtimensec : clong; // nsec of last data modification
  96. st_ctime : time_t; // time of last file status change
  97. st_ctimensec : clong; // nsec of last file status change
  98. st_size : off_t; // file size, in bytes
  99. st_blocks : cint64; // blocks allocated for file
  100. st_blksize : cuint32; // optimal blocksize for I/O
  101. st_flags : cuint32; // user defined flags for file
  102. st_gen : cuint32; // file generation number
  103. st_lspare : cint32;
  104. st_qspare1 : cint64; // was recursive change detect
  105. st_qspare2 : cint64;
  106. {$elseif defined(openbsd)}
  107. st_mode : mode_t; // inode protection mode
  108. st_dev : dev_t; // inode's device
  109. st_ino : ino_t; // inode's number
  110. st_nlink : nlink_t; // number of hard links
  111. st_uid : uid_t; // user ID of the file's owner
  112. st_gid : gid_t; // group ID of the file's group
  113. st_rdev : dev_t; // device type
  114. st_atime : time_t; // time of last access
  115. st_atimensec : clong; // nsec of last access
  116. st_mtime : time_t; // time of last data modification
  117. st_mtimensec : clong; // nsec of last data modification
  118. st_ctime : time_t; // time of last file status change
  119. st_ctimensec : clong; // nsec of last file status change
  120. st_size : off_t; // file size, in bytes
  121. st_blocks : cint64; // blocks allocated for file
  122. st_blksize : cint32; // optimal blocksize for I/O
  123. st_flags : cuint32; // user defined flags for file
  124. st_gen : cuint32; // file generation number
  125. st_birthtime : time_t; // File creation time
  126. st_birthtimensec : clong; // nsec of file creation time
  127. {$elseif defined(freebsd)}
  128. {$ifdef i386}
  129. {$define __STAT_TIME_T_EXT}
  130. {$endif}
  131. st_dev : dev_t; // inode's device
  132. st_ino : ino_t; // inode's number
  133. st_nlink : nlink_t; // number of hard links
  134. st_mode : mode_t; // inode protection mode
  135. st_padding0 : cint16;
  136. st_uid : uid_t; // user ID of the file's owner
  137. st_gid : gid_t; // group ID of the file's group
  138. st_padding1 : cint32;
  139. st_rdev : dev_t; // device type
  140. {$ifdef __STAT_TIME_T_EXT}
  141. st_atim_ext : cint32;
  142. {$endif}
  143. st_atime : time_t; // time of last access
  144. st_atimensec : clong; // nsec of last access
  145. {$ifdef __STAT_TIME_T_EXT}
  146. st_mtim_ext : cint32;
  147. {$endif}
  148. st_mtime : time_t; // time of last data modification
  149. st_mtimensec : clong; // nsec of last data modification
  150. {$ifdef __STAT_TIME_T_EXT}
  151. st_ctim_ext : cint32;
  152. {$endif}
  153. st_ctime : time_t; // time of last file status change
  154. st_ctimensec : clong; // nsec of last file status change
  155. {$ifdef __STAT_TIME_T_EXT}
  156. st_birthtim_ext : cint32;
  157. {$endif}
  158. st_birthtime : time_t; // File creation time
  159. st_birthtimensec : clong; // nsec of file creation time
  160. st_size : off_t; // file size, in bytes
  161. st_blocks : cint64; // blocks allocated for file
  162. st_blksize : cint32; // optimal blocksize for I/O
  163. st_flags : cuint32; // user defined flags for file
  164. st_gen : cuint64; // file generation number
  165. st_spare : array [0..10-1] of cuint64;
  166. {$else}
  167. st_dev : dev_t; // inode's device
  168. {$ifdef netbsd_use_stat30}
  169. { order is inverted for better alignment probably }
  170. st_mode : mode_t; // inode protection mode
  171. st_ino : ino_t; // inode's number
  172. {$else not netbsd}
  173. st_ino : ino_t; // inode's number
  174. st_mode : mode_t; // inode protection mode
  175. {$endif not netbsd}
  176. st_nlink : nlink_t; // number of hard links
  177. st_uid : uid_t; // user ID of the file's owner
  178. st_gid : gid_t; // group ID of the file's group
  179. st_rdev : dev_t; // device type
  180. st_atime : time_t; // time of last access
  181. st_atimensec : clong; // nsec of last access
  182. st_mtime : time_t; // time of last data modification
  183. st_mtimensec : clong; // nsec of last data modification
  184. st_ctime : time_t; // time of last file status change
  185. st_ctimensec : clong; // nsec of last file status change
  186. {$ifdef netbsdPowerpc}
  187. st_padd1 : cint;
  188. {$endif}
  189. st_size : off_t; // file size, in bytes
  190. st_blocks : cint64; // blocks allocated for file
  191. st_blksize : cuint32; // optimal blocksize for I/O
  192. st_flags : cuint32; // user defined flags for file
  193. st_gen : cuint32; // file generation number
  194. {$ifdef netbsdPowerpc}
  195. st_padd2 : cint;
  196. {$endif}
  197. {$ifndef NetBSD}
  198. st_lspare : cint32;
  199. {$endif}
  200. st_qspare : array[0..1] Of cint64;
  201. {$endif}
  202. end;
  203. TStat = stat;
  204. pStat = ^stat;
  205. { directory services }
  206. {$if defined(darwin_new_iostructs)}
  207. {$packrecords 4}
  208. { available on Mac OS X 10.6 and later, and used by all iPhoneOS versions }
  209. dirent = record
  210. d_fileno : cuint64; // file number of entry
  211. d_seekoff : cuint64; // seek offset (optional, used by servers)
  212. d_reclen : cuint16; // length of this record
  213. d_namlen : cuint16; // length of string in d_name
  214. d_type : cuint8; // file type, see below
  215. d_name : array[0..PATH_MAX-1] of AnsiChar; // name must be no longer than this
  216. end;
  217. {$packrecords c}
  218. {$elseif defined(dragonfly)}
  219. dirent = record
  220. d_fileno : ino_t; // file number of entry
  221. d_namlen : cuint16; // strlen (d_name)
  222. d_type : cuint8; // file type, see below
  223. d_unused1 : cuint8; // padding, reserved
  224. d_unused2 : cuint32; // reserved
  225. d_name : array[0..255] of AnsiChar; // name, null terminated
  226. end;
  227. {$elseif defined(openbsd)}
  228. dirent = record
  229. d_fileno : ino_t;
  230. d_off : off_t;
  231. d_reclen : cuint16; // length of this record
  232. d_type : cuint8; // file type, see below
  233. d_namlen : cuint8; // length of string in d_name
  234. d_padding : array[0..3] of cuint8;
  235. d_name : array[0..(255 + 1)-1] of AnsiChar; // name must be no longer than this
  236. end;
  237. {$elseif defined(freebsd)}
  238. dirent = record
  239. d_fileno : ino_t;
  240. d_off : off_t;
  241. d_reclen : cuint16; // length of this record
  242. d_type : cuint8; // file type, see below
  243. d_pad0 : cuint8;
  244. d_namlen : cuint16; // length of string in d_name
  245. d_pad1 : cuint16;
  246. d_name : array[0..(255 + 1)-1] of AnsiChar; // name must be no longer than this
  247. end;
  248. {$else}
  249. dirent = record
  250. d_fileno : cuint32; // file number of entry
  251. d_reclen : cuint16; // length of this record
  252. d_type : cuint8; // file type, see below
  253. d_namlen : cuint8; // length of string in d_name
  254. d_name : array[0..(255 + 1)-1] of AnsiChar; // name must be no longer than this
  255. end;
  256. {$endif}
  257. TDirent = dirent;
  258. pDirent = ^dirent;
  259. dir = record
  260. dd_fd : cint; // file descriptor associated with directory
  261. dd_loc : clong; // offset in current buffer
  262. dd_size : clong; // amount of data returned by getdirentries
  263. dd_buf : PAnsiChar; // data buffer
  264. dd_len : cint; // size of data buffer
  265. {$ifdef openbsd}
  266. dd_curpos : off_t;
  267. dd_lock : pointer;
  268. dd_rewind : clong;
  269. {$else not openbsd}
  270. {$ifdef netbsdpowerpc}
  271. dd_pad1 : cint;
  272. dd_seek : cint64; // magic cookie returned by getdirentries
  273. {$else}
  274. dd_seek : clong; // magic cookie returned by getdirentries
  275. {$endif}
  276. dd_rewind : clong; // magic cookie for rewinding
  277. dd_flags : cint; // flags for readdir
  278. {$ifdef darwin}
  279. __dd_lock : pthread_mutex_t; // for thread locking
  280. __dd_td : pointer; // telldir position recording
  281. {$endif}
  282. {$endif not openbsd}
  283. end;
  284. TDir = dir;
  285. pDir = ^dir;
  286. utimbuf = record
  287. actime : time_t;
  288. modtime : time_t;
  289. end;
  290. TUtimBuf = utimbuf;
  291. putimbuf = ^utimbuf;
  292. flock = record
  293. l_start : off_t; { starting offset }
  294. l_len : off_t; { len = 0 means until end of file }
  295. l_pid : pid_t; { lock owner }
  296. l_type : cshort; { lock type: read/write, etc. }
  297. l_whence: cshort; { type of l_start }
  298. {$ifdef freebsd}
  299. l_sysid : cint;
  300. {$endif}
  301. end;
  302. TFlock = flock;
  303. pFlock = ^flock;
  304. tms = record
  305. tms_utime : clock_t; { User CPU time }
  306. tms_stime : clock_t; { System CPU time }
  307. tms_cutime : clock_t; { User CPU time of terminated child procs }
  308. tms_cstime : clock_t; { System CPU time of terminated child procs }
  309. end;
  310. TTms= tms;
  311. pTms= ^tms;
  312. TFDSetEl = Cardinal;
  313. TFDSet = ARRAY[0..(FD_MAXFDSET div 32)-1] of TFDSetEl;
  314. pFDSet = ^TFDSet;
  315. {***********************************************************************}
  316. { POSIX CONSTANT ROUTINE DEFINITIONS }
  317. {***********************************************************************}
  318. CONST
  319. { access routine - these maybe OR'ed together }
  320. F_OK = 0; { test for existence of file }
  321. R_OK = 4; { test for read permission on file }
  322. W_OK = 2; { test for write permission on file }
  323. X_OK = 1; { test for execute or search permission }
  324. { seek routine }
  325. SEEK_SET = 0; { seek from beginning of file }
  326. SEEK_CUR = 1; { seek from current position }
  327. SEEK_END = 2; { seek from end of file }
  328. { open routine }
  329. { File access modes for `open' and `fcntl'. }
  330. O_RDONLY = 0; { Open read-only. }
  331. O_WRONLY = 1; { Open write-only. }
  332. O_RDWR = 2; { Open read/write. }
  333. { Bits OR'd into the second argument to open. }
  334. O_CREAT = $200; { Create file if it doesn't exist. }
  335. O_EXCL = $800; { Fail if file already exists. }
  336. O_TRUNC = $400; { Truncate file to zero length. }
  337. O_NOCTTY = $8000; { Don't assign a controlling terminal. }
  338. { File status flags for `open' and `fcntl'. }
  339. O_APPEND = 8; { Writes append to the file. }
  340. O_NONBLOCK = 4; { Non-blocking I/O. }
  341. {$if defined(freebsd) or defined(dragonfly)}
  342. { Other }
  343. O_SHLOCK = $10; { Open with shared file lock }
  344. O_EXLOCK = $20; { Open with exclusive file lock }
  345. O_ASYNC = $40; { Signal pgrp when data ready }
  346. O_FSYNC = $80; { Synchronous writes }
  347. O_SYNC = $80; { POSIX synonym for O_FSYNC }
  348. O_NOFOLLOW = $100; { Don't follow symlinks }
  349. O_DIRECT =$10000; { Attempt to bypass buffer cache }
  350. {$endif}
  351. { mode_t possible values }
  352. S_IRUSR = %0100000000; { Read permission for owner }
  353. S_IWUSR = %0010000000; { Write permission for owner }
  354. S_IXUSR = %0001000000; { Exec permission for owner }
  355. S_IRGRP = %0000100000; { Read permission for group }
  356. S_IWGRP = %0000010000; { Write permission for group }
  357. S_IXGRP = %0000001000; { Exec permission for group }
  358. S_IROTH = %0000000100; { Read permission for world }
  359. S_IWOTH = %0000000010; { Write permission for world }
  360. S_IXOTH = %0000000001; { Exec permission for world }
  361. S_IRWXU = S_IRUSR or S_IWUSR or S_IXUSR;
  362. S_IRWXG = S_IRGRP or S_IWGRP or S_IXGRP;
  363. S_IRWXO = S_IROTH or S_IWOTH or S_IXOTH;
  364. { Used for waitpid }
  365. WNOHANG = 1; { don't block waiting }
  366. WUNTRACED = 2; { report status of stopped children }
  367. { For File control mechanism }
  368. F_DupFd = 0; { duplicate file descriptor }
  369. F_GetFd = 1; { get file descriptor flags }
  370. F_SetFd = 2; { set file descriptor flags }
  371. F_GetFl = 3; { get file status flags }
  372. F_SetFl = 4; { set file status flags }
  373. F_GetOwn = 5; { get SIGIO/SIGURG proc/pgrp }
  374. F_SetOwn = 6; { set SIGIO/SIGURG proc/pgrp }
  375. {$ifdef freebsd}
  376. F_OGetLk = 7; { get record locking information }
  377. F_OSetLk = 8; { set record locking information }
  378. F_OSetLkW = 9; { F_SETLK; wait if blocked }
  379. F_Dup2Fd = 10; { duplicate file descriptor to arg }
  380. F_GetLk = 11; { get record locking information}
  381. F_SetLk = 12; { set record locking information }
  382. F_SetLkW = 13; { F_SETLK; wait if blocked }
  383. F_SetLkRemote = 14; { debugging support for remote locks }
  384. {$endif}
  385. {$ifdef dragonfly}
  386. F_GetLk = 7; { get record locking information}
  387. F_SetLk = 8; { set record locking information }
  388. F_SetLkW = 9; { F_SETLK; wait if blocked }
  389. F_Dup2Fd = 10; { duplicate file descriptor to arg }
  390. F_DupFd_CloExec = 17; { close on exec duplicated fd }
  391. {$endif}
  392. {$ifdef netbsd}
  393. F_GetLk = 7; { get record locking information}
  394. F_SetLk = 8; { set record locking information }
  395. F_SetLkW = 9; { F_SETLK; wait if blocked }
  396. F_CloseM = 10; { close all fds >= to the one given }
  397. F_MaxFd = 11; { return the max open fd }
  398. F_DupFd_CloExec = 12; { close on exec duplicated fd }
  399. {$endif}
  400. {$ifdef openbsd}
  401. F_GetLk = 7; { get record locking information}
  402. F_SetLk = 8; { set record locking information }
  403. F_SetLkW = 9; { F_SETLK; wait if blocked }
  404. F_DupFd_CloExec = 10; { duplicate with FD_CLOEXEC set }
  405. {$endif}
  406. {$ifdef darwin}
  407. F_GetLk = 7; { get record locking information}
  408. F_SetLk = 8; { set record locking information }
  409. F_SetLkW = 9; { F_SETLK; wait if blocked }
  410. {$endif}
  411. { File descriptor flags (F_GETFD, F_SETFD) }
  412. FD_CLOEXEC = 1; { close-on-exec flag }
  413. { Record locking flags (F_GETLK, F_SETLK, F_SETLKW) }
  414. F_RDLCK = 1; { shared or read lock }
  415. F_UNLCK = 2; { unlock }
  416. F_WRLCK = 3; { exclusive or write lock }
  417. {$ifdef freebsd}
  418. F_UNLCKSYS = 4; { purge locks for a given system ID }
  419. F_CANCEL = 5; { cancel an async lock request }
  420. {$endif}
  421. {$ifndef darwin}
  422. F_WAIT = $10; { Wait until lock is granted }
  423. F_FLOCK = $20; { Use flock(2) semantics for lock }
  424. F_POSIX = $40; { Use POSIX semantics for lock }
  425. {$endif}
  426. {$ifdef freebsd}
  427. F_REMOTE = $80; { Lock owner is remote NFS client }
  428. F_NOINTR = $100; { Ignore signals when waiting }
  429. {$endif}
  430. {$ifdef darwin}
  431. F_CHKCLEAN = 41; { Used for regression test }
  432. F_PREALLOCATE = 42; { Preallocate storage }
  433. F_SETSIZE = 43; { Truncate a file without zeroing space }
  434. F_RDADVISE = 44; { Issue an advisory read async with no copy to user }
  435. F_RDAHEAD = 45; { turn read ahead off/on }
  436. F_READBOOTSTRAP = 46; { Read bootstrap from disk }
  437. F_WRITEBOOTSTRAP = 47; { Write bootstrap on disk }
  438. F_NOCACHE = 48; { turning data caching off/on }
  439. F_LOG2PHYS = 49; { file offset to device offset }
  440. F_GETPATH = 50; { return the full path of the fd }
  441. F_FULLFSYNC = 51; { fsync + ask the drive to flush to the media }
  442. F_PATHPKG_CHECK = 52; { find which component (if any) is a package }
  443. F_FREEZE_FS = 53; { "freeze" all fs operations }
  444. F_THAW_FS = 54; { "thaw" all fs operations }
  445. F_GLOBAL_NOCACHE = 55; { turn data caching off/on (globally) for this file }
  446. {$endif}
  447. type
  448. timezone = record
  449. tz_minuteswest,
  450. tz_dsttime : cint;
  451. end;
  452. ptimezone =^timezone;
  453. TTimeZone = timezone;
  454. rusage = record
  455. ru_utime : timeval; { user time used }
  456. ru_stime : timeval; { system time used }
  457. ru_maxrss : clong; { max resident set size }
  458. ru_ixrss : clong; { integral shared memory size }
  459. ru_idrss : clong; { integral unshared data " }
  460. ru_isrss : clong; { integral unshared stack " }
  461. ru_minflt : clong; { page reclaims }
  462. ru_majflt : clong; { page faults }
  463. ru_nswap : clong; { swaps }
  464. ru_inblock : clong; { block input operations }
  465. ru_oublock : clong; { block output operations }
  466. ru_msgsnd : clong; { messages sent }
  467. ru_msgrcv : clong; { messages received }
  468. ru_nsignals : clong; { signals received }
  469. ru_nvcsw : clong; { voluntary context switches }
  470. ru_nivcsw : clong; { involuntary " }
  471. end;
  472. // #define ru_last ru_nivcsw
  473. // #define ru_first ru_ixrss
  474. Const
  475. S_IFMT = &170000;
  476. S_IFIFO = &10000;
  477. S_IFCHR = &20000;
  478. S_IFDIR = &40000;
  479. S_IFBLK = &60000;
  480. S_IFREG = &100000;
  481. S_IFLNK = &120000;
  482. S_IFSOCK= &140000;
  483. S_IFWHT = &160000;
  484. S_ISUID = &4000;
  485. S_ISGID = &2000;
  486. S_ISVTX = &1000;
  487. {
  488. * Resource limits from FreeBSD5. To be checked for the others.
  489. }
  490. RLIMIT_CPU = 0; { cpu time in milliseconds }
  491. RLIMIT_FSIZE = 1; { maximum file size }
  492. RLIMIT_DATA = 2; { data size }
  493. RLIMIT_STACK = 3; { stack size }
  494. RLIMIT_CORE = 4; { core file size }
  495. RLIMIT_RSS = 5; { resident set size }
  496. RLIMIT_MEMLOCK = 6; { locked-in-memory address space }
  497. RLIMIT_NPROC = 7; { number of processes }
  498. RLIMIT_NOFILE = 8; { number of open files }
  499. {$if defined(freebsd) or defined(dragonfly)}
  500. RLIMIT_SBSIZE = 9; { maximum size of all socket buffers }
  501. RLIMIT_VMEM =10; { virtual process size (inclusive of mmap) }
  502. RLIMIT_AS = RLIMIT_VMEM;
  503. {$ELSE}
  504. RLIMIT_AS = 5; { address space= resident set size}
  505. {$ENDIF}
  506. {$ifdef FreeBSD}
  507. RLIM_NLIMITS =11; { number of resource limits }
  508. {$endif}
  509. {$ifdef dragonfly}
  510. RLIM_NLIMITS =12; { number of resource limits }
  511. {$endif}
  512. {$ifdef Darwin} // OS X 10.3
  513. RLIM_NLIMITS =9; { number of resource limits }
  514. {$endif}
  515. Type
  516. TRLimit = record
  517. rlim_cur, { current (soft) limit }
  518. rlim_max : TRLim; { maximum value for rlim_cur }
  519. end;
  520. PRLimit = ^TRLimit;
  521. iovec = record
  522. iov_base : pointer;
  523. iov_len : size_t;
  524. end;
  525. tiovec=iovec;
  526. piovec=^tiovec;
  527. CONST
  528. { Constansts for MMAP }
  529. {$ifdef FPC_IS_SYSTEM}
  530. MAP_PRIVATE =2;
  531. {$endif}
  532. MAP_ANONYMOUS =$1000;
  533. const
  534. POLLIN = $0001;
  535. POLLPRI = $0002;
  536. POLLOUT = $0004;
  537. POLLERR = $0008;
  538. POLLHUP = $0010;
  539. POLLNVAL = $0020;
  540. { XOpen, XPG 4.2 }
  541. POLLRDNORM = $0040;
  542. POLLRDBAND = $0080;
  543. POLLWRNORM = POLLOUT;
  544. POLLWRBAND = $0100;
  545. type
  546. pollfd = record
  547. fd: cint;
  548. events: cshort;
  549. revents: cshort;
  550. end;
  551. tpollfd = pollfd;
  552. ppollfd = ^pollfd;
  553. {*************************************************************************}
  554. { SIGNALS }
  555. {*************************************************************************}
  556. {$i signal.inc}
  557. type
  558. TTimespecArr = array[0..1] of ttimespec;