bunxtype.inc 9.6 KB

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