ptypes.inc 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2001 by Free Pascal development team
  4. This file implements all the base types and limits required
  5. for a minimal POSIX compliant subset required to port the compiler
  6. to a new OS.
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. {***********************************************************************}
  14. { POSIX TYPE DEFINITIONS }
  15. {***********************************************************************}
  16. {$I ctypes.inc}
  17. {$packrecords c}
  18. type
  19. dev_t = cuint32; { used for device numbers }
  20. TDev = dev_t;
  21. pDev = ^dev_t;
  22. gid_t = cuint32; { used for group IDs }
  23. TGid = gid_t;
  24. pGid = ^gid_t;
  25. TIOCtlRequest = cuLong;
  26. ino_t = clong; { used for file serial numbers }
  27. TIno = ino_t;
  28. pIno = ^ino_t;
  29. mode_t = cuint32; { used for file attributes }
  30. TMode = mode_t;
  31. pMode = ^mode_t;
  32. nlink_t = cuint32; { 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. pSize_t = ^size_t;
  49. {$ifdef CPU64}
  50. ssize_t = cint64; { used by function for returning number of bytes }
  51. {$else}
  52. ssize_t = cint32; { used by function for returning number of bytes}
  53. {$endif}
  54. TsSize = ssize_t;
  55. psSize = ^ssize_t;
  56. uid_t = cuint32; { used for user ID type }
  57. TUid = Uid_t;
  58. pUid = ^Uid_t;
  59. clock_t = culong;
  60. TClock = clock_t;
  61. pClock = ^clock_t;
  62. time_t = clong; { used for returning the time }
  63. TTime = time_t;
  64. pTime = ^time_t;
  65. ptime_t = ^time_t;
  66. socklen_t= cuint32;
  67. TSocklen = socklen_t;
  68. pSocklen = ^socklen_t;
  69. Const
  70. {$warning Check me, I'am from FreeBSD}
  71. MNAMLEN = 80; // slightly machine specific.
  72. MFSNamLen = 16;
  73. type
  74. {$warning Check me, I'am from FreeBSD}
  75. fsid_t = array[0..1] of cint;
  76. // Kernel statfs
  77. {$warning Check me, I'am from FreeBSD}
  78. TStatfs = packed record
  79. spare2, { place holder}
  80. bsize, { fundamental block size}
  81. iosize, { optimal block size }
  82. blocks, { total blocks}
  83. bfree, { blocks free}
  84. bavail, { block available for mortal users}
  85. files, { Total file nodes}
  86. ffree : clong ; { file nodes free}
  87. fsid : fsid_t;
  88. fowner : tuid; {mounter uid}
  89. ftype : cint;
  90. fflags : cint; {copy of mount flags}
  91. fsyncwrites,
  92. fasyncwrites : clong;
  93. fstypename : array[0..MFSNamLen-1] of char;
  94. mountpoint : array[0..MNAMLEN-1] of char;
  95. fsyncreads, { count of sync reads since mount }
  96. fasyncreads : clong;
  97. fspares1 : cshort;
  98. mnfromname : array[0..MNAMLEN-1] of char;
  99. fspares2 : cshort;
  100. fspare3 : array[0..1] of clong;
  101. end;
  102. PStatFS=^TStatFS;
  103. timeval = packed record
  104. tv_sec,
  105. tv_usec : clong;
  106. end;
  107. ptimeval= ^timeval;
  108. TTimeval= timeval;
  109. timespec = packed record
  110. tv_sec : time_t;
  111. tv_nsec : clong;
  112. end;
  113. ptimespec= ^timespec;
  114. Ttimespec= timespec;
  115. pthread_t = pointer;
  116. pthread_attr_t = pointer;
  117. pthread_mutex_t = {$i pmutext.inc}
  118. pthread_mutexattr_t = pointer;
  119. pthread_cond_t = pointer;
  120. pthread_condattr_t = pointer;
  121. pthread_key_t = cint;
  122. pthread_rwlock_t = pointer;
  123. pthread_rwlockattr_t = pointer;
  124. sem_t = pointer;
  125. rlim_t = int64;
  126. TRlim = rlim_t;
  127. {
  128. Mutex types (Single UNIX Specification, Version 2, 1997).
  129. Note that a mutex attribute with one of the following types:
  130. PTHREAD_MUTEX_NORMAL
  131. PTHREAD_MUTEX_RECURSIVE
  132. MUTEX_TYPE_FAST (deprecated)
  133. MUTEX_TYPE_COUNTING_FAST (deprecated)
  134. will deviate from POSIX specified semantics.
  135. }
  136. pthread_mutextype = (
  137. { Default POSIX mutex }
  138. _PTHREAD_MUTEX_ERRORCHECK := 1,
  139. { Recursive mutex }
  140. _PTHREAD_MUTEX_RECURSIVE := 2,
  141. { No error checking }
  142. _PTHREAD_MUTEX_NORMAL := 3,
  143. _MUTEX_TYPE_MAX
  144. );
  145. const
  146. _PTHREAD_MUTEX_DEFAULT = _PTHREAD_MUTEX_ERRORCHECK;
  147. _MUTEX_TYPE_FAST = _PTHREAD_MUTEX_NORMAL;
  148. _MUTEX_TYPE_COUNTING_FAST = _PTHREAD_MUTEX_RECURSIVE;
  149. _PTHREAD_KEYS_MAX = 256;
  150. _PTHREAD_STACK_MIN = 1024;
  151. { System limits, POSIX value in parentheses, used for buffer and stack allocation }
  152. ARG_MAX = 256*1024; {4096} { Maximum number of argument size }
  153. NAME_MAX = 255; {14} { Maximum number of bytes in filename }
  154. PATH_MAX = 1024; {255} { Maximum number of bytes in pathname }
  155. SYS_NMLN = 32; {BSD utsname struct limit}
  156. SIG_MAXSIG = 128; // highest signal version
  157. { For getting/setting priority }
  158. Prio_Process = 0;
  159. Prio_PGrp = 1;
  160. Prio_User = 2;