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 the BaseUnix unit.
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. ***********************************************************************}
  11. {***********************************************************************}
  12. { Base Unix Structures }
  13. {***********************************************************************}
  14. {$IFDEF FPC_IS_SYSTEM}
  15. {$i ptypes.inc}
  16. {$ENDIF}
  17. CONST
  18. // SYS_NMLM = 65;
  19. UTSNAME_LENGTH = SYS_NMLN;
  20. UTSNAME_NODENAME_LENGTH = UTSNAME_LENGTH;
  21. {$ifdef usedomain}
  22. UTSNAME_DOMAIN_LENGTH = UTSNAME_LENGTH;
  23. {$endif}
  24. FD_MAXFDSET = 1024;
  25. BITSINWORD = 8*sizeof(longint);
  26. wordsinsigset = SIG_MAXSIG DIV BITSINWORD; // words in sigset_t
  27. wordsinfdset = FD_MAXFDSET DIV BITSINWORD; // words in fdset_t
  28. ln2bitsinword = 5; { 32bit : ln(32)/ln(2)=5 }
  29. ln2bitmask = 1 shl ln2bitsinword - 1;
  30. TYPE
  31. Blksize_t = cuint;
  32. Blkcnt_t = cuint;
  33. Ino64_t = cint64;
  34. Off64_t = cint64;
  35. TBlkSize = BlkSize_t;
  36. PBlkSize = ^BlkSize_t;
  37. TBlkCnt = Blkcnt_t;
  38. PBlkCnt = ^Blkcnt_t;
  39. TIno64 = Ino64_t;
  40. PIno64 = ^Ino64_t;
  41. TOff64 = Off64_t;
  42. POff64 = ^Off64_t;
  43. { system information services }
  44. UtsName = Record
  45. Sysname : Array[0..UTSNAME_LENGTH -1] OF Char; // Name of this OS
  46. Nodename: Array[0..UTSNAME_NODENAME_LENGTH-1] OF Char; // Name of this network node.
  47. Release : Array[0..UTSNAME_LENGTH -1] OF Char; // Release level.
  48. Version : Array[0..UTSNAME_LENGTH -1] OF Char; // Version level.
  49. Machine : Array[0..UTSNAME_LENGTH -1] OF Char; // Hardware type.
  50. {$ifdef usedomain}
  51. Domain : array[0..UTSNAME_DOMAIN_LENGTH-1] of char; // Linux addition "Domain"
  52. {$endif}
  53. end;
  54. TUtsName = UtsName;
  55. PUtsName = TUtsName;
  56. { Definition of (kernel) stat type }
  57. { see kernel/include/asm-<cpu>/stat.h, include/linux/types.h and }
  58. { include /include/asm-<cpu>/posix-types.h }
  59. {$i stat.inc}
  60. TStat = Stat;
  61. PStat = ^Stat;
  62. {$ifdef notused} // 64-bit support needs some work still :-)
  63. { file characteristics services }
  64. stat64 = record
  65. st_dev : dev_t; // inode's device
  66. pad1 : cushort;
  67. {$ifdef 64bitfs} // ??
  68. __st_ino : ino_t;
  69. {$else}
  70. st_ino : ino_t; // inode's number
  71. {$endif}
  72. st_mode : mode_t; // inode protection mode
  73. st_nlink : nlink_t; // number of hard links
  74. st_uid : uid_t; // user ID of the file's owner
  75. st_gid : gid_t; // group ID of the file's group
  76. st_rdev : dev_t; // device type
  77. pad2 : cushort;
  78. {$ifdef 64bitfs}
  79. st_size : off64_t; // file size, in bytes
  80. {$else}
  81. st_size : off_t; // file size, in bytes
  82. {$endif}
  83. st_blksize : blksize_t; // optimal blocksize for I/O
  84. {$ifdef 64bitfs}
  85. st_blocks : blkcnt64_t; // blocks allocated for file
  86. {$else}
  87. st_blocks : blkcnt_t; // blocks allocated for file
  88. {$endif}
  89. st_atime : time_t; // time of last access
  90. unused1 : culong;
  91. st_mtime : time_t; // time of last data modification
  92. unused2 : culong;
  93. st_ctime : time_t; // time of last file status change
  94. unused3 : culong;
  95. {$ifdef 64bitfs}
  96. st_ino : ino64_t
  97. {$else}
  98. unused4 : culong;
  99. unused5 : culong;
  100. {$endif}
  101. end;
  102. {$endif}
  103. { directory services }
  104. Dirent = packed record
  105. {$ifndef 64bitfs}
  106. d_fileno : ino_t; // file number of entry
  107. d_off : off_t;
  108. {$else}
  109. d_fileno : ino64_t; // file number of entry
  110. d_off : off64_t;
  111. {$endif}
  112. d_reclen : cushort; // length of string in d_name
  113. {$ifdef Uselibc} // Libc different from kernel record!
  114. d_type : cuchar; // file type, see below
  115. {$endif}
  116. d_name : array[0..(255 + 1)-1] of char; // name must be no longer than this
  117. end;
  118. TDirent = Dirent;
  119. pDirent = ^Dirent;
  120. {$ifdef oldreaddir}
  121. { Still old one. This is a userland struct}
  122. Dir = record
  123. dd_fd : integer;
  124. dd_loc : longint;
  125. dd_size : integer;
  126. dd_buf : pdirent;
  127. {The following are used in libc, but NOT in the linux kernel sources ??}
  128. dd_nextoff: longint;
  129. dd_max : integer; {size of buf. Irrelevant, as buf is of type dirent}
  130. dd_lock : pointer;
  131. end;
  132. {$else}
  133. // new libc one. NOTE that off_t must be real, so 64-bit ifdef
  134. // 64bitsfs
  135. Dir = Record // packing doesn't matter. This is a userland struct.
  136. fd : cint;
  137. data : pchar;
  138. allocation: size_t;
  139. _size : size_t;
  140. offset : size_t;
  141. filepos : off_t;
  142. end;
  143. {$endif}
  144. TDir = Dir;
  145. pDir = ^Dir;
  146. UTimBuf = Record
  147. actime : time_t;
  148. modtime : time_t;
  149. end;
  150. TUtimBuf = UtimBuf;
  151. pUtimBuf = ^UtimBuf;
  152. FLock = Record
  153. l_type : cshort; { lock type: read/write, etc. }
  154. l_whence: cshort; { type of l_start }
  155. {$ifdef 64bitfs}
  156. l_start : off64_t; { starting offset }
  157. l_len : off64_t; { len = 0 means until end of file }
  158. {$else}
  159. l_start : off_t; { starting offset }
  160. l_len : off_t; { len = 0 means until end of file }
  161. {$endif}
  162. l_pid : pid_t; { lock owner }
  163. End;
  164. tms = packed Record
  165. tms_utime : clock_t; { User CPU time }
  166. tms_stime : clock_t; { System CPU time }
  167. tms_cutime : clock_t; { User CPU time of terminated child procs }
  168. tms_cstime : clock_t; { System CPU time of terminated child procs }
  169. end;
  170. TTms = tms;
  171. PTms = ^tms;
  172. TFDSet = ARRAY[0..(FD_MAXFDSET div 32)-1] of Cardinal;
  173. pFDSet = ^TFDSet;
  174. timezone = packed record
  175. tz_minuteswest,tz_dsttime:cint;
  176. end;
  177. ptimezone =^timezone;
  178. TTimeZone = timezone;
  179. {***********************************************************************}
  180. { POSIX CONSTANT ROUTINE DEFINITIONS }
  181. {***********************************************************************}
  182. CONST
  183. { access routine - these maybe OR'ed together }
  184. F_OK = 0; { test for existence of file }
  185. R_OK = 4; { test for read permission on file }
  186. W_OK = 2; { test for write permission on file }
  187. X_OK = 1; { test for execute or search permission }
  188. { seek routine }
  189. SEEK_SET = 0; { seek from beginning of file }
  190. SEEK_CUR = 1; { seek from current position }
  191. SEEK_END = 2; { seek from end of file }
  192. { open routine }
  193. { File access modes for `open' and `fcntl'. }
  194. O_RDONLY = 0; { Open read-only. }
  195. O_WRONLY = 1; { Open write-only. }
  196. O_RDWR = 2; { Open read/write. }
  197. {$ifdef sparc}
  198. O_APPEND = 8;
  199. O_CREAT = $200;
  200. O_TRUNC = $400;
  201. O_EXCL = $800;
  202. O_SYNC = $2000;
  203. O_NONBLOCK = $4000;
  204. O_NDELAY = O_NONBLOCK or 4;
  205. O_NOCTTY = $8000;
  206. O_DIRECTORY = $10000;
  207. O_NOFOLLOW = $20000;
  208. O_LARGEFILE = $40000;
  209. O_DIRECT = $100000;
  210. {$else sparc}
  211. O_CREAT = $40;
  212. O_EXCL = $80;
  213. O_NOCTTY = $100;
  214. O_TRUNC = $200;
  215. O_APPEND = $400;
  216. O_NONBLOCK = $800;
  217. O_NDELAY = O_NONBLOCK;
  218. O_SYNC = $1000;
  219. O_DIRECT = $4000;
  220. O_LARGEFILE = $8000;
  221. O_DIRECTORY = $10000;
  222. O_NOFOLLOW = $20000;
  223. {$endif sparc}
  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. { Used for waitpid }
  235. WNOHANG = 1; { don't block waiting }
  236. WUNTRACED = 2; { report status of stopped children }
  237. { File types }
  238. S_IFMT = 61440; { type of file mask}
  239. S_IFIFO = 4096; { named pipe (fifo)}
  240. S_IFCHR = 8192; { character special}
  241. S_IFDIR = 16384; { directory }
  242. S_IFBLK = 24576; { block special}
  243. S_IFREG = 32768; { regular }
  244. S_IFLNK = 40960; { symbolic link }
  245. S_IFSOCK= 49152; { socket }
  246. { Constansts for MMAP }
  247. MAP_PRIVATE =2;
  248. MAP_ANONYMOUS =$20;
  249. { For File control mechanism }
  250. F_GetFd = 1;
  251. F_SetFd = 2;
  252. F_GetFl = 3;
  253. F_SetFl = 4;
  254. F_GetLk = 5;
  255. F_SetLk = 6;
  256. F_SetLkW = 7;
  257. F_SetOwn = 8;
  258. F_GetOwn = 9;
  259. {*************************************************************************}
  260. { SIGNALS }
  261. {*************************************************************************}
  262. {$i signal.inc}