bunxtype.inc 10 KB

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