ostypes.inc 10 KB

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