2
0

ostypes.inc 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. {
  2. Copyright (c) 2000-2002 by Marco van de Voort
  3. Some non POSIX BSD types used internally in the system unit.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  15. MA 02110-1301, USA.
  16. ****************************************************************************
  17. }
  18. {***********************************************************************}
  19. { POSIX STRUCTURES }
  20. {***********************************************************************}
  21. {$ifdef FPC_IS_SYSTEM}
  22. {$i ptypes.inc}
  23. {$ENDIF}
  24. Type
  25. timezone = packed record
  26. tz_minuteswest,tz_dsttime:cint;
  27. end;
  28. ptimezone =^timezone;
  29. TTimeZone = timezone;
  30. rusage = packed record
  31. ru_utime : timeval; { user time used }
  32. ru_stime : timeval; { system time used }
  33. ru_maxrss : clong; { max resident set size }
  34. ru_ixrss : clong; { integral shared memory size }
  35. ru_idrss : clong; { integral unshared data " }
  36. ru_isrss : clong; { integral unshared stack " }
  37. ru_minflt : clong; { page reclaims }
  38. ru_majflt : clong; { page faults }
  39. ru_nswap : clong; { swaps }
  40. ru_inblock : clong; { block input operations }
  41. ru_oublock : clong; { block output operations }
  42. ru_msgsnd : clong; { messages sent }
  43. ru_msgrcv : clong; { messages received }
  44. ru_nsignals : clong; { signals received }
  45. ru_nvcsw : clong; { voluntary context switches }
  46. ru_nivcsw : clong; { involuntary " }
  47. end;
  48. // #define ru_last ru_nivcsw
  49. // #define ru_first ru_ixrss
  50. { auto generated by a c prog, statmacr.c}
  51. Const
  52. S_IFMT = &0000170000;
  53. S_IFLNK = &0000120000;
  54. S_IFREG = &0000100000;
  55. S_IFBLK = &0000060000;
  56. S_IFDIR = &0000040000;
  57. S_IFCHR = &0000020000;
  58. S_IFIFO = &0000010000;
  59. S_IFSOCK= &0000000000; // not defined under BeOS
  60. S_IFWHT = &0000000000; // not defined under BeOS
  61. S_ISVTX = &1000;
  62. // CONST SYS_NMLN=32;
  63. // Can't find these two in Posix and in BeOS
  64. //CONST
  65. // _UTSNAME_LENGTH = ;
  66. // _UTSNAME_NODENAME_LENGTH = ;
  67. CONST // OS specific parameters for general<fd,sig>set behaviour
  68. BITSINWORD = 8*sizeof(longint);
  69. // SIG_MAXSIG = 32; //128; // highest signal version
  70. FD_MAXFDSET = 1024;
  71. // wordsinsigset = 4; // words in sigset_t
  72. ln2bitsinword = 5; { 32bit : ln(32)/ln(2)=5 }
  73. ln2bitmask = 2 shl ln2bitsinword - 1;
  74. wordsinfdset = FD_MAXFDSET DIV BITSINWORD; // words in fdset_t
  75. wordsinsigset = SIG_MAXSIG DIV BITSINWORD;
  76. TYPE
  77. { system information services }
  78. utsname = record
  79. sysname : Array[0..SYS_NMLN-1] OF Char; // Name of this OS
  80. nodename: Array[0..SYS_NMLN-1] OF Char; // Name of this network node.
  81. release : Array[0..SYS_NMLN-1] OF Char; // Release level.
  82. version : Array[0..SYS_NMLN-1] OF Char; // Version level.
  83. machine : Array[0..SYS_NMLN-1] OF Char; // Hardware type.
  84. end;
  85. TUtsName= utsname;
  86. pUtsName= ^utsname;
  87. { file characteristics services }
  88. (* stat = record { the types are real}
  89. st_dev : dev_t; // inode's device
  90. st_ino : ino_t; // inode's number
  91. st_mode : mode_t; // inode protection mode
  92. st_nlink : nlink_t; // number of hard links
  93. st_uid : uid_t; // user ID of the file's owner
  94. st_gid : gid_t; // group ID of the file's group
  95. st_rdev : dev_t; // device type
  96. st_atime : time_t; // time of last access
  97. st_atimensec : clong; // nsec of last access
  98. st_mtime : time_t; // time of last data modification
  99. st_mtimensec : clong; // nsec of last data modification
  100. st_ctime : time_t; // time of last file status change
  101. st_ctimensec : clong; // nsec of last file status change
  102. {$ifdef netbsdPowerpc}
  103. st_padd1 : cint;
  104. {$endif}
  105. st_size : off_t; // file size, in bytes
  106. st_blocks : cint64; // blocks allocated for file
  107. st_blksize : cuint32; // optimal blocksize for I/O
  108. st_flags : cuint32; // user defined flags for file
  109. st_gen : cuint32; // file generation number
  110. {$ifdef netbsdPowerpc}
  111. st_padd2 : cint;
  112. {$endif}
  113. {$ifndef NetBSD}
  114. st_lspare : cint32;
  115. {$endif}
  116. st_qspare : array[0..1] Of cint64;
  117. end;*)
  118. stat = packed record
  119. dev:longint; {"device" that this file resides on}
  120. ino:int64; {this file's inode #, unique per device}
  121. st_mode:dword; {mode bits (rwx for user, group, etc)}
  122. nlink:longint; {number of hard links to this file}
  123. uid:dword; {user id of the owner of this file}
  124. gid:dword; {group id of the owner of this file}
  125. st_size:int64; {size of this file (in bytes)}
  126. rdev:longint; {device type (not used)}
  127. blksize:longint; {preferref block size for i/o}
  128. atime:longint; {last access time}
  129. st_mtime:longint; {last modification time}
  130. ctime:longint; {last change time, not creation time}
  131. crtime:longint; {creation time}
  132. end;
  133. TStat = stat;
  134. pStat = ^stat;
  135. { directory services }
  136. dirent = packed record
  137. d_dev:longint;
  138. d_pdev:longint;
  139. d_ino:int64;
  140. d_pino:int64;
  141. d_reclen:word;
  142. d_name:array[0..255] of char;
  143. end;
  144. (* dirent = record
  145. d_dev : dev_t;
  146. d_pdev : dev_t;
  147. d_ino : ino_t;
  148. d_pino : ino_t;
  149. d_reclen : word;
  150. d_name : Char;
  151. // d_fileno : cuint32; // file number of entry
  152. // d_reclen : cuint16; // length of this record
  153. // d_type : cuint8; // file type, see below
  154. // d_namlen : cuint8; // length of string in d_name
  155. // d_name : array[0..(255 + 1)-1] of char; // name must be no longer than this
  156. end;*)
  157. TDirent = dirent;
  158. pDirent = ^dirent;
  159. dir = packed record
  160. fd : cint; // file descriptor associated with directory
  161. ent : dirent;
  162. // dd_loc : clong; // offset in current buffer
  163. // dd_size : clong; // amount of data returned by getdirentries
  164. // dd_buf : pchar; // data buffer
  165. // dd_len : cint; // size of data buffer
  166. {$ifdef netbsdpowerpc}
  167. // dd_pad1 : cint;
  168. // dd_seek : cint64; // magic cookie returned by getdirentries
  169. {$else}
  170. // dd_seek : clong; // magic cookie returned by getdirentries
  171. {$endif}
  172. // dd_rewind : clong; // magic cookie for rewinding
  173. // dd_flags : cint; // flags for readdir
  174. end;
  175. TDir = dir;
  176. pDir = ^dir;
  177. utimbuf = record
  178. actime : time_t;
  179. modtime : time_t;
  180. end;
  181. TUtimBuf = utimbuf;
  182. putimbuf = ^utimbuf;
  183. flock = record
  184. l_start : off_t; { starting offset }
  185. l_len : off_t; { len = 0 means until end of file }
  186. l_pid : pid_t; { lock owner }
  187. l_type : cshort; { lock type: read/write, etc. }
  188. l_whence: cshort; { type of l_start }
  189. end;
  190. TFlock = flock;
  191. pFlock = ^flock;
  192. tms = packed record
  193. tms_utime : clock_t; { User CPU time }
  194. tms_stime : clock_t; { System CPU time }
  195. tms_cutime : clock_t; { User CPU time of terminated child procs }
  196. tms_cstime : clock_t; { System CPU time of terminated child procs }
  197. end;
  198. TTms= tms;
  199. pTms= ^tms;
  200. TFDSetEl = Cardinal;
  201. TFDSet = ARRAY[0..(FD_MAXFDSET div 32)-1] of TFDSetEl;
  202. pFDSet = ^TFDSet;
  203. {***********************************************************************}
  204. { POSIX CONSTANT ROUTINE DEFINITIONS }
  205. {***********************************************************************}
  206. CONST
  207. { access routine - these maybe OR'ed together }
  208. F_OK = 0; { test for existence of file }
  209. R_OK = 4; { test for read permission on file }
  210. W_OK = 2; { test for write permission on file }
  211. X_OK = 1; { test for execute or search permission }
  212. { seek routine }
  213. SEEK_SET = 0; { seek from beginning of file }
  214. SEEK_CUR = 1; { seek from current position }
  215. SEEK_END = 2; { seek from end of file }
  216. { open routine }
  217. { File access modes for `open' and `fcntl'. }
  218. O_RDONLY = 0; { Open read-only. }
  219. O_WRONLY = 1; { Open write-only. }
  220. O_RDWR = 2; { Open read/write. }
  221. { Bits OR'd into the second argument to open. }
  222. O_CREAT = $200; { Create file if it doesn't exist. }
  223. O_EXCL = $100; { Fail if file already exists. }
  224. O_TRUNC = $400; { Truncate file to zero length. }
  225. O_NOCTTY = $1000; { Don't assign a controlling terminal. }
  226. { File status flags for `open' and `fcntl'. }
  227. O_APPEND = $800; { Writes append to the file. }
  228. O_NONBLOCK = $0080; { Non-blocking I/O. }
  229. { mode_t possible values }
  230. S_IRUSR = %0100000000; { Read permission for owner }
  231. S_IWUSR = %0010000000; { Write permission for owner }
  232. S_IXUSR = %0001000000; { Exec permission for owner }
  233. S_IRGRP = %0000100000; { Read permission for group }
  234. S_IWGRP = %0000010000; { Write permission for group }
  235. S_IXGRP = %0000001000; { Exec permission for group }
  236. S_IROTH = %0000000100; { Read permission for world }
  237. S_IWOTH = %0000000010; { Write permission for world }
  238. S_IXOTH = %0000000001; { Exec permission for world }
  239. { Used for waitpid }
  240. WNOHANG = 1; { don't block waiting }
  241. WUNTRACED = 2; { report status of stopped children }
  242. Type
  243. TRLimit = record
  244. rlim_cur, { current (soft) limit }
  245. rlim_max : TRLim; { maximum value for rlim_cur }
  246. end;
  247. PRLimit = ^TRLimit;
  248. iovec = record
  249. iov_base : pointer;
  250. iov_len : size_t;
  251. end;
  252. tiovec=iovec;
  253. piovec=^tiovec;
  254. {*************************************************************************}
  255. { SIGNALS }
  256. {*************************************************************************}
  257. {$i signal.inc}
  258. // BeOS types
  259. { ------------------------- Images --------------------------- }
  260. type
  261. // Descriptive formats
  262. status_t = Longint;
  263. area_id = Longint;
  264. port_id = Longint;
  265. sem_id = Longint;
  266. thread_id = Longint;
  267. team_id = Longint;
  268. bigtime_t = int64;
  269. image_id = longint;
  270. {/* commands that can be passed to fcntl */
  271. #define F_DUPFD 0x0001
  272. #define F_GETFD 0x0002
  273. #define F_SETFD 0x0004
  274. #define F_GETFL 0x0008
  275. #define F_SETFL 0x0010
  276. #define F_GETLK 0x0020
  277. #define F_RDLCK 0x0040
  278. #define F_SETLK 0x0080
  279. #define F_SETLKW 0x0100
  280. #define F_UNLCK 0x0200
  281. #define F_WRLCK 0x0400
  282. }
  283. const
  284. F_DUPFD = $0001;
  285. F_GETFD = $0002;
  286. F_SETFD = $0004;
  287. F_GETFL = $0008;
  288. F_SETFL = $0010;
  289. F_GETLK = $0020;
  290. F_RDLCK = $0040;
  291. F_SETLK = $0080;
  292. F_SETLKW = $0100;
  293. F_UNLCK = $0200;
  294. F_WRLCK = $0400;
  295. { image types }
  296. const
  297. B_APP_IMAGE = 1;
  298. B_LIBRARY_IMAGE = 2;
  299. B_ADD_ON_IMAGE = 3;
  300. B_SYSTEM_IMAGE = 4;
  301. type
  302. image_info = packed record
  303. id : image_id;
  304. _type : longint;
  305. sequence: longint;
  306. init_order: longint;
  307. init_routine: pointer;
  308. term_routine: pointer;
  309. device: dev_t;
  310. node: ino_t;
  311. name: array[0..1024{MAXPATHLEN}-1] of char;
  312. { name: string[255];
  313. name2: string[255];
  314. name3: string[255];
  315. name4: string[255];
  316. name5: string[5];
  317. }
  318. text: pointer;
  319. data: pointer;
  320. text_size: longint;
  321. data_size: longint;
  322. end;
  323. (*----- symbol types and functions ------------------------*)
  324. const B_SYMBOL_TYPE_DATA = $1;
  325. const B_SYMBOL_TYPE_TEXT = $2;
  326. const B_SYMBOL_TYPE_ANY = $5;
  327. { Constansts for MMAP }
  328. const
  329. MAP_ANONYMOUS =$1000;
  330. const
  331. POLLIN = $0001;
  332. POLLOUT = $0002;
  333. POLLERR = $0004;
  334. POLLPRI = $0020;
  335. POLLHUP = $0080;
  336. POLLNVAL = $1000;
  337. { XOpen, XPG 4.2 }
  338. POLLRDNORM = POLLIN;
  339. POLLRDBAND = $0008;
  340. POLLWRNORM = POLLOUT;
  341. POLLWRBAND = $0010;
  342. type
  343. pollfd = record
  344. fd: cint;
  345. events: cshort;
  346. revents: cshort;
  347. end;
  348. tpollfd = pollfd;
  349. ppollfd = ^pollfd;