bunxtype.inc 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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. {$i ptypes.inc}
  18. {$ifdef cpupowerpc}
  19. {$ifdef netbsd}
  20. {$define netbsdpowerpc}
  21. {$endif}
  22. {$endif}
  23. // CONST SYS_NMLN=65;
  24. // Can't find these two in Posix and in FreeBSD
  25. //CONST
  26. // _UTSNAME_LENGTH = ;
  27. // _UTSNAME_NODENAME_LENGTH = ;
  28. CONST // OS specific parameters for general<fd,sig>set behaviour
  29. FD_MAXFDSET = 1024;
  30. ln2bitsinword = 5; { 32bit : ln(32)/ln(2)=5 }
  31. ln2bitmask = 1 shl ln2bitsinword - 1;
  32. TYPE
  33. { system information services }
  34. utsname = record
  35. sysname : Array[0..SYS_NMLN-1] OF Char; // Name of this OS
  36. nodename: Array[0..SYS_NMLN-1] OF Char; // Name of this network node.
  37. release : Array[0..SYS_NMLN-1] OF Char; // Release level.
  38. version : Array[0..SYS_NMLN-1] OF Char; // Version level.
  39. machine : Array[0..SYS_NMLN-1] OF Char; // Hardware type.
  40. end;
  41. TUtsName= utsname;
  42. pUtsName= ^utsname;
  43. { file characteristics services }
  44. stat = record { the types are real}
  45. st_dev : dev_t; // inode's device
  46. st_ino : ino_t; // inode's number
  47. st_mode : mode_t; // inode protection mode
  48. st_nlink : nlink_t; // number of hard links
  49. st_uid : uid_t; // user ID of the file's owner
  50. st_gid : gid_t; // group ID of the file's group
  51. st_rdev : dev_t; // device type
  52. st_atime : time_t; // time of last access
  53. st_atimensec : clong; // nsec of last access
  54. st_mtime : time_t; // time of last data modification
  55. st_mtimensec : clong; // nsec of last data modification
  56. st_ctime : time_t; // time of last file status change
  57. st_ctimensec : clong; // nsec of last file status change
  58. {$ifdef netbsdPowerpc}
  59. st_padd1 : cint;
  60. {$endif}
  61. st_size : off_t; // file size, in bytes
  62. st_blocks : cint64; // blocks allocated for file
  63. st_blksize : cuint32; // optimal blocksize for I/O
  64. st_flags : cuint32; // user defined flags for file
  65. st_gen : cuint32; // file generation number
  66. {$ifdef netbsdPowerpc}
  67. st_padd2 : cint;
  68. {$endif}
  69. {$ifndef NetBSD}
  70. st_lspare : cint32;
  71. {$endif}
  72. st_qspare : array[0..1] Of cint64;
  73. end;
  74. TStat = stat;
  75. pStat = ^stat;
  76. { directory services }
  77. dirent = record
  78. d_fileno : cuint32; // file number of entry
  79. d_reclen : cuint16; // length of this record
  80. d_type : cuint8; // file type, see below
  81. d_namlen : cuint8; // length of string in d_name
  82. d_name : array[0..(255 + 1)-1] of char; // name must be no longer than this
  83. end;
  84. TDirent = dirent;
  85. pDirent = ^dirent;
  86. dir = packed record
  87. dd_fd : cint; // file descriptor associated with directory
  88. dd_loc : clong; // offset in current buffer
  89. dd_size : clong; // amount of data returned by getdirentries
  90. dd_buf : pchar; // data buffer
  91. dd_len : cint; // size of data buffer
  92. {$ifdef netbsdpowerpc}
  93. dd_pad1 : cint;
  94. dd_seek : cint64; // magic cookie returned by getdirentries
  95. {$else}
  96. dd_seek : clong; // magic cookie returned by getdirentries
  97. {$endif}
  98. dd_rewind : clong; // magic cookie for rewinding
  99. dd_flags : cint; // flags for readdir
  100. end;
  101. TDir = dir;
  102. pDir = ^dir;
  103. utimbuf = record
  104. actime : time_t;
  105. modtime : time_t;
  106. end;
  107. TUtimBuf = utimbuf;
  108. putimbuf = ^utimbuf;
  109. flock = record
  110. l_start : off_t; { starting offset }
  111. l_len : off_t; { len = 0 means until end of file }
  112. l_pid : pid_t; { lock owner }
  113. l_type : cshort; { lock type: read/write, etc. }
  114. l_whence: cshort; { type of l_start }
  115. end;
  116. TFlock = flock;
  117. pFlock = ^flock;
  118. tms = packed record
  119. tms_utime : clock_t; { User CPU time }
  120. tms_stime : clock_t; { System CPU time }
  121. tms_cutime : clock_t; { User CPU time of terminated child procs }
  122. tms_cstime : clock_t; { System CPU time of terminated child procs }
  123. end;
  124. TTms= tms;
  125. pTms= ^tms;
  126. TFDSet = ARRAY[0..(FD_MAXFDSET div 32)-1] of Cardinal;
  127. pFDSet = ^TFDSet;
  128. {***********************************************************************}
  129. { POSIX CONSTANT ROUTINE DEFINITIONS }
  130. {***********************************************************************}
  131. CONST
  132. { access routine - these maybe OR'ed together }
  133. F_OK = 0; { test for existence of file }
  134. R_OK = 4; { test for read permission on file }
  135. W_OK = 2; { test for write permission on file }
  136. X_OK = 1; { test for execute or search permission }
  137. { seek routine }
  138. SEEK_SET = 0; { seek from beginning of file }
  139. SEEK_CUR = 1; { seek from current position }
  140. SEEK_END = 2; { seek from end of file }
  141. { open routine }
  142. { File access modes for `open' and `fcntl'. }
  143. O_RDONLY = 0; { Open read-only. }
  144. O_WRONLY = 1; { Open write-only. }
  145. O_RDWR = 2; { Open read/write. }
  146. { Bits OR'd into the second argument to open. }
  147. O_CREAT = $200; { Create file if it doesn't exist. }
  148. O_EXCL = $800; { Fail if file already exists. }
  149. O_TRUNC = $400; { Truncate file to zero length. }
  150. O_NOCTTY = $8000; { Don't assign a controlling terminal. }
  151. { File status flags for `open' and `fcntl'. }
  152. O_APPEND = 8; { Writes append to the file. }
  153. O_NONBLOCK = 4; { Non-blocking I/O. }
  154. { mode_t possible values }
  155. S_IRUSR = %0100000000; { Read permission for owner }
  156. S_IWUSR = %0010000000; { Write permission for owner }
  157. S_IXUSR = %0001000000; { Exec permission for owner }
  158. S_IRGRP = %0000100000; { Read permission for group }
  159. S_IWGRP = %0000010000; { Write permission for group }
  160. S_IXGRP = %0000001000; { Exec permission for group }
  161. S_IROTH = %0000000100; { Read permission for world }
  162. S_IWOTH = %0000000010; { Write permission for world }
  163. S_IXOTH = %0000000001; { Exec permission for world }
  164. { Used for waitpid }
  165. WNOHANG = 1; { don't block waiting }
  166. WUNTRACED = 2; { report status of stopped children }
  167. { For File control mechanism }
  168. F_GetFd = 1;
  169. F_SetFd = 2;
  170. F_GetFl = 3;
  171. F_SetFl = 4;
  172. F_GetLk = 5;
  173. F_SetLk = 6;
  174. F_SetLkW = 7;
  175. F_SetOwn = 8;
  176. F_GetOwn = 9;
  177. {*************************************************************************}
  178. { SIGNALS }
  179. {*************************************************************************}
  180. {$i signal.inc}
  181. // function geterrno:longint;
  182. // procedure seterrno(i:longint);
  183. {
  184. $Log$
  185. Revision 1.7 2004-01-04 20:08:45 jonas
  186. * moved SIG_MAXSIG and wordsinsigset constants from bunxtype.inc to
  187. ptypes.inc (already there for Darwin)
  188. Revision 1.6 2003/11/30 12:40:29 marco
  189. * fix from sebastian
  190. Revision 1.5 2003/11/19 17:11:40 marco
  191. * termio unit
  192. Revision 1.4 2003/09/14 20:15:01 marco
  193. * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
  194. Revision 1.3 2003/08/21 22:23:34 olle
  195. - removed parameter from fpc_iocheck
  196. Revision 1.2 2003/06/01 16:35:27 marco
  197. * Several small fixes to harmonize the *BSD rtls and Linux.
  198. Revision 1.1 2003/01/03 15:45:21 marco
  199. * Renamed to bunxtype.inc (from osposixh.inc), some minor changes
  200. (as introduced going from posix unit to baseunix)
  201. Revision 1.6 2002/10/27 17:21:29 marco
  202. * Only "difficult" functions + execvp + termios + rewinddir left to do
  203. Revision 1.5 2002/10/27 11:58:30 marco
  204. * Modifications from Saturday.
  205. Revision 1.4 2002/09/07 16:01:17 peter
  206. * old logs removed and tabs fixed
  207. Revision 1.3 2002/08/21 07:03:16 marco
  208. * Fixes from Tuesday.
  209. Revision 1.2 2002/08/19 12:29:11 marco
  210. * First working POSIX *BSD system unit.
  211. Revision 1.1 2002/08/03 19:34:19 marco
  212. * Initial *BSD versions. Seems that OpenBSD doesn't need much change,
  213. NetBSD may need some fixes to stat record and ftruncate and lseek.
  214. It is all close together, and it should be doable to have just one copy
  215. of these for *BSD.
  216. }