ostypes.inc 13 KB

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