ostypes.inc 14 KB

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