bunxtype.inc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  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 the BaseUnix 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. { Base Unix Structures }
  14. {***********************************************************************}
  15. {$IFDEF FPC_IS_SYSTEM}
  16. {$i ptypes.inc}
  17. {$ENDIF}
  18. CONST
  19. // SYS_NMLM = 65;
  20. UTSNAME_LENGTH = SYS_NMLN;
  21. UTSNAME_NODENAME_LENGTH = UTSNAME_LENGTH;
  22. {$ifdef usedomain}
  23. UTSNAME_DOMAIN_LENGTH = UTSNAME_LENGTH;
  24. {$endif}
  25. FD_MAXFDSET = 1024;
  26. BITSINWORD = 8*sizeof(longint);
  27. wordsinsigset = SIG_MAXSIG DIV BITSINWORD; // words in sigset_t
  28. wordsinfdset = FD_MAXFDSET DIV BITSINWORD; // words in fdset_t
  29. ln2bitsinword = 5; { 32bit : ln(32)/ln(2)=5 }
  30. ln2bitmask = 1 shl ln2bitsinword - 1;
  31. TYPE
  32. Blksize_t = cuint;
  33. Blkcnt_t = cuint;
  34. Ino64_t = cint64;
  35. Off64_t = cint64;
  36. TBlkSize = BlkSize_t;
  37. PBlkSize = ^BlkSize_t;
  38. TBlkCnt = Blkcnt_t;
  39. PBlkCnt = ^Blkcnt_t;
  40. TIno64 = Ino64_t;
  41. PIno64 = ^Ino64_t;
  42. TOff64 = Off64_t;
  43. POff64 = ^Off64_t;
  44. { system information services }
  45. UtsName = Record
  46. Sysname : Array[0..UTSNAME_LENGTH -1] OF Char; // Name of this OS
  47. Nodename: Array[0..UTSNAME_NODENAME_LENGTH-1] OF Char; // Name of this network node.
  48. Release : Array[0..UTSNAME_LENGTH -1] OF Char; // Release level.
  49. Version : Array[0..UTSNAME_LENGTH -1] OF Char; // Version level.
  50. Machine : Array[0..UTSNAME_LENGTH -1] OF Char; // Hardware type.
  51. {$ifdef usedomain}
  52. Domain : array[0..UTSNAME_DOMAIN_LENGTH-1] of char; // Linux addition "Domain"
  53. {$endif}
  54. end;
  55. TUtsName = UtsName;
  56. PUtsName = TUtsName;
  57. { Definition of (kernel) stat type }
  58. { see kernel/include/asm-<cpu>/stat.h, include/linux/types.h and }
  59. { include /include/asm-<cpu>/posix-types.h }
  60. {$i stat.inc}
  61. TStat = Stat;
  62. PStat = ^Stat;
  63. {$ifdef notused} // 64-bit support needs some work still :-)
  64. { file characteristics services }
  65. stat64 = record
  66. st_dev : dev_t; // inode's device
  67. pad1 : cushort;
  68. {$ifdef 64bitfs} // ??
  69. __st_ino : ino_t;
  70. {$else}
  71. st_ino : ino_t; // inode's number
  72. {$endif}
  73. st_mode : mode_t; // inode protection mode
  74. st_nlink : nlink_t; // number of hard links
  75. st_uid : uid_t; // user ID of the file's owner
  76. st_gid : gid_t; // group ID of the file's group
  77. st_rdev : dev_t; // device type
  78. pad2 : cushort;
  79. {$ifdef 64bitfs}
  80. st_size : off64_t; // file size, in bytes
  81. {$else}
  82. st_size : off_t; // file size, in bytes
  83. {$endif}
  84. st_blksize : blksize_t; // optimal blocksize for I/O
  85. {$ifdef 64bitfs}
  86. st_blocks : blkcnt64_t; // blocks allocated for file
  87. {$else}
  88. st_blocks : blkcnt_t; // blocks allocated for file
  89. {$endif}
  90. st_atime : time_t; // time of last access
  91. unused1 : culong;
  92. st_mtime : time_t; // time of last data modification
  93. unused2 : culong;
  94. st_ctime : time_t; // time of last file status change
  95. unused3 : culong;
  96. {$ifdef 64bitfs}
  97. st_ino : ino64_t
  98. {$else}
  99. unused4 : culong;
  100. unused5 : culong;
  101. {$endif}
  102. end;
  103. {$endif}
  104. { directory services }
  105. Dirent = packed record
  106. {$ifndef 64bitfs}
  107. d_fileno : ino_t; // file number of entry
  108. d_off : off_t;
  109. {$else}
  110. d_fileno : ino64_t; // file number of entry
  111. d_off : off64_t;
  112. {$endif}
  113. d_reclen : cushort; // length of string in d_name
  114. {$ifdef Uselibc} // Libc different from kernel record!
  115. d_type : cuchar; // file type, see below
  116. {$endif}
  117. d_name : array[0..(255 + 1)-1] of char; // name must be no longer than this
  118. end;
  119. TDirent = Dirent;
  120. pDirent = ^Dirent;
  121. {$ifdef oldreaddir}
  122. { Still old one. This is a userland struct}
  123. Dir = record
  124. dd_fd : integer;
  125. dd_loc : longint;
  126. dd_size : integer;
  127. dd_buf : pdirent;
  128. {The following are used in libc, but NOT in the linux kernel sources ??}
  129. dd_nextoff: longint;
  130. dd_max : integer; {size of buf. Irrelevant, as buf is of type dirent}
  131. dd_lock : pointer;
  132. end;
  133. {$else}
  134. // new libc one. NOTE that off_t must be real, so 64-bit ifdef
  135. // 64bitsfs
  136. Dir = Record // packing doesn't matter. This is a userland struct.
  137. fd : cint;
  138. data : pchar;
  139. allocation: size_t;
  140. _size : size_t;
  141. offset : size_t;
  142. filepos : off_t;
  143. end;
  144. {$endif}
  145. TDir = Dir;
  146. pDir = ^Dir;
  147. UTimBuf = Record
  148. actime : time_t;
  149. modtime : time_t;
  150. end;
  151. TUtimBuf = UtimBuf;
  152. pUtimBuf = ^UtimBuf;
  153. FLock = Record
  154. l_type : cshort; { lock type: read/write, etc. }
  155. l_whence: cshort; { type of l_start }
  156. {$ifdef 64bitfs}
  157. l_start : off64_t; { starting offset }
  158. l_len : off64_t; { len = 0 means until end of file }
  159. {$else}
  160. l_start : off_t; { starting offset }
  161. l_len : off_t; { len = 0 means until end of file }
  162. {$endif}
  163. l_pid : pid_t; { lock owner }
  164. End;
  165. tms = packed Record
  166. tms_utime : clock_t; { User CPU time }
  167. tms_stime : clock_t; { System CPU time }
  168. tms_cutime : clock_t; { User CPU time of terminated child procs }
  169. tms_cstime : clock_t; { System CPU time of terminated child procs }
  170. end;
  171. TTms = tms;
  172. PTms = ^tms;
  173. TFDSet = ARRAY[0..(FD_MAXFDSET div 32)-1] of Cardinal;
  174. pFDSet = ^TFDSet;
  175. {***********************************************************************}
  176. { POSIX CONSTANT ROUTINE DEFINITIONS }
  177. {***********************************************************************}
  178. CONST
  179. { access routine - these maybe OR'ed together }
  180. F_OK = 0; { test for existence of file }
  181. R_OK = 4; { test for read permission on file }
  182. W_OK = 2; { test for write permission on file }
  183. X_OK = 1; { test for execute or search permission }
  184. { seek routine }
  185. SEEK_SET = 0; { seek from beginning of file }
  186. SEEK_CUR = 1; { seek from current position }
  187. SEEK_END = 2; { seek from end of file }
  188. { open routine }
  189. { File access modes for `open' and `fcntl'. }
  190. O_RDONLY = 0; { Open read-only. }
  191. O_WRONLY = 1; { Open write-only. }
  192. O_RDWR = 2; { Open read/write. }
  193. {$ifdef sparc}
  194. O_APPEND = 8;
  195. O_CREAT = $200;
  196. O_TRUNC = $400;
  197. O_EXCL = $800;
  198. O_SYNC = $2000;
  199. O_NONBLOCK = $4000;
  200. O_NDELAY = O_NONBLOCK or 4;
  201. O_NOCTTY = $8000;
  202. O_DIRECTORY = $10000;
  203. O_NOFOLLOW = $20000;
  204. O_LARGEFILE = $40000;
  205. O_DIRECT = $100000;
  206. {$else sparc}
  207. O_CREAT = $40;
  208. O_EXCL = $80;
  209. O_NOCTTY = $100;
  210. O_TRUNC = $200;
  211. O_APPEND = $400;
  212. O_NONBLOCK = $800;
  213. O_NDELAY = O_NONBLOCK;
  214. O_SYNC = $1000;
  215. O_DIRECT = $4000;
  216. O_LARGEFILE = $8000;
  217. O_DIRECTORY = $10000;
  218. O_NOFOLLOW = $20000;
  219. {$endif sparc}
  220. { mode_t possible values }
  221. S_IRUSR = %0100000000; { Read permission for owner }
  222. S_IWUSR = %0010000000; { Write permission for owner }
  223. S_IXUSR = %0001000000; { Exec permission for owner }
  224. S_IRGRP = %0000100000; { Read permission for group }
  225. S_IWGRP = %0000010000; { Write permission for group }
  226. S_IXGRP = %0000001000; { Exec permission for group }
  227. S_IROTH = %0000000100; { Read permission for world }
  228. S_IWOTH = %0000000010; { Write permission for world }
  229. S_IXOTH = %0000000001; { Exec permission for world }
  230. { Used for waitpid }
  231. WNOHANG = 1; { don't block waiting }
  232. WUNTRACED = 2; { report status of stopped children }
  233. const
  234. { For File control mechanism }
  235. F_GetFd = 1;
  236. F_SetFd = 2;
  237. F_GetFl = 3;
  238. F_SetFl = 4;
  239. F_GetLk = 5;
  240. F_SetLk = 6;
  241. F_SetLkW = 7;
  242. F_SetOwn = 8;
  243. F_GetOwn = 9;
  244. {*************************************************************************}
  245. { SIGNALS }
  246. {*************************************************************************}
  247. {$i signal.inc}
  248. // function geterrno:longint;
  249. // procedure seterrno(i:longint);
  250. {
  251. $Log$
  252. Revision 1.10 2004-09-12 15:20:23 peter
  253. * sparc has different values for O_ flags
  254. Revision 1.9 2004/03/04 22:15:16 marco
  255. * UnixType changes. Please report problems to me.
  256. Revision 1.8 2004/02/22 15:00:27 marco
  257. * genfdset word count added. Small fix for libc maxsigsetsize
  258. Revision 1.7 2004/01/31 16:17:38 florian
  259. * removed packed directive from Dir type because it's not properly aligned
  260. and it's never passed to the OS
  261. Revision 1.6 2003/12/31 20:17:06 marco
  262. * sigset size adaption for FPC_USE_LIBC
  263. Revision 1.5 2003/12/02 00:04:34 sg
  264. * Fixed ln2bitmask
  265. Revision 1.4 2003/11/19 10:56:15 marco
  266. * some constants moved from System
  267. Revision 1.3 2003/09/14 20:15:01 marco
  268. * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
  269. Revision 1.2 2003/05/15 22:50:50 jonas
  270. * the stat type is processor-dependent
  271. * the dev_t tpye is processor dependent. Don't use it in the stat type
  272. however, as that one is also used at a time where dev_t is already
  273. defined as qword
  274. Revision 1.1 2002/12/18 16:43:26 marco
  275. * new unix rtl, linux part.....
  276. Revision 1.1 2002/11/12 14:37:59 marco
  277. * Parts of new unix rtl
  278. }