ptypes.inc 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. { the following type definitions are compiler dependant }
  21. { and system dependant }
  22. dev_t = cuint32; { used for device numbers }
  23. TDev = dev_t;
  24. pDev = ^dev_t;
  25. gid_t = cuint32; { used for group IDs }
  26. TGid = gid_t;
  27. pGid = ^gid_t;
  28. ino_t = clong; { used for file serial numbers }
  29. TIno = ino_t;
  30. pIno = ^ino_t;
  31. mode_t = cuint16; { used for file attributes }
  32. TMode = mode_t;
  33. pMode = ^mode_t;
  34. nlink_t = cuint16; { used for link counts }
  35. TnLink = nlink_t;
  36. pnLink = ^nlink_t;
  37. off_t = cint64; { used for file sizes }
  38. TOff = off_t;
  39. pOff = ^off_t;
  40. pid_t = cint32; { used as process identifier }
  41. TPid = pid_t;
  42. pPid = ^pid_t;
  43. size_t = cuint32; { as definied in the C standard}
  44. TSize = size_t;
  45. pSize = ^size_t;
  46. ssize_t = cint32; { used by function for returning number of bytes }
  47. TsSize = ssize_t;
  48. psSize = ^ssize_t;
  49. uid_t = cuint32; { used for user ID type }
  50. TUid = Uid_t;
  51. pUid = ^Uid_t;
  52. clock_t = culong;
  53. TClock = clock_t;
  54. pClock = ^clock_t;
  55. time_t = clong; { used for returning the time }
  56. TTime = time_t;
  57. pTime = ^time_t;
  58. ptime_t = ^time_t;
  59. socklen_t= cuint32;
  60. TSocklen = socklen_t;
  61. pSocklen = ^socklen_t;
  62. timeval = record
  63. tv_sec: cint;
  64. tv_usec: cint;
  65. end;
  66. ptimeval = ^timeval;
  67. TTimeVal = timeval;
  68. timespec = packed record
  69. tv_sec : time_t;
  70. tv_nsec : clong;
  71. end;
  72. ptimespec= ^timespec;
  73. Ttimespec= timespec;
  74. CONST
  75. { System limits, POSIX value in parentheses, used for buffer and stack allocation }
  76. ARG_MAX = 65536; {4096} { Maximum number of argument size }
  77. NAME_MAX = 255; {14} { Maximum number of bytes in filename }
  78. PATH_MAX = 1024; {255} { Maximum number of bytes in pathname }
  79. SYS_NMLN = 32; {BSD utsname struct limit}
  80. SIG_MAXSIG = 32; // highest signal version
  81. MFSNAMELEN = 15;
  82. MNAMELEN = 90;
  83. type
  84. pthread_mutextype = (
  85. _PTHREAD_MUTEX_NORMAL := 0,
  86. _PTHREAD_MUTEX_ERRORCHECK := 1,
  87. _PTHREAD_MUTEX_RECURSIVE := 2
  88. );
  89. const
  90. _PTHREAD_MUTEX_DEFAULT = _PTHREAD_MUTEX_NORMAL;
  91. _MUTEX_TYPE_FAST = _PTHREAD_MUTEX_NORMAL;
  92. _MUTEX_TYPE_COUNTING_FAST = _PTHREAD_MUTEX_RECURSIVE;
  93. _PTHREAD_KEYS_MAX = 128;
  94. _PTHREAD_STACK_MIN = 8192;
  95. type
  96. fsid_t = record
  97. val: array[0..1] of cint32;
  98. end;
  99. tstatfs = record
  100. otype : cint16;
  101. oflags : cint16;
  102. bsize : cint32;
  103. iosize : cint32;
  104. blocks : cint32;
  105. bfree : cint32;
  106. bavail : cint32;
  107. files : cint32;
  108. ffree : cint32;
  109. fsid : fsid_t;
  110. fowner : uid_t;
  111. reserved1 : cint16;
  112. ftype : cint16;
  113. fflags : cint32;
  114. reserved2 : array[0..1] of cint32;
  115. fstypename : array[0..(MFSNAMELEN)-1] of char;
  116. mountpoint : array[0..(MNAMELEN)-1] of char;
  117. mntfromname : array[0..(MNAMELEN)-1] of char;
  118. end;
  119. pstatfs = ^tstatfs;
  120. pthread_t = pointer;
  121. pthread_attr_t = record sig: clong; opaque: array[0..36-1] of byte; end;
  122. pthread_mutex_t = record sig: clong; opaque: array[0..40-1] of byte; end;
  123. pthread_mutexattr_t = record sig: clong; opaque: array[0..8-1] of byte; end;
  124. pthread_cond_t = record sig: clong; opaque: array[0..24-1] of byte; end;
  125. pthread_condattr_t = record sig: clong; opaque: array[0..4-1] of byte; end;
  126. pthread_key_t = clong;
  127. pthread_rwlock_t = record sig: clong; opaque: array[0..124-1] of byte; end;
  128. pthread_rwlockattr_t = record sig: clong; opaque: array[0..12-1] of byte; end;
  129. sem_t = cint;
  130. // for get/setpriority
  131. Const
  132. { For getting/setting priority }
  133. Prio_Process = 0;
  134. Prio_PGrp = 1;
  135. Prio_User = 2;
  136. {
  137. $Log$
  138. Revision 1.9 2004-11-14 12:24:33 marco
  139. * priority constants
  140. Revision 1.8 2004/09/09 20:29:06 jonas
  141. * fixed definition of pthread_mutex_t for non-linux targets (and for
  142. linux as well, actually).
  143. * base libpthread definitions are now in ptypes.inc, included in unixtype
  144. They sometimes have an extra underscore in front of their name, in
  145. case they were also exported by the packages/base/pthreads unit, so
  146. they can keep their original name there
  147. * cthreadds unit now imports systuils, because it uses exceptions (it
  148. already did so before as well)
  149. * fixed many linux definitions of libpthread functions in pthrlinux.inc
  150. (integer -> cint etc)
  151. + added culonglong type to ctype.inc
  152. Revision 1.7 2004/08/25 21:42:11 jonas
  153. * fixed pthread type definitions for darwin and made them generic
  154. Revision 1.6 2004/03/04 22:28:08 marco
  155. * Darwin specific unixtype fixes.
  156. Revision 1.5 2004/03/01 19:50:40 jonas
  157. - removed wordsinfdset again, because now it's defined in a common file
  158. Revision 1.4 2004/02/22 23:18:24 jonas
  159. + added wordsinfdset constant
  160. Revision 1.3 2004/01/04 20:05:38 jonas
  161. * first working version of the Darwin/Mac OS X (for PowerPC) RTL
  162. Several non-essential units are still missing, but make cycle works
  163. Revision 1.2 2003/05/25 12:59:57 jonas
  164. * several fixes, addition of Mach trap numbers (thye are simply syscalls
  165. with a negative number)
  166. Revision 1.1 2002/09/08 09:00:54 jonas
  167. + initial revision, simply copied from FreeBSD
  168. }