1{
2    This file is part of the Free Pascal run time library.
3    Copyright (c) 2001 by Free Pascal development team
4
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
9    See the file COPYING.FPC, included in this distribution,
10    for details about the copyright.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
16 **********************************************************************}
17
18{***********************************************************************}
19{                       POSIX TYPE DEFINITIONS                          }
20{***********************************************************************}
21
22{$i ctypes.inc}
23
24{$packrecords c}
25
26type
27  fsblkcnt_t = clonglong;
28  TStatfs = record
29    bsize   : culong;
30    frsize  : culong;
31    blocks  : fsblkcnt_t;
32    bfree   : fsblkcnt_t;
33    bavail  : fsblkcnt_t;
34    files   : fsblkcnt_t;
35    ffree   : fsblkcnt_t;
36    favail  : fsblkcnt_t;
37    fsid    : culong;
38    flag    : culong;
39    namemax : culong;
40  end;
41  PStatFS=^TStatFS;
42
43  mbstate_t = record
44    converter : pointer;
45    charset : array[0..63] of char;
46    count : cuint;
47    data : array[0..1023+8] of char;  { 1024 bytes for data, 8 for alignment space }
48  end;
49  pmbstate_t = ^mbstate_t;
50
51    dev_t    = cint32;         { used for device numbers      }
52    TDev     = dev_t;
53    pDev     = ^dev_t;
54
55    gid_t    = cint32;         { used for group IDs           }
56    TGid     = gid_t;
57    pGid     = ^gid_t;
58    TIOCtlRequest = cuLong;
59
60    ino_t    = cint64;           { used for file serial numbers }
61    TIno     = ino_t;
62    pIno     = ^ino_t;
63
64    mode_t   = cuint32;         { used for file attributes     }
65    TMode    = mode_t;
66    pMode    = ^mode_t;
67
68    nlink_t  = cint32;          { used for link counts         }
69    TnLink   = nlink_t;
70    pnLink   = ^nlink_t;
71
72    off_t    = cint64;          { used for file sizes          }
73    TOff     = off_t;
74    pOff     = ^off_t;
75
76    pid_t    = cint32;          { used as process identifier   }
77    TPid     = pid_t;
78    pPid     = ^pid_t;
79
80{$ifdef cpu64}
81    size_t   = cuint64;         { as definied in the C standard}
82    ssize_t  = cint64;          { used by function for returning number of bytes }
83    time_t   = cint64;           { used for returning the time  }
84{$else}
85    size_t   = cuint32;         { as definied in the C standard}
86    ssize_t  = cint32;          { used by function for returning number of bytes }
87    time_t   = clong;           { used for returning the time  }
88{$endif}
89
90    wint_t   = cint32;
91    TSize    = size_t;
92    pSize    = ^size_t;
93    psize_t  = pSize;
94
95    TsSize   = ssize_t;
96    psSize   = ^ssize_t;
97
98    uid_t    = cuint32;         { used for user ID type        }
99    TUid     = Uid_t;
100    pUid     = ^Uid_t;
101
102    clock_t  = cint32;
103    suseconds_t = cint32;
104    useconds_t = cuint32;
105
106    TClock   = clock_t;
107    pClock   = ^clock_t;
108
109    // TTime    = time_t;    // Not allowed in system unit, -> unixtype
110    pTime    = ^time_t;
111    ptime_t =  ^time_t;
112
113    wchar_t   = cint32;
114    pwchar_t  = ^wchar_t;
115
116    socklen_t= cuint32;
117    TSocklen = socklen_t;
118    pSocklen = ^socklen_t;
119
120    timeval  = record
121      tv_sec: time_t;
122      tv_usec: suseconds_t;
123    end;
124    ptimeval = ^timeval;
125    TTimeVal = timeval;
126
127    timespec = record
128      tv_sec   : time_t;
129      tv_nsec  : clong;
130    end;
131
132    ptimespec= ^timespec;
133    Ttimespec= timespec;
134
135  pthread_t = culong;
136
137  sched_param = record
138    __sched_priority: cint;
139  end;
140
141  pthread_attr_t = record
142    __detachstate: cint;
143    __schedpolicy: cint;
144    __schedparam: sched_param;
145    __inheritsched: cint;
146    __scope: cint;
147    __guardsize: size_t;
148    __stackaddr_set: cint;
149    __stackaddr: pointer;
150    __stacksize: size_t;
151  end;
152
153  _pthread_fastlock = record
154    __status: clong;
155    __spinlock: cint;
156  end;
157
158  pthread_mutex_t = record
159    __m_reserved: cint;
160    __m_count: cint;
161    __m_owner: pointer;
162    __m_kind:  cint;
163    __m_lock: _pthread_fastlock;
164  end;
165
166  pthread_mutexattr_t = record
167    __mutexkind: cint32;
168    process_shared: cbool;
169  end;
170
171  pthread_cond_t = record
172    __c_lock: _pthread_fastlock;
173    __c_waiting: pointer;
174    __padding: array[0..48-1-sizeof(_pthread_fastlock)-sizeof(pointer)-sizeof(clonglong)] of byte;
175    __align: clonglong;
176  end;
177
178  pthread_condattr_t = record
179    __dummy: cint;
180  end;
181
182  pthread_key_t = cuint;
183
184  pthread_rwlock_t = record
185    __rw_readers: cint;
186    __rw_writer: pointer;
187    __rw_read_waiting: pointer;
188    __rw_write_waiting: pointer;
189    __rw_kind: cint;
190    __rw_pshared: cint;
191  end;
192
193  pthread_rwlockattr_t = record
194    __lockkind: cint;
195    __pshared: cint;
196  end;
197
198  sem_t = record
199     __sem_lock: _pthread_fastlock;
200     __sem_value: cint;
201     __sem_waiting: pointer;
202  end;
203
204   rlim_t = int64;
205   TRlim  = rlim_t;
206
207
208CONST
209    _PTHREAD_MUTEX_TIMED_NP      = 0;
210    _PTHREAD_MUTEX_RECURSIVE_NP  = 3;
211    _PTHREAD_MUTEX_ERRORCHECK_NP = 2;
212    _PTHREAD_MUTEX_ADAPTIVE_NP   = 3;
213
214    _PTHREAD_MUTEX_NORMAL     = 1;
215    _PTHREAD_MUTEX_RECURSIVE  = _PTHREAD_MUTEX_RECURSIVE_NP;
216    _PTHREAD_MUTEX_ERRORCHECK = _PTHREAD_MUTEX_ERRORCHECK_NP;
217    _PTHREAD_MUTEX_DEFAULT    = 0;
218    _PTHREAD_MUTEX_FAST_NP    = _PTHREAD_MUTEX_ADAPTIVE_NP;
219
220     _PTHREAD_KEYS_MAX              = 256;
221     _PTHREAD_STACK_MIN             = 1024;
222
223CONST
224   { System limits, POSIX value in parentheses, used for buffer and stack allocation }
225    ARG_MAX  = 65536;   {4096}  { Maximum number of argument size     }
226    NAME_MAX = 255;     {14}    { Maximum number of bytes in filename }
227    PATH_MAX = 1024;    {255}   { Maximum number of bytes in pathname }
228
229    SYS_NMLN = 32;              {BSD utsname struct limit}
230
231    SIG_MAXSIG = 64;    { __MAX_SIGNO in signal.h }
232
233const
234  { For getting/setting priority }
235  Prio_Process = 0;
236  Prio_PGrp    = 1;
237  Prio_User    = 2;
238