ostypes.inc 13 KB

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