ptypes.inc 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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. This file implements all the base types and limits required
  6. for a minimal POSIX compliant subset required to port the compiler
  7. to a new 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 TYPE DEFINITIONS }
  16. {***********************************************************************}
  17. {$I ctypes.inc}
  18. {$packrecords c}
  19. type
  20. dev_t = cuint32; { used for device numbers }
  21. TDev = dev_t;
  22. pDev = ^dev_t;
  23. gid_t = cuint32; { used for group IDs }
  24. TGid = gid_t;
  25. pGid = ^gid_t;
  26. ino_t = clong; { used for file serial numbers }
  27. TIno = ino_t;
  28. pIno = ^ino_t;
  29. mode_t = cuint16; { used for file attributes }
  30. TMode = mode_t;
  31. pMode = ^mode_t;
  32. nlink_t = cuint16; { used for link counts }
  33. TnLink = nlink_t;
  34. pnLink = ^nlink_t;
  35. off_t = cint64; { used for file sizes }
  36. TOff = off_t;
  37. pOff = ^off_t;
  38. pid_t = cint32; { used as process identifier }
  39. TPid = pid_t;
  40. pPid = ^pid_t;
  41. {$ifdef CPU64}
  42. size_t = cuint64;
  43. {$else}
  44. size_t = cuint32; { as definied in the C standard}
  45. {$endif}
  46. TSize = size_t;
  47. pSize = ^size_t;
  48. {$ifdef CPU64}
  49. ssize_t = cint64; { used by function for returning number of bytes }
  50. {$else}
  51. ssize_t = cint32; { used by function for returning number of bytes}
  52. {$endif}
  53. TsSize = ssize_t;
  54. psSize = ^ssize_t;
  55. uid_t = cuint32; { used for user ID type }
  56. TUid = Uid_t;
  57. pUid = ^Uid_t;
  58. {$ifdef CPU64}
  59. clock_t = cuint32; // 32-bit even on Athlon64
  60. {$else}
  61. clock_t = culong;
  62. {$endif}
  63. TClock = clock_t;
  64. pClock = ^clock_t;
  65. time_t = clong; { used for returning the time, clong
  66. is 64-bit on AMD64}
  67. TTime = time_t;
  68. pTime = ^time_t;
  69. ptime_t = ^time_t;
  70. socklen_t= cuint32;
  71. TSocklen = socklen_t;
  72. pSocklen = ^socklen_t;
  73. timeval = packed record
  74. tv_sec,tv_usec:clong;
  75. end;
  76. ptimeval = ^timeval;
  77. TTimeVal = timeval;
  78. timespec = packed record
  79. tv_sec : time_t; // should be time_t, bug compability
  80. tv_nsec : clong;
  81. end;
  82. ptimespec= ^timespec;
  83. Ttimespec= timespec;
  84. pthread_t = pointer;
  85. pthread_attr_t = pointer;
  86. pthread_mutex_t = pointer;
  87. pthread_mutexattr_t = pointer;
  88. pthread_cond_t = pointer;
  89. pthread_condattr_t = pointer;
  90. pthread_key_t = cint;
  91. pthread_rwlock_t = pointer;
  92. pthread_rwlockattr_t = pointer;
  93. sem_t = pointer;
  94. {
  95. Mutex types (Single UNIX Specification, Version 2, 1997).
  96. Note that a mutex attribute with one of the following types:
  97. PTHREAD_MUTEX_NORMAL
  98. PTHREAD_MUTEX_RECURSIVE
  99. MUTEX_TYPE_FAST (deprecated)
  100. MUTEX_TYPE_COUNTING_FAST (deprecated)
  101. will deviate from POSIX specified semantics.
  102. }
  103. pthread_mutextype = (
  104. { Default POSIX mutex }
  105. _PTHREAD_MUTEX_ERRORCHECK := 1,
  106. { Recursive mutex }
  107. _PTHREAD_MUTEX_RECURSIVE := 2,
  108. { No error checking }
  109. _PTHREAD_MUTEX_NORMAL := 3,
  110. _MUTEX_TYPE_MAX
  111. );
  112. Const
  113. MNAMLEN = 80; // slightly machine specific.
  114. type
  115. TStatfs = packed record
  116. spare2, { place holder}
  117. bsize, { fundamental block size}
  118. iosize, { optimal block size }
  119. blocks, { total blocks}
  120. bfree, { blocks free}
  121. bavail, { block available for mortal users}
  122. files, { Total file nodes}
  123. ffree : clong ; { file nodes free}
  124. fsid : array[0..1] of longint; // fsid_t
  125. fowner : tuid; {mounter uid}
  126. ftype : cint;
  127. fflags : cint; {copy of mount flags}
  128. fsyncwrites,
  129. fasyncwrites : cint;
  130. fstypename : array[0..15] of char;
  131. mountpoint : array[0..MNAMLEN-1] of char;
  132. fsyncreads, { count of sync reads since mount }
  133. fasyncreads : clong;
  134. fspares1 : cshort;
  135. mnfromname : array[0..MNAMLEN-1] of char;
  136. fspares2 : cshort;
  137. fspare3 : array[0..1] of clong;
  138. end;
  139. PStatFS=^TStatFS;
  140. ITimerVal= Record
  141. It_Interval,
  142. It_Value : TimeVal;
  143. end;
  144. const
  145. _PTHREAD_MUTEX_DEFAULT = _PTHREAD_MUTEX_ERRORCHECK;
  146. _MUTEX_TYPE_FAST = _PTHREAD_MUTEX_NORMAL;
  147. _MUTEX_TYPE_COUNTING_FAST = _PTHREAD_MUTEX_RECURSIVE;
  148. _PTHREAD_KEYS_MAX = 256;
  149. _PTHREAD_STACK_MIN = 1024;
  150. { System limits, POSIX value in parentheses, used for buffer and stack allocation }
  151. ARG_MAX = 65536; {4096} { Maximum number of argument size }
  152. NAME_MAX = 255; {14} { Maximum number of bytes in filename }
  153. PATH_MAX = 1024; {255} { Maximum number of bytes in pathname }
  154. SYS_NMLN = 32; {BSD utsname struct limit, kernel mode}
  155. SIG_MAXSIG = 128; // highest signal version
  156. // wordsinsigset = 4; // words in sigset_t
  157. {
  158. $Log$
  159. Revision 1.15 2004-10-31 14:34:14 marco
  160. * statfs moved and updated
  161. Revision 1.14 2004/09/09 20:29:06 jonas
  162. * fixed definition of pthread_mutex_t for non-linux targets (and for
  163. linux as well, actually).
  164. * base libpthread definitions are now in ptypes.inc, included in unixtype
  165. They sometimes have an extra underscore in front of their name, in
  166. case they were also exported by the packages/base/pthreads unit, so
  167. they can keep their original name there
  168. * cthreadds unit now imports systuils, because it uses exceptions (it
  169. already did so before as well)
  170. * fixed many linux definitions of libpthread functions in pthrlinux.inc
  171. (integer -> cint etc)
  172. + added culonglong type to ctype.inc
  173. Revision 1.13 2004/08/25 21:42:11 jonas
  174. * fixed pthread type definitions for darwin and made them generic
  175. Revision 1.12 2004/05/18 19:33:45 marco
  176. * left a comment unmatched
  177. Revision 1.11 2004/05/17 19:18:38 marco
  178. * first x86-64 changes
  179. Revision 1.10 2004/03/04 22:15:16 marco
  180. * UnixType changes. Please report problems to me.
  181. Revision 1.9 2004/01/04 20:08:45 jonas
  182. * moved SIG_MAXSIG and wordsinsigset constants from bunxtype.inc to
  183. ptypes.inc (already there for Darwin)
  184. Revision 1.8 2003/12/30 12:32:30 marco
  185. *** empty log message ***
  186. Revision 1.7 2003/09/27 13:45:58 peter
  187. * fpnanosleep exported in baseunix
  188. * fpnanosleep has pointer arguments to be C compliant
  189. Revision 1.6 2003/09/14 20:15:01 marco
  190. * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
  191. Revision 1.5 2003/01/03 13:11:32 marco
  192. * split into ptypes and ctypes
  193. }