ostypes.inc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2001 by Free Pascal development team
  4. Types and structures for baseunix unit, also used in system.
  5. This file implements all the types/constants which must
  6. be defined to port FPC to a new POSIX compliant OS.
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. {***********************************************************************}
  14. { POSIX STRUCTURES }
  15. {***********************************************************************}
  16. {$ifdef FPC_IS_SYSTEM}
  17. {$i ptypes.inc}
  18. {$ENDIF}
  19. {$ifdef cpupowerpc}
  20. {$ifdef netbsd}
  21. {$define netbsdpowerpc}
  22. {$endif}
  23. {$endif}
  24. // CONST SYS_NMLN=65;
  25. // Can't find these two in Posix and in FreeBSD
  26. //CONST
  27. // _UTSNAME_LENGTH = ;
  28. // _UTSNAME_NODENAME_LENGTH = ;
  29. CONST // OS specific parameters for general<fd,sig>set behaviour
  30. BITSINWORD = 8*sizeof(longint);
  31. FD_MAXFDSET = 1024;
  32. ln2bitsinword = 5; { 32bit : ln(32)/ln(2)=5 }
  33. ln2bitmask = 1 shl ln2bitsinword - 1;
  34. wordsinfdset = FD_MAXFDSET DIV BITSINWORD; // words in fdset_t
  35. wordsinsigset = SIG_MAXSIG DIV BITSINWORD;
  36. TYPE
  37. { system information services }
  38. utsname = record
  39. sysname : Array[0..SYS_NMLN-1] OF Char; // Name of this OS
  40. nodename: Array[0..SYS_NMLN-1] OF Char; // Name of this network node.
  41. release : Array[0..SYS_NMLN-1] OF Char; // Release level.
  42. version : Array[0..SYS_NMLN-1] OF Char; // Version level.
  43. machine : Array[0..SYS_NMLN-1] OF Char; // Hardware type.
  44. end;
  45. TUtsName= utsname;
  46. pUtsName= ^utsname;
  47. { file characteristics services }
  48. stat = record { the types are real}
  49. st_dev : dev_t; // inode's device
  50. st_ino : ino_t; // inode's number
  51. st_mode : mode_t; // inode protection mode
  52. st_nlink : nlink_t; // number of hard links
  53. st_uid : uid_t; // user ID of the file's owner
  54. st_gid : gid_t; // group ID of the file's group
  55. st_rdev : dev_t; // device type
  56. st_atime : time_t; // time of last access
  57. st_atimensec : clong; // nsec of last access
  58. st_mtime : time_t; // time of last data modification
  59. st_mtimensec : clong; // nsec of last data modification
  60. st_ctime : time_t; // time of last file status change
  61. st_ctimensec : clong; // nsec of last file status change
  62. {$ifdef netbsdPowerpc}
  63. st_padd1 : cint;
  64. {$endif}
  65. st_size : off_t; // file size, in bytes
  66. st_blocks : cint64; // blocks allocated for file
  67. st_blksize : cuint32; // optimal blocksize for I/O
  68. st_flags : cuint32; // user defined flags for file
  69. st_gen : cuint32; // file generation number
  70. {$ifdef netbsdPowerpc}
  71. st_padd2 : cint;
  72. {$endif}
  73. {$ifndef NetBSD}
  74. st_lspare : cint32;
  75. {$endif}
  76. st_qspare : array[0..1] Of cint64;
  77. end;
  78. TStat = stat;
  79. pStat = ^stat;
  80. { directory services }
  81. dirent = record
  82. d_fileno : cuint32; // file number of entry
  83. d_reclen : cuint16; // length of this record
  84. d_type : cuint8; // file type, see below
  85. d_namlen : cuint8; // length of string in d_name
  86. d_name : array[0..(255 + 1)-1] of char; // name must be no longer than this
  87. end;
  88. TDirent = dirent;
  89. pDirent = ^dirent;
  90. dir = packed record
  91. dd_fd : cint; // file descriptor associated with directory
  92. dd_loc : clong; // offset in current buffer
  93. dd_size : clong; // amount of data returned by getdirentries
  94. dd_buf : pchar; // data buffer
  95. dd_len : cint; // size of data buffer
  96. {$ifdef netbsdpowerpc}
  97. dd_pad1 : cint;
  98. dd_seek : cint64; // magic cookie returned by getdirentries
  99. {$else}
  100. dd_seek : clong; // magic cookie returned by getdirentries
  101. {$endif}
  102. dd_rewind : clong; // magic cookie for rewinding
  103. dd_flags : cint; // flags for readdir
  104. end;
  105. TDir = dir;
  106. pDir = ^dir;
  107. utimbuf = record
  108. actime : time_t;
  109. modtime : time_t;
  110. end;
  111. TUtimBuf = utimbuf;
  112. putimbuf = ^utimbuf;
  113. flock = record
  114. l_start : off_t; { starting offset }
  115. l_len : off_t; { len = 0 means until end of file }
  116. l_pid : pid_t; { lock owner }
  117. l_type : cshort; { lock type: read/write, etc. }
  118. l_whence: cshort; { type of l_start }
  119. end;
  120. TFlock = flock;
  121. pFlock = ^flock;
  122. tms = packed record
  123. tms_utime : clock_t; { User CPU time }
  124. tms_stime : clock_t; { System CPU time }
  125. tms_cutime : clock_t; { User CPU time of terminated child procs }
  126. tms_cstime : clock_t; { System CPU time of terminated child procs }
  127. end;
  128. TTms= tms;
  129. pTms= ^tms;
  130. TFDSet = ARRAY[0..(FD_MAXFDSET div 32)-1] of Cardinal;
  131. pFDSet = ^TFDSet;
  132. {***********************************************************************}
  133. { POSIX CONSTANT ROUTINE DEFINITIONS }
  134. {***********************************************************************}
  135. CONST
  136. { access routine - these maybe OR'ed together }
  137. F_OK = 0; { test for existence of file }
  138. R_OK = 4; { test for read permission on file }
  139. W_OK = 2; { test for write permission on file }
  140. X_OK = 1; { test for execute or search permission }
  141. { seek routine }
  142. SEEK_SET = 0; { seek from beginning of file }
  143. SEEK_CUR = 1; { seek from current position }
  144. SEEK_END = 2; { seek from end of file }
  145. { open routine }
  146. { File access modes for `open' and `fcntl'. }
  147. O_RDONLY = 0; { Open read-only. }
  148. O_WRONLY = 1; { Open write-only. }
  149. O_RDWR = 2; { Open read/write. }
  150. { Bits OR'd into the second argument to open. }
  151. O_CREAT = $200; { Create file if it doesn't exist. }
  152. O_EXCL = $800; { Fail if file already exists. }
  153. O_TRUNC = $400; { Truncate file to zero length. }
  154. O_NOCTTY = $8000; { Don't assign a controlling terminal. }
  155. { File status flags for `open' and `fcntl'. }
  156. O_APPEND = 8; { Writes append to the file. }
  157. O_NONBLOCK = 4; { Non-blocking I/O. }
  158. { mode_t possible values }
  159. S_IRUSR = %0100000000; { Read permission for owner }
  160. S_IWUSR = %0010000000; { Write permission for owner }
  161. S_IXUSR = %0001000000; { Exec permission for owner }
  162. S_IRGRP = %0000100000; { Read permission for group }
  163. S_IWGRP = %0000010000; { Write permission for group }
  164. S_IXGRP = %0000001000; { Exec permission for group }
  165. S_IROTH = %0000000100; { Read permission for world }
  166. S_IWOTH = %0000000010; { Write permission for world }
  167. S_IXOTH = %0000000001; { Exec permission for world }
  168. { Used for waitpid }
  169. WNOHANG = 1; { don't block waiting }
  170. WUNTRACED = 2; { report status of stopped children }
  171. { For File control mechanism }
  172. F_GetFd = 1;
  173. F_SetFd = 2;
  174. F_GetFl = 3;
  175. F_SetFl = 4;
  176. F_GetLk = 5;
  177. F_SetLk = 6;
  178. F_SetLkW = 7;
  179. F_SetOwn = 8;
  180. F_GetOwn = 9;
  181. type
  182. timezone = packed record
  183. tz_minuteswest,
  184. tz_dsttime : cint;
  185. end;
  186. ptimezone =^timezone;
  187. TTimeZone = timezone;
  188. rusage = packed record
  189. ru_utime : timeval; { user time used }
  190. ru_stime : timeval; { system time used }
  191. ru_maxrss : clong; { max resident set size }
  192. ru_ixrss : clong; { integral shared memory size }
  193. ru_idrss : clong; { integral unshared data " }
  194. ru_isrss : clong; { integral unshared stack " }
  195. ru_minflt : clong; { page reclaims }
  196. ru_majflt : clong; { page faults }
  197. ru_nswap : clong; { swaps }
  198. ru_inblock : clong; { block input operations }
  199. ru_oublock : clong; { block output operations }
  200. ru_msgsnd : clong; { messages sent }
  201. ru_msgrcv : clong; { messages received }
  202. ru_nsignals : clong; { signals received }
  203. ru_nvcsw : clong; { voluntary context switches }
  204. ru_nivcsw : clong; { involuntary " }
  205. end;
  206. // #define ru_last ru_nivcsw
  207. // #define ru_first ru_ixrss
  208. { auto generated by a c prog, statmacr.c}
  209. Const
  210. S_IFMT = 61440;
  211. S_IFIFO = 4096;
  212. S_IFCHR = 8192;
  213. S_IFDIR = 16384;
  214. S_IFBLK = 24576;
  215. S_IFREG = 32768;
  216. S_IFLNK = 40960;
  217. S_IFSOCK= 49152;
  218. S_IFWHT = 57344;
  219. S_ISVTX = 512;
  220. {
  221. * Resource limits from FreeBSD5. To be checked for the others.
  222. }
  223. RLIMIT_CPU = 0; { cpu time in milliseconds }
  224. RLIMIT_FSIZE = 1; { maximum file size }
  225. RLIMIT_DATA = 2; { data size }
  226. RLIMIT_STACK = 3; { stack size }
  227. RLIMIT_CORE = 4; { core file size }
  228. RLIMIT_RSS = 5; { resident set size }
  229. RLIMIT_MEMLOCK = 6; { locked-in-memory address space }
  230. RLIMIT_NPROC = 7; { number of processes }
  231. RLIMIT_NOFILE = 8; { number of open files }
  232. {$IFDEF FreeBSD}
  233. RLIMIT_SBSIZE = 9; { maximum size of all socket buffers }
  234. RLIMIT_VMEM =10; { virtual process size (inclusive of mmap) }
  235. RLIMIT_AS = RLIMIT_VMEM;
  236. {$ELSE}
  237. RLIMIT_AS = 5; { address space= resident set size}
  238. {$ENDIF}
  239. {$ifdef FreeBSD}
  240. RLIM_NLIMITS =11; { number of resource limits }
  241. {$endif}
  242. {$ifdef Darwin} // OS X 10.3
  243. RLIM_NLIMITS =9; { number of resource limits }
  244. {$endif}
  245. Type
  246. TRLimit = record
  247. rlim_cur, { current (soft) limit }
  248. rlim_max : TRLim; { maximum value for rlim_cur }
  249. end;
  250. PRLimit = ^TRLimit;
  251. iovec = record
  252. iov_base : pointer;
  253. iov_len : size_t;
  254. end;
  255. tiovec=iovec;
  256. piovec=^tiovec;
  257. CONST
  258. { Constansts for MMAP }
  259. MAP_PRIVATE =2;
  260. MAP_ANONYMOUS =$1000;
  261. {*************************************************************************}
  262. { SIGNALS }
  263. {*************************************************************************}
  264. {$i signal.inc}