ostypes.inc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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 = record
  26. tz_minuteswest,tz_dsttime:cint;
  27. end;
  28. ptimezone =^timezone;
  29. TTimeZone = timezone;
  30. rusage = record
  31. ru_utime : timeval; { user time used }
  32. ru_stime : timeval; { system time used }
  33. end;
  34. { auto generated by a c prog, statmacr.c}
  35. Const
  36. S_IFMT = &0000170000;
  37. S_IFLNK = &0000120000;
  38. S_IFREG = &0000100000;
  39. S_IFBLK = &0000060000;
  40. S_IFDIR = &0000040000;
  41. S_IFCHR = &0000020000;
  42. S_IFIFO = &0000010000;
  43. S_IFSOCK= &0000000000; // not defined under BeOS
  44. S_IFWHT = &0000000000; // not defined under BeOS
  45. S_ISUID = &4000; { set user id on execution }
  46. S_ISGID = &2000; { set group id on execution }
  47. S_ISVTX = &1000; { save swapped text even after use (sticky bit) }
  48. // CONST SYS_NMLN=32;
  49. // Can't find these two in Posix and in BeOS
  50. //CONST
  51. // _UTSNAME_LENGTH = ;
  52. // _UTSNAME_NODENAME_LENGTH = ;
  53. CONST // OS specific parameters for general<fd,sig>set behaviour
  54. BITSINWORD = 8*sizeof(longint);
  55. FD_MAXFDSET = 1024;
  56. ln2bitsinword = 5; { 32bit : ln(32)/ln(2)=5 }
  57. ln2bitmask = 2 shl ln2bitsinword - 1;
  58. wordsinfdset = FD_MAXFDSET DIV BITSINWORD; // words in fdset_t
  59. wordsinsigset = SIG_MAXSIG DIV BITSINWORD;
  60. TYPE
  61. { system information services }
  62. utsname = record
  63. sysname : Array[0..SYS_NMLN-1] OF AnsiChar; // Name of this OS
  64. nodename: Array[0..SYS_NMLN-1] OF AnsiChar; // Name of this network node.
  65. release : Array[0..SYS_NMLN-1] OF AnsiChar; // Release level.
  66. version : Array[0..SYS_NMLN-1] OF AnsiChar; // Version level.
  67. machine : Array[0..SYS_NMLN-1] OF AnsiChar; // Hardware type.
  68. end;
  69. TUtsName= utsname;
  70. pUtsName= ^utsname;
  71. {$packrecords c}
  72. { file characteristics services }
  73. stat = record { the types are real}
  74. st_dev : dev_t; // inode's device
  75. st_ino : ino_t; // inode's number
  76. st_mode : mode_t; // inode protection mode
  77. st_nlink : nlink_t; // number of hard links
  78. st_uid : uid_t; // user ID of the file's owner
  79. st_gid : gid_t; // group ID of the file's group
  80. st_size : off_t; // file size, in bytes
  81. st_rdev : dev_t; // device type
  82. st_blksize : cint32; // optimal blocksize for I/O
  83. st_atime : time_t; // time of last access
  84. st_atimensec : clong; // nsec of last access
  85. st_mtime : time_t; // time of last data modification
  86. st_mtimensec : clong; // nsec of last data modification
  87. st_ctime : time_t; // time of last file status change
  88. st_ctimensec : clong; // nsec of last file status change
  89. st_crtime : time_t; // time of creation file
  90. st_crtimensec : clong; // nsec of creation file
  91. st_type : cint; // attribute/index type
  92. st_blocks : fsblkcnt_t; // blocks allocated for file
  93. end;
  94. TStat = stat;
  95. pStat = ^stat;
  96. { directory services }
  97. dirent = record
  98. d_dev : dev_t;
  99. d_pdev : dev_t;
  100. d_ino : ino_t;
  101. d_pino : ino_t;
  102. d_reclen : cushort;
  103. d_name : array[0..255] of AnsiChar;
  104. end;
  105. TDirent = dirent;
  106. pDirent = ^dirent;
  107. dir = record
  108. fd : cint; // file descriptor associated with directory
  109. next_entry : cshort;
  110. entries_left : cushort;
  111. seek_position : clong;
  112. current_position : clong;
  113. first_entry : dirent;
  114. end;
  115. TDir = dir;
  116. pDir = ^dir;
  117. utimbuf = record
  118. actime : time_t;
  119. modtime : time_t;
  120. end;
  121. TUtimBuf = utimbuf;
  122. putimbuf = ^utimbuf;
  123. flock = record
  124. l_type : cshort; { lock type: read/write, etc. }
  125. l_whence : cshort; { type of l_start }
  126. l_start : off_t; { starting offset }
  127. l_len : off_t; { len = 0 means until end of file }
  128. l_pid : pid_t; { lock owner }
  129. end;
  130. TFlock = flock;
  131. pFlock = ^flock;
  132. tms = record
  133. tms_utime : clock_t; { User CPU time }
  134. tms_stime : clock_t; { System CPU time }
  135. tms_cutime : clock_t; { User CPU time of terminated child procs }
  136. tms_cstime : clock_t; { System CPU time of terminated child procs }
  137. end;
  138. TTms= tms;
  139. pTms= ^tms;
  140. type
  141. TFDSetEl = Cardinal;
  142. TFDSet = ARRAY[0..(FD_MAXFDSET div 32)-1] of TFDSetEl;
  143. pFDSet = ^TFDSet;
  144. {***********************************************************************}
  145. { POSIX CONSTANT ROUTINE DEFINITIONS }
  146. {***********************************************************************}
  147. CONST
  148. { access routine - these maybe OR'ed together }
  149. F_OK = 0; { test for existence of file }
  150. R_OK = 4; { test for read permission on file }
  151. W_OK = 2; { test for write permission on file }
  152. X_OK = 1; { test for execute or search permission }
  153. { seek routine }
  154. SEEK_SET = 0; { seek from beginning of file }
  155. SEEK_CUR = 1; { seek from current position }
  156. SEEK_END = 2; { seek from end of file }
  157. { open routine }
  158. { File access modes for `open' and `fcntl'. }
  159. O_RDONLY = 0; { Open read-only. }
  160. O_WRONLY = 1; { Open write-only. }
  161. O_RDWR = 2; { Open read/write. }
  162. { Bits OR'd into the second argument to open. }
  163. O_CREAT = $200; { Create file if it doesn't exist. }
  164. O_EXCL = $100; { Fail if file already exists. }
  165. O_TRUNC = $400; { Truncate file to zero length. }
  166. O_NOCTTY = $1000; { Don't assign a controlling terminal. }
  167. { File status flags for `open' and `fcntl'. }
  168. O_APPEND = $800; { Writes append to the file. }
  169. O_NONBLOCK = $0080; { Non-blocking I/O. }
  170. { mode_t possible values }
  171. S_IRUSR = %0100000000; { Read permission for owner }
  172. S_IWUSR = %0010000000; { Write permission for owner }
  173. S_IXUSR = %0001000000; { Exec permission for owner }
  174. S_IRGRP = %0000100000; { Read permission for group }
  175. S_IWGRP = %0000010000; { Write permission for group }
  176. S_IXGRP = %0000001000; { Exec permission for group }
  177. S_IROTH = %0000000100; { Read permission for world }
  178. S_IWOTH = %0000000010; { Write permission for world }
  179. S_IXOTH = %0000000001; { Exec permission for world }
  180. { Used for waitpid }
  181. WNOHANG = 1; { don't block waiting }
  182. WUNTRACED = 2; { report status of stopped children }
  183. type
  184. TRLimit = record
  185. rlim_cur, { current (soft) limit }
  186. rlim_max : TRLim; { maximum value for rlim_cur }
  187. end;
  188. PRLimit = ^TRLimit;
  189. iovec = record
  190. iov_base : pointer;
  191. iov_len : size_t;
  192. end;
  193. tiovec=iovec;
  194. piovec=^tiovec;
  195. {*************************************************************************}
  196. { SIGNALS }
  197. {*************************************************************************}
  198. {$i signal.inc}
  199. // BeOS types
  200. { ------------------------- Images --------------------------- }
  201. type
  202. // Descriptive formats
  203. status_t = Longint;
  204. area_id = Longint;
  205. port_id = Longint;
  206. sem_id = Longint;
  207. thread_id = Longint;
  208. team_id = Longint;
  209. bigtime_t = int64;
  210. image_id = longint;
  211. {/* commands that can be passed to fcntl */
  212. #define F_DUPFD 0x0001
  213. #define F_GETFD 0x0002
  214. #define F_SETFD 0x0004
  215. #define F_GETFL 0x0008
  216. #define F_SETFL 0x0010
  217. #define F_GETLK 0x0020
  218. #define F_RDLCK 0x0040
  219. #define F_SETLK 0x0080
  220. #define F_SETLKW 0x0100
  221. #define F_UNLCK 0x0200
  222. #define F_WRLCK 0x0400
  223. }
  224. const
  225. F_DUPFD = $0001;
  226. F_GETFD = $0002;
  227. F_SETFD = $0004;
  228. F_GETFL = $0008;
  229. F_SETFL = $0010;
  230. F_GETLK = $0020;
  231. F_RDLCK = $0040;
  232. F_SETLK = $0080;
  233. F_SETLKW = $0100;
  234. F_UNLCK = $0200;
  235. F_WRLCK = $0400;
  236. { image types }
  237. const
  238. B_APP_IMAGE = 1;
  239. B_LIBRARY_IMAGE = 2;
  240. B_ADD_ON_IMAGE = 3;
  241. B_SYSTEM_IMAGE = 4;
  242. type
  243. image_info = record
  244. id: image_id;
  245. _type: longint;
  246. sequence: longint;
  247. init_order: longint;
  248. init_routine: pointer;
  249. term_routine: pointer;
  250. device: dev_t;
  251. node: ino_t;
  252. name: array[0..1024{MAXPATHLEN}-1] of AnsiChar;
  253. text: pointer;
  254. data: pointer;
  255. text_size: longint;
  256. data_size: longint;
  257. end;
  258. (*----- symbol types and functions ------------------------*)
  259. const B_SYMBOL_TYPE_DATA = $1;
  260. const B_SYMBOL_TYPE_TEXT = $2;
  261. const B_SYMBOL_TYPE_ANY = $5;
  262. { Constansts for MMAP }
  263. const
  264. {$ifdef FPC_IS_SYSTEM}
  265. MAP_PRIVATE =2;
  266. {$endif}
  267. MAP_ANONYMOUS =$08;
  268. const
  269. POLLIN = $0001;
  270. POLLOUT = $0002;
  271. POLLERR = $0004;
  272. POLLPRI = $0020;
  273. POLLHUP = $0080;
  274. POLLNVAL = $1000;
  275. { XOpen, XPG 4.2 }
  276. POLLRDNORM = POLLIN;
  277. POLLRDBAND = $0008;
  278. POLLWRNORM = POLLOUT;
  279. POLLWRBAND = $0010;
  280. type
  281. pollfd = record
  282. fd: cint;
  283. events: cshort;
  284. revents: cshort;
  285. end;
  286. tpollfd = pollfd;
  287. ppollfd = ^pollfd;
  288. type
  289. TTimespecArr = array[0..1] of ttimespec;