ostypes.inc 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2002 Marco van de Voort
  4. member of the Free Pascal development team.
  5. Some non POSIX BSD types used internally in the system unit.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  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.
  11. **********************************************************************}
  12. {***********************************************************************}
  13. { POSIX STRUCTURES }
  14. {***********************************************************************}
  15. {$ifdef FPC_IS_SYSTEM}
  16. {$i ptypes.inc}
  17. {$ENDIF}
  18. Type
  19. timezone = packed record
  20. tz_minuteswest,tz_dsttime:cint;
  21. end;
  22. ptimezone =^timezone;
  23. TTimeZone = timezone;
  24. rusage = packed record
  25. ru_utime : timeval; { user time used }
  26. ru_stime : timeval; { system time used }
  27. ru_maxrss : clong; { max resident set size }
  28. ru_ixrss : clong; { integral shared memory size }
  29. ru_idrss : clong; { integral unshared data " }
  30. ru_isrss : clong; { integral unshared stack " }
  31. ru_minflt : clong; { page reclaims }
  32. ru_majflt : clong; { page faults }
  33. ru_nswap : clong; { swaps }
  34. ru_inblock : clong; { block input operations }
  35. ru_oublock : clong; { block output operations }
  36. ru_msgsnd : clong; { messages sent }
  37. ru_msgrcv : clong; { messages received }
  38. ru_nsignals : clong; { signals received }
  39. ru_nvcsw : clong; { voluntary context switches }
  40. ru_nivcsw : clong; { involuntary " }
  41. end;
  42. // #define ru_last ru_nivcsw
  43. // #define ru_first ru_ixrss
  44. { auto generated by a c prog, statmacr.c}
  45. Const
  46. S_IFMT = &0000170000;
  47. S_IFLNK = &0000120000;
  48. S_IFREG = &0000100000;
  49. S_IFBLK = &0000060000;
  50. S_IFDIR = &0000040000;
  51. S_IFCHR = &0000020000;
  52. S_IFIFO = &0000010000;
  53. S_IFSOCK= &0000000000; // not defined under BeOS
  54. S_IFWHT = &0000000000; // not defined under BeOS
  55. S_ISVTX = &1000;
  56. // CONST SYS_NMLN=32;
  57. // Can't find these two in Posix and in BeOS
  58. //CONST
  59. // _UTSNAME_LENGTH = ;
  60. // _UTSNAME_NODENAME_LENGTH = ;
  61. CONST // OS specific parameters for general<fd,sig>set behaviour
  62. BITSINWORD = 8*sizeof(longint);
  63. // SIG_MAXSIG = 32; //128; // highest signal version
  64. FD_MAXFDSET = 1024;
  65. // wordsinsigset = 4; // words in sigset_t
  66. ln2bitsinword = 5; { 32bit : ln(32)/ln(2)=5 }
  67. ln2bitmask = 2 shl ln2bitsinword - 1;
  68. wordsinfdset = FD_MAXFDSET DIV BITSINWORD; // words in fdset_t
  69. wordsinsigset = SIG_MAXSIG DIV BITSINWORD;
  70. TYPE
  71. { system information services }
  72. utsname = record
  73. sysname : Array[0..SYS_NMLN-1] OF AnsiChar; // Name of this OS
  74. nodename: Array[0..SYS_NMLN-1] OF AnsiChar; // Name of this network node.
  75. release : Array[0..SYS_NMLN-1] OF AnsiChar; // Release level.
  76. version : Array[0..SYS_NMLN-1] OF AnsiChar; // Version level.
  77. machine : Array[0..SYS_NMLN-1] OF AnsiChar; // Hardware type.
  78. end;
  79. TUtsName= utsname;
  80. pUtsName= ^utsname;
  81. { file characteristics services }
  82. (* stat = record { the types are real}
  83. st_dev : dev_t; // inode's device
  84. st_ino : ino_t; // inode's number
  85. st_mode : mode_t; // inode protection mode
  86. st_nlink : nlink_t; // number of hard links
  87. st_uid : uid_t; // user ID of the file's owner
  88. st_gid : gid_t; // group ID of the file's group
  89. st_rdev : dev_t; // device type
  90. st_atime : time_t; // time of last access
  91. st_atimensec : clong; // nsec of last access
  92. st_mtime : time_t; // time of last data modification
  93. st_mtimensec : clong; // nsec of last data modification
  94. st_ctime : time_t; // time of last file status change
  95. st_ctimensec : clong; // nsec of last file status change
  96. {$ifdef netbsdPowerpc}
  97. st_padd1 : cint;
  98. {$endif}
  99. st_size : off_t; // file size, in bytes
  100. st_blocks : cint64; // blocks allocated for file
  101. st_blksize : cuint32; // optimal blocksize for I/O
  102. st_flags : cuint32; // user defined flags for file
  103. st_gen : cuint32; // file generation number
  104. {$ifdef netbsdPowerpc}
  105. st_padd2 : cint;
  106. {$endif}
  107. {$ifndef NetBSD}
  108. st_lspare : cint32;
  109. {$endif}
  110. st_qspare : array[0..1] Of cint64;
  111. end;*)
  112. { https://www.haiku-os.org/legacy-docs/bebook/TheStorageKit_DefinedTypes.html#stat }
  113. stat = packed record
  114. st_dev:longint; {"device" that this file resides on}
  115. st_ino:int64; {this file's inode #, unique per device}
  116. st_mode:dword; {mode bits (rwx for user, group, etc)}
  117. st_nlink:longint; {number of hard links to this file}
  118. st_uid:dword; {user id of the owner of this file}
  119. st_gid:dword; {group id of the owner of this file}
  120. st_size:int64; {size of this file (in bytes)}
  121. st_rdev:longint; {device type (not used)}
  122. st_blksize:longint; {preferref block size for i/o}
  123. st_atime:longint; {last access time}
  124. st_mtime:longint; {last modification time}
  125. st_ctime:longint; {last change time, not creation time}
  126. crtime:longint; {creation time}
  127. end;
  128. TStat = stat;
  129. pStat = ^stat;
  130. { directory services }
  131. dirent = packed record
  132. d_dev:longint;
  133. d_pdev:longint;
  134. d_ino:int64;
  135. d_pino:int64;
  136. d_reclen:word;
  137. d_name:array[0..255] of AnsiChar;
  138. end;
  139. (* dirent = record
  140. d_dev : dev_t;
  141. d_pdev : dev_t;
  142. d_ino : ino_t;
  143. d_pino : ino_t;
  144. d_reclen : word;
  145. d_name : AnsiChar;
  146. // d_fileno : cuint32; // file number of entry
  147. // d_reclen : cuint16; // length of this record
  148. // d_type : cuint8; // file type, see below
  149. // d_namlen : cuint8; // length of string in d_name
  150. // d_name : array[0..(255 + 1)-1] of AnsiChar; // name must be no longer than this
  151. end;*)
  152. TDirent = dirent;
  153. pDirent = ^dirent;
  154. dir = packed record
  155. fd : cint; // file descriptor associated with directory
  156. ent : dirent;
  157. // dd_loc : clong; // offset in current buffer
  158. // dd_size : clong; // amount of data returned by getdirentries
  159. // dd_buf : PAnsiChar; // data buffer
  160. // dd_len : cint; // size of data buffer
  161. {$ifdef netbsdpowerpc}
  162. // dd_pad1 : cint;
  163. // dd_seek : cint64; // magic cookie returned by getdirentries
  164. {$else}
  165. // dd_seek : clong; // magic cookie returned by getdirentries
  166. {$endif}
  167. // dd_rewind : clong; // magic cookie for rewinding
  168. // dd_flags : cint; // flags for readdir
  169. end;
  170. TDir = dir;
  171. pDir = ^dir;
  172. utimbuf = record
  173. actime : time_t;
  174. modtime : time_t;
  175. end;
  176. TUtimBuf = utimbuf;
  177. putimbuf = ^utimbuf;
  178. flock = record
  179. l_start : off_t; { starting offset }
  180. l_len : off_t; { len = 0 means until end of file }
  181. l_pid : pid_t; { lock owner }
  182. l_type : cshort; { lock type: read/write, etc. }
  183. l_whence: cshort; { type of l_start }
  184. end;
  185. TFlock = flock;
  186. pFlock = ^flock;
  187. tms = packed record
  188. tms_utime : clock_t; { User CPU time }
  189. tms_stime : clock_t; { System CPU time }
  190. tms_cutime : clock_t; { User CPU time of terminated child procs }
  191. tms_cstime : clock_t; { System CPU time of terminated child procs }
  192. end;
  193. TTms= tms;
  194. pTms= ^tms;
  195. TFDSetEl = Cardinal;
  196. TFDSet = ARRAY[0..(FD_MAXFDSET div 32)-1] of TFDSetEl;
  197. pFDSet = ^TFDSet;
  198. {***********************************************************************}
  199. { POSIX CONSTANT ROUTINE DEFINITIONS }
  200. {***********************************************************************}
  201. CONST
  202. { access routine - these maybe OR'ed together }
  203. F_OK = 0; { test for existence of file }
  204. R_OK = 4; { test for read permission on file }
  205. W_OK = 2; { test for write permission on file }
  206. X_OK = 1; { test for execute or search permission }
  207. { seek routine }
  208. SEEK_SET = 0; { seek from beginning of file }
  209. SEEK_CUR = 1; { seek from current position }
  210. SEEK_END = 2; { seek from end of file }
  211. { open routine }
  212. { File access modes for `open' and `fcntl'. }
  213. O_RDONLY = 0; { Open read-only. }
  214. O_WRONLY = 1; { Open write-only. }
  215. O_RDWR = 2; { Open read/write. }
  216. { Bits OR'd into the second argument to open. }
  217. O_CREAT = $200; { Create file if it doesn't exist. }
  218. O_EXCL = $100; { Fail if file already exists. }
  219. O_TRUNC = $400; { Truncate file to zero length. }
  220. O_NOCTTY = $1000; { Don't assign a controlling terminal. }
  221. { File status flags for `open' and `fcntl'. }
  222. O_APPEND = $800; { Writes append to the file. }
  223. O_NONBLOCK = $0080; { Non-blocking I/O. }
  224. { mode_t possible values }
  225. S_IRUSR = %0100000000; { Read permission for owner }
  226. S_IWUSR = %0010000000; { Write permission for owner }
  227. S_IXUSR = %0001000000; { Exec permission for owner }
  228. S_IRGRP = %0000100000; { Read permission for group }
  229. S_IWGRP = %0000010000; { Write permission for group }
  230. S_IXGRP = %0000001000; { Exec permission for group }
  231. S_IROTH = %0000000100; { Read permission for world }
  232. S_IWOTH = %0000000010; { Write permission for world }
  233. S_IXOTH = %0000000001; { Exec permission for world }
  234. { The two following modes are not supported on BeOS }
  235. S_ISUID = 0; { set user id on execution }
  236. S_ISGID = 0; { set group id on execution }
  237. { Used for waitpid }
  238. WNOHANG = 1; { don't block waiting }
  239. WUNTRACED = 2; { report status of stopped children }
  240. Type
  241. TRLimit = record
  242. rlim_cur, { current (soft) limit }
  243. rlim_max : TRLim; { maximum value for rlim_cur }
  244. end;
  245. PRLimit = ^TRLimit;
  246. iovec = record
  247. iov_base : pointer;
  248. iov_len : size_t;
  249. end;
  250. tiovec=iovec;
  251. piovec=^tiovec;
  252. {*************************************************************************}
  253. { SIGNALS }
  254. {*************************************************************************}
  255. {$i signal.inc}
  256. // BeOS types
  257. { ------------------------- Images --------------------------- }
  258. type
  259. // Descriptive formats
  260. status_t = Longint;
  261. area_id = Longint;
  262. port_id = Longint;
  263. sem_id = Longint;
  264. thread_id = Longint;
  265. team_id = Longint;
  266. bigtime_t = int64;
  267. image_id = longint;
  268. {/* commands that can be passed to fcntl */
  269. #define F_DUPFD 0x0001
  270. #define F_GETFD 0x0002
  271. #define F_SETFD 0x0004
  272. #define F_GETFL 0x0008
  273. #define F_SETFL 0x0010
  274. #define F_GETLK 0x0020
  275. #define F_RDLCK 0x0040
  276. #define F_SETLK 0x0080
  277. #define F_SETLKW 0x0100
  278. #define F_UNLCK 0x0200
  279. #define F_WRLCK 0x0400
  280. }
  281. const
  282. F_DUPFD = $0001;
  283. F_GETFD = $0002;
  284. F_SETFD = $0004;
  285. F_GETFL = $0008;
  286. F_SETFL = $0010;
  287. F_GETLK = $0020;
  288. F_RDLCK = $0040;
  289. F_SETLK = $0080;
  290. F_SETLKW = $0100;
  291. F_UNLCK = $0200;
  292. F_WRLCK = $0400;
  293. { image types }
  294. const
  295. B_APP_IMAGE = 1;
  296. B_LIBRARY_IMAGE = 2;
  297. B_ADD_ON_IMAGE = 3;
  298. B_SYSTEM_IMAGE = 4;
  299. type
  300. image_info = packed record
  301. id : image_id;
  302. _type : longint;
  303. sequence: longint;
  304. init_order: longint;
  305. init_routine: pointer;
  306. term_routine: pointer;
  307. device: dev_t;
  308. node: ino_t;
  309. name: array[0..1024{MAXPATHLEN}-1] of AnsiChar;
  310. { name: string[255];
  311. name2: string[255];
  312. name3: string[255];
  313. name4: string[255];
  314. name5: string[5];
  315. }
  316. text: pointer;
  317. data: pointer;
  318. text_size: longint;
  319. data_size: longint;
  320. end;
  321. (*----- symbol types and functions ------------------------*)
  322. const B_SYMBOL_TYPE_DATA = $1;
  323. const B_SYMBOL_TYPE_TEXT = $2;
  324. const B_SYMBOL_TYPE_ANY = $5;
  325. { Constansts for MMAP }
  326. const
  327. MAP_ANONYMOUS =$1000;
  328. const
  329. POLLIN = $0001;
  330. POLLOUT = $0002;
  331. POLLERR = $0004;
  332. POLLPRI = $0020;
  333. POLLHUP = $0080;
  334. POLLNVAL = $1000;
  335. { XOpen, XPG 4.2 }
  336. POLLRDNORM = POLLIN;
  337. POLLRDBAND = $0008;
  338. POLLWRNORM = POLLOUT;
  339. POLLWRBAND = $0010;
  340. type
  341. pollfd = record
  342. fd: cint;
  343. events: cshort;
  344. revents: cshort;
  345. end;
  346. tpollfd = pollfd;
  347. ppollfd = ^pollfd;
  348. type
  349. TTimespecArr = array[0..1] of ttimespec;