ostypes.inc 13 KB

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