ostypes.inc 10 KB

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