ptypes.inc 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. { the following type definitions are compiler dependant }
  20. { and system dependant }
  21. dev_t = cuint32; { used for device numbers }
  22. TDev = dev_t;
  23. pDev = ^dev_t;
  24. gid_t = cuint32; { used for group IDs }
  25. TGid = gid_t;
  26. pGid = ^gid_t;
  27. ino_t = cuint32; { used for file serial numbers }
  28. TIno = ino_t;
  29. pIno = ^ino_t;
  30. mode_t = cuint16; { used for file attributes }
  31. TMode = mode_t;
  32. pMode = ^mode_t;
  33. nlink_t = cuint16; { used for link counts }
  34. TnLink = nlink_t;
  35. pnLink = ^nlink_t;
  36. off_t = cint64; { used for file sizes }
  37. TOff = off_t;
  38. pOff = ^off_t;
  39. pid_t = cint32; { used as process identifier }
  40. TPid = pid_t;
  41. pPid = ^pid_t;
  42. size_t = culong; { as definied in the C standard}
  43. TSize = size_t;
  44. pSize = ^size_t;
  45. psize_t = ^size_t;
  46. ssize_t = clong; { 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. wchar_t = widechar;
  60. pwchar_t = ^wchar_t;
  61. wint_t = cint;
  62. socklen_t= cuint32;
  63. TSocklen = socklen_t;
  64. pSocklen = ^socklen_t;
  65. suseconds_t = cint32;
  66. timeval = record
  67. tv_sec: time_t;
  68. tv_usec: suseconds_t;
  69. end;
  70. ptimeval = ^timeval;
  71. TTimeVal = timeval;
  72. timespec = packed record
  73. tv_sec : time_t;
  74. tv_nsec : clong;
  75. end;
  76. ptimespec= ^timespec;
  77. Ttimespec= timespec;
  78. rlim_t = int64;
  79. TRlim = rlim_t;
  80. CONST
  81. { System limits, POSIX value in parentheses, used for buffer and stack allocation }
  82. ARG_MAX = 65536; {4096} { Maximum number of argument size }
  83. NAME_MAX = 255; {14} { Maximum number of bytes in filename }
  84. PATH_MAX = 1024; {255} { Maximum number of bytes in pathname }
  85. SYS_NMLN = 256; {BSD utsname struct limit}
  86. SIG_MAXSIG = 32; // highest signal version
  87. MFSNAMELEN = 15;
  88. MNAMELEN = 90;
  89. type
  90. pthread_mutextype = (
  91. _PTHREAD_MUTEX_NORMAL := 0,
  92. _PTHREAD_MUTEX_ERRORCHECK := 1,
  93. _PTHREAD_MUTEX_RECURSIVE := 2
  94. );
  95. const
  96. _PTHREAD_MUTEX_DEFAULT = _PTHREAD_MUTEX_NORMAL;
  97. _MUTEX_TYPE_FAST = _PTHREAD_MUTEX_NORMAL;
  98. _MUTEX_TYPE_COUNTING_FAST = _PTHREAD_MUTEX_RECURSIVE;
  99. _PTHREAD_KEYS_MAX = 128;
  100. _PTHREAD_STACK_MIN = 8192;
  101. type
  102. fsid_t = record
  103. val: array[0..1] of cint32;
  104. end;
  105. tstatfs = record
  106. otype : cint16;
  107. oflags : cint16;
  108. bsize : clong;
  109. iosize : clong;
  110. blocks : clong;
  111. bfree : clong;
  112. bavail : clong;
  113. files : clong;
  114. ffree : clong;
  115. fsid : fsid_t;
  116. fowner : uid_t;
  117. reserved1 : cint16;
  118. ftype : cint16;
  119. fflags : clong;
  120. reserved2 : array[0..1] of clong;
  121. fstypename : array[0..(MFSNAMELEN)-1] of char;
  122. mountpoint : array[0..(MNAMELEN)-1] of char;
  123. mntfromname : array[0..(MNAMELEN)-1] of char;
  124. f_reserved3: char;
  125. reserved4: array[0..3] of clong;
  126. end;
  127. pstatfs = ^tstatfs;
  128. pthread_t = pointer;
  129. pthread_attr_t = record sig: clong; opaque: array[0..{$ifdef cpu64}56{$else}36{$endif}-1] of byte; end;
  130. pthread_mutex_t = {$i pmutext.inc}
  131. pthread_mutexattr_t = record sig: clong; opaque: array[0..8-1] of byte; end;
  132. pthread_cond_t = record sig: clong; opaque: array[0..{$ifdef cpu64}40{$else}24{$endif}-1] of byte; end;
  133. pthread_condattr_t = record sig: clong; opaque: array[0..{$ifdef cpu64}8{$else}4{$endif}-1] of byte; end;
  134. pthread_key_t = culong;
  135. pthread_rwlock_t = record sig: clong; opaque: array[0..{$ifdef cpu64}192{$else}124{$endif}-1] of byte; end;
  136. pthread_rwlockattr_t = record sig: clong; opaque: array[0..{$ifdef cpu64}16{$else}12{$endif}-1] of byte; end;
  137. sem_t = cint;
  138. // for get/setpriority
  139. Const
  140. { For getting/setting priority }
  141. Prio_Process = 0;
  142. Prio_PGrp = 1;
  143. Prio_User = 2;