ostypes.inc 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  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. {$packrecords c}
  88. { file characteristics services }
  89. stat = record { the types are real}
  90. st_dev : dev_t; // inode's device
  91. st_ino : ino_t; // inode's number
  92. st_mode : mode_t; // inode protection mode
  93. st_nlink : nlink_t; // number of hard links
  94. st_uid : uid_t; // user ID of the file's owner
  95. st_gid : gid_t; // group ID of the file's group
  96. st_size : off_t; // file size, in bytes
  97. st_rdev : dev_t; // device type
  98. st_blksize : cint32; // optimal blocksize for I/O
  99. st_atime : time_t; // time of last access
  100. st_atimensec : clong; // nsec of last access
  101. st_mtime : time_t; // time of last data modification
  102. st_mtimensec : clong; // nsec of last data modification
  103. st_ctime : time_t; // time of last file status change
  104. st_ctimensec : clong; // nsec of last file status change
  105. st_crtime : time_t; // time of creation file
  106. st_crtimensec : clong; // nsec of creation file
  107. st_type : cint; // attribute/index type
  108. st_blocks : fsblkcnt_t; // blocks allocated for file
  109. end;
  110. TStat = stat;
  111. pStat = ^stat;
  112. { directory services }
  113. dirent = record
  114. d_dev : dev_t;
  115. d_pdev : dev_t;
  116. d_ino : ino_t;
  117. d_pino : ino_t;
  118. d_reclen : cushort;
  119. d_name:array[0..255] of char;
  120. end;
  121. (* dirent = record
  122. d_dev : dev_t;
  123. d_pdev : dev_t;
  124. d_ino : ino_t;
  125. d_pino : ino_t;
  126. d_reclen : word;
  127. d_name : Char;
  128. // d_fileno : cuint32; // file number of entry
  129. // d_reclen : cuint16; // length of this record
  130. // d_type : cuint8; // file type, see below
  131. // d_namlen : cuint8; // length of string in d_name
  132. // d_name : array[0..(255 + 1)-1] of char; // name must be no longer than this
  133. end;*)
  134. TDirent = dirent;
  135. pDirent = ^dirent;
  136. dir = packed record
  137. fd : cint; // file descriptor associated with directory
  138. ent : dirent;
  139. // dd_loc : clong; // offset in current buffer
  140. // dd_size : clong; // amount of data returned by getdirentries
  141. // dd_buf : pchar; // data buffer
  142. // dd_len : cint; // size of data buffer
  143. {$ifdef netbsdpowerpc}
  144. // dd_pad1 : cint;
  145. // dd_seek : cint64; // magic cookie returned by getdirentries
  146. {$else}
  147. // dd_seek : clong; // magic cookie returned by getdirentries
  148. {$endif}
  149. // dd_rewind : clong; // magic cookie for rewinding
  150. // dd_flags : cint; // flags for readdir
  151. end;
  152. TDir = dir;
  153. pDir = ^dir;
  154. utimbuf = record
  155. actime : time_t;
  156. modtime : time_t;
  157. end;
  158. TUtimBuf = utimbuf;
  159. putimbuf = ^utimbuf;
  160. flock = record
  161. l_start : off_t; { starting offset }
  162. l_len : off_t; { len = 0 means until end of file }
  163. l_pid : pid_t; { lock owner }
  164. l_type : cshort; { lock type: read/write, etc. }
  165. l_whence: cshort; { type of l_start }
  166. end;
  167. TFlock = flock;
  168. pFlock = ^flock;
  169. tms = packed record
  170. tms_utime : clock_t; { User CPU time }
  171. tms_stime : clock_t; { System CPU time }
  172. tms_cutime : clock_t; { User CPU time of terminated child procs }
  173. tms_cstime : clock_t; { System CPU time of terminated child procs }
  174. end;
  175. TTms= tms;
  176. pTms= ^tms;
  177. TFDSetEl = Cardinal;
  178. TFDSet = ARRAY[0..(FD_MAXFDSET div 32)-1] of TFDSetEl;
  179. pFDSet = ^TFDSet;
  180. {***********************************************************************}
  181. { POSIX CONSTANT ROUTINE DEFINITIONS }
  182. {***********************************************************************}
  183. CONST
  184. { access routine - these maybe OR'ed together }
  185. F_OK = 0; { test for existence of file }
  186. R_OK = 4; { test for read permission on file }
  187. W_OK = 2; { test for write permission on file }
  188. X_OK = 1; { test for execute or search permission }
  189. { seek routine }
  190. SEEK_SET = 0; { seek from beginning of file }
  191. SEEK_CUR = 1; { seek from current position }
  192. SEEK_END = 2; { seek from end of file }
  193. { open routine }
  194. { File access modes for `open' and `fcntl'. }
  195. O_RDONLY = 0; { Open read-only. }
  196. O_WRONLY = 1; { Open write-only. }
  197. O_RDWR = 2; { Open read/write. }
  198. { Bits OR'd into the second argument to open. }
  199. O_CREAT = $200; { Create file if it doesn't exist. }
  200. O_EXCL = $100; { Fail if file already exists. }
  201. O_TRUNC = $400; { Truncate file to zero length. }
  202. O_NOCTTY = $1000; { Don't assign a controlling terminal. }
  203. { File status flags for `open' and `fcntl'. }
  204. O_APPEND = $800; { Writes append to the file. }
  205. O_NONBLOCK = $0080; { Non-blocking I/O. }
  206. { mode_t possible values }
  207. S_IRUSR = %0100000000; { Read permission for owner }
  208. S_IWUSR = %0010000000; { Write permission for owner }
  209. S_IXUSR = %0001000000; { Exec permission for owner }
  210. S_IRGRP = %0000100000; { Read permission for group }
  211. S_IWGRP = %0000010000; { Write permission for group }
  212. S_IXGRP = %0000001000; { Exec permission for group }
  213. S_IROTH = %0000000100; { Read permission for world }
  214. S_IWOTH = %0000000010; { Write permission for world }
  215. S_IXOTH = %0000000001; { Exec permission for world }
  216. { Used for waitpid }
  217. WNOHANG = 1; { don't block waiting }
  218. WUNTRACED = 2; { report status of stopped children }
  219. Type
  220. TRLimit = record
  221. rlim_cur, { current (soft) limit }
  222. rlim_max : TRLim; { maximum value for rlim_cur }
  223. end;
  224. PRLimit = ^TRLimit;
  225. iovec = record
  226. iov_base : pointer;
  227. iov_len : size_t;
  228. end;
  229. tiovec=iovec;
  230. piovec=^tiovec;
  231. {*************************************************************************}
  232. { SIGNALS }
  233. {*************************************************************************}
  234. {$i signal.inc}
  235. // BeOS types
  236. { ------------------------- Images --------------------------- }
  237. type
  238. // Descriptive formats
  239. status_t = Longint;
  240. area_id = Longint;
  241. port_id = Longint;
  242. sem_id = Longint;
  243. thread_id = Longint;
  244. team_id = Longint;
  245. bigtime_t = int64;
  246. image_id = longint;
  247. {/* commands that can be passed to fcntl */
  248. #define F_DUPFD 0x0001
  249. #define F_GETFD 0x0002
  250. #define F_SETFD 0x0004
  251. #define F_GETFL 0x0008
  252. #define F_SETFL 0x0010
  253. #define F_GETLK 0x0020
  254. #define F_RDLCK 0x0040
  255. #define F_SETLK 0x0080
  256. #define F_SETLKW 0x0100
  257. #define F_UNLCK 0x0200
  258. #define F_WRLCK 0x0400
  259. }
  260. const
  261. F_DUPFD = $0001;
  262. F_GETFD = $0002;
  263. F_SETFD = $0004;
  264. F_GETFL = $0008;
  265. F_SETFL = $0010;
  266. F_GETLK = $0020;
  267. F_RDLCK = $0040;
  268. F_SETLK = $0080;
  269. F_SETLKW = $0100;
  270. F_UNLCK = $0200;
  271. F_WRLCK = $0400;
  272. { image types }
  273. const
  274. B_APP_IMAGE = 1;
  275. B_LIBRARY_IMAGE = 2;
  276. B_ADD_ON_IMAGE = 3;
  277. B_SYSTEM_IMAGE = 4;
  278. type
  279. image_info = packed record
  280. id : image_id;
  281. _type : longint;
  282. sequence: longint;
  283. init_order: longint;
  284. init_routine: pointer;
  285. term_routine: pointer;
  286. device: dev_t;
  287. node: ino_t;
  288. name: array[0..1024{MAXPATHLEN}-1] of char;
  289. { name: string[255];
  290. name2: string[255];
  291. name3: string[255];
  292. name4: string[255];
  293. name5: string[5];
  294. }
  295. text: pointer;
  296. data: pointer;
  297. text_size: longint;
  298. data_size: longint;
  299. end;
  300. (*----- symbol types and functions ------------------------*)
  301. const B_SYMBOL_TYPE_DATA = $1;
  302. const B_SYMBOL_TYPE_TEXT = $2;
  303. const B_SYMBOL_TYPE_ANY = $5;
  304. { Constansts for MMAP }
  305. const
  306. {$ifdef FPC_IS_SYSTEM}
  307. MAP_PRIVATE =2;
  308. {$endif}
  309. MAP_ANONYMOUS =$08;
  310. const
  311. POLLIN = $0001;
  312. POLLOUT = $0002;
  313. POLLERR = $0004;
  314. POLLPRI = $0020;
  315. POLLHUP = $0080;
  316. POLLNVAL = $1000;
  317. { XOpen, XPG 4.2 }
  318. POLLRDNORM = POLLIN;
  319. POLLRDBAND = $0008;
  320. POLLWRNORM = POLLOUT;
  321. POLLWRBAND = $0010;
  322. type
  323. pollfd = record
  324. fd: cint;
  325. events: cshort;
  326. revents: cshort;
  327. end;
  328. tpollfd = pollfd;
  329. ppollfd = ^pollfd;