bunxtype.inc 8.8 KB

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