Rev 2168 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1693 | serge | 1 | /* unified sys/types.h: |
2 | start with sef's sysvi386 version. |
||
3 | merge go32 version -- a few ifdefs. |
||
4 | h8300hms, h8300xray, and sysvnecv70 disagree on the following types: |
||
5 | |||
6 | typedef int gid_t; |
||
7 | typedef int uid_t; |
||
8 | typedef int dev_t; |
||
9 | typedef int ino_t; |
||
10 | typedef int mode_t; |
||
11 | typedef int caddr_t; |
||
12 | |||
13 | however, these aren't "reasonable" values, the sysvi386 ones make far |
||
14 | more sense, and should work sufficiently well (in particular, h8300 |
||
15 | doesn't have a stat, and the necv70 doesn't matter.) -- eichin |
||
16 | */ |
||
17 | |||
18 | #ifndef _SYS_TYPES_H |
||
19 | |||
20 | #include <_ansi.h> |
||
21 | |||
22 | #ifndef __INTTYPES_DEFINED__ |
||
23 | #define __INTTYPES_DEFINED__ |
||
24 | |||
25 | #include |
||
26 | |||
27 | #if defined(__rtems__) || defined(__XMK__) |
||
28 | /* |
||
29 | * The following section is RTEMS specific and is needed to more |
||
30 | * closely match the types defined in the BSD sys/types.h. |
||
31 | * This is needed to let the RTEMS/BSD TCP/IP stack compile. |
||
32 | */ |
||
33 | |||
34 | /* deprecated */ |
||
35 | #if ___int8_t_defined |
||
36 | typedef __uint8_t u_int8_t; |
||
37 | #endif |
||
38 | #if ___int16_t_defined |
||
39 | typedef __uint16_t u_int16_t; |
||
40 | #endif |
||
41 | #if ___int32_t_defined |
||
42 | typedef __uint32_t u_int32_t; |
||
43 | #endif |
||
44 | |||
45 | #if ___int64_t_defined |
||
46 | typedef __uint64_t u_int64_t; |
||
47 | |||
48 | /* deprecated */ |
||
49 | typedef __uint64_t u_quad_t; |
||
50 | typedef __int64_t quad_t; |
||
51 | typedef quad_t * qaddr_t; |
||
52 | #endif |
||
53 | |||
54 | #endif |
||
55 | |||
56 | #endif /* ! __INTTYPES_DEFINED */ |
||
57 | |||
58 | #ifndef __need_inttypes |
||
59 | |||
60 | #define _SYS_TYPES_H |
||
61 | #include |
||
62 | |||
63 | #ifdef __i386__ |
||
64 | #if defined (GO32) || defined (__MSDOS__) |
||
65 | #define __MS_types__ |
||
66 | #endif |
||
67 | #endif |
||
68 | |||
69 | # include |
||
70 | # include |
||
71 | |||
72 | /* To ensure the stat struct's layout doesn't change when sizeof(int), etc. |
||
73 | changes, we assume sizeof short and long never change and have all types |
||
74 | used to define struct stat use them and not int where possible. |
||
75 | Where not possible, _ST_INTxx are used. It would be preferable to not have |
||
76 | such assumptions, but until the extra fluff is necessary, it's avoided. |
||
77 | No 64 bit targets use stat yet. What to do about them is postponed |
||
78 | until necessary. */ |
||
79 | #ifdef __GNUC__ |
||
80 | #define _ST_INT32 __attribute__ ((__mode__ (__SI__))) |
||
81 | #else |
||
82 | #define _ST_INT32 |
||
83 | #endif |
||
84 | |||
85 | # ifndef _POSIX_SOURCE |
||
86 | |||
87 | # define physadr physadr_t |
||
88 | # define quad quad_t |
||
89 | |||
90 | #ifndef _BSDTYPES_DEFINED |
||
91 | /* also defined in mingw/gmon.h and in w32api/winsock[2].h */ |
||
92 | typedef unsigned char u_char; |
||
93 | typedef unsigned short u_short; |
||
94 | typedef unsigned int u_int; |
||
95 | typedef unsigned long u_long; |
||
96 | #define _BSDTYPES_DEFINED |
||
97 | #endif |
||
98 | |||
99 | typedef unsigned short ushort; /* System V compatibility */ |
||
100 | typedef unsigned int uint; /* System V compatibility */ |
||
3065 | serge | 101 | typedef unsigned long ulong; /* System V compatibility */ |
1693 | serge | 102 | # endif /*!_POSIX_SOURCE */ |
103 | |||
104 | #ifndef __clock_t_defined |
||
105 | typedef _CLOCK_T_ clock_t; |
||
106 | #define __clock_t_defined |
||
107 | #endif |
||
108 | |||
109 | #ifndef __time_t_defined |
||
110 | typedef _TIME_T_ time_t; |
||
111 | #define __time_t_defined |
||
112 | |||
113 | /* Time Value Specification Structures, P1003.1b-1993, p. 261 */ |
||
114 | |||
115 | struct timespec { |
||
116 | time_t tv_sec; /* Seconds */ |
||
117 | long tv_nsec; /* Nanoseconds */ |
||
118 | }; |
||
119 | |||
120 | struct itimerspec { |
||
121 | struct timespec it_interval; /* Timer period */ |
||
122 | struct timespec it_value; /* Timer expiration */ |
||
123 | }; |
||
124 | #endif |
||
125 | |||
126 | typedef long daddr_t; |
||
127 | typedef char * caddr_t; |
||
128 | |||
129 | #ifndef __CYGWIN__ |
||
130 | #if defined(__MS_types__) || defined(__rtems__) || \ |
||
131 | defined(__sparc__) || defined(__SPU__) |
||
132 | typedef unsigned long ino_t; |
||
133 | #else |
||
134 | typedef unsigned short ino_t; |
||
135 | #endif |
||
136 | #endif /*__CYGWIN__*/ |
||
137 | |||
138 | #ifdef __MS_types__ |
||
139 | typedef unsigned long vm_offset_t; |
||
140 | typedef unsigned long vm_size_t; |
||
141 | |||
142 | #define __BIT_TYPES_DEFINED__ |
||
143 | |||
144 | typedef signed char int8_t; |
||
145 | typedef unsigned char u_int8_t; |
||
146 | typedef short int16_t; |
||
147 | typedef unsigned short u_int16_t; |
||
148 | typedef int int32_t; |
||
149 | typedef unsigned int u_int32_t; |
||
150 | typedef long long int64_t; |
||
151 | typedef unsigned long long u_int64_t; |
||
152 | typedef int32_t register_t; |
||
153 | #endif /* __MS_types__ */ |
||
154 | |||
155 | /* |
||
156 | * All these should be machine specific - right now they are all broken. |
||
157 | * However, for all of Cygnus' embedded targets, we want them to all be |
||
158 | * the same. Otherwise things like sizeof (struct stat) might depend on |
||
159 | * how the file was compiled (e.g. -mint16 vs -mint32, etc.). |
||
160 | */ |
||
161 | |||
162 | #ifndef __CYGWIN__ /* which defines these types in it's own types.h. */ |
||
163 | typedef _off_t off_t; |
||
164 | typedef __dev_t dev_t; |
||
165 | typedef __uid_t uid_t; |
||
166 | typedef __gid_t gid_t; |
||
167 | #endif |
||
168 | |||
169 | #if defined(__XMK__) |
||
170 | typedef signed char pid_t; |
||
171 | #else |
||
172 | typedef int pid_t; |
||
173 | #endif |
||
174 | |||
2168 | serge | 175 | #if defined(__rtems__) |
176 | typedef _mode_t mode_t; |
||
177 | #endif |
||
178 | |||
1693 | serge | 179 | #ifndef __CYGWIN__ |
180 | typedef long key_t; |
||
181 | #endif |
||
182 | typedef _ssize_t ssize_t; |
||
183 | |||
2168 | serge | 184 | #if !defined(__CYGWIN__) && !defined(__rtems__) |
1693 | serge | 185 | #ifdef __MS_types__ |
186 | typedef char * addr_t; |
||
187 | typedef int mode_t; |
||
188 | #else |
||
189 | #if defined (__sparc__) && !defined (__sparc_v9__) |
||
190 | #ifdef __svr4__ |
||
191 | typedef unsigned long mode_t; |
||
192 | #else |
||
193 | typedef unsigned short mode_t; |
||
194 | #endif |
||
195 | #else |
||
196 | typedef unsigned int mode_t _ST_INT32; |
||
197 | #endif |
||
198 | #endif /* ! __MS_types__ */ |
||
199 | #endif /*__CYGWIN__*/ |
||
200 | |||
201 | typedef unsigned short nlink_t; |
||
202 | |||
203 | /* We don't define fd_set and friends if we are compiling POSIX |
||
204 | source, or if we have included (or may include as indicated |
||
205 | by __USE_W32_SOCKETS) the W32api winsock[2].h header which |
||
206 | defines Windows versions of them. Note that a program which |
||
207 | includes the W32api winsock[2].h header must know what it is doing; |
||
208 | it must not call the cygwin32 select function. |
||
209 | */ |
||
210 | # if !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS)) |
||
211 | # define _SYS_TYPES_FD_SET |
||
212 | # define NBBY 8 /* number of bits in a byte */ |
||
213 | /* |
||
214 | * Select uses bit masks of file descriptors in longs. |
||
215 | * These macros manipulate such bit fields (the filesystem macros use chars). |
||
216 | * FD_SETSIZE may be defined by the user, but the default here |
||
217 | * should be >= NOFILE (param.h). |
||
218 | */ |
||
219 | # ifndef FD_SETSIZE |
||
220 | # define FD_SETSIZE 64 |
||
221 | # endif |
||
222 | |||
223 | typedef long fd_mask; |
||
224 | # define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */ |
||
225 | # ifndef howmany |
||
226 | # define howmany(x,y) (((x)+((y)-1))/(y)) |
||
227 | # endif |
||
228 | |||
229 | /* We use a macro for fd_set so that including Sockets.h afterwards |
||
230 | can work. */ |
||
231 | typedef struct _types_fd_set { |
||
232 | fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; |
||
233 | } _types_fd_set; |
||
234 | |||
235 | #define fd_set _types_fd_set |
||
236 | |||
237 | # define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS))) |
||
238 | # define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS))) |
||
239 | # define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS))) |
||
240 | # define FD_ZERO(p) (__extension__ (void)({ \ |
||
241 | size_t __i; \ |
||
242 | char *__tmp = (char *)p; \ |
||
243 | for (__i = 0; __i < sizeof (*(p)); ++__i) \ |
||
244 | *__tmp++ = 0; \ |
||
245 | })) |
||
246 | |||
247 | # endif /* !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS)) */ |
||
248 | |||
249 | #undef __MS_types__ |
||
250 | #undef _ST_INT32 |
||
251 | |||
252 | |||
253 | #ifndef __clockid_t_defined |
||
254 | typedef _CLOCKID_T_ clockid_t; |
||
255 | #define __clockid_t_defined |
||
256 | #endif |
||
257 | |||
258 | #ifndef __timer_t_defined |
||
259 | typedef _TIMER_T_ timer_t; |
||
260 | #define __timer_t_defined |
||
261 | #endif |
||
262 | |||
263 | typedef unsigned long useconds_t; |
||
264 | typedef long suseconds_t; |
||
265 | |||
266 | #include |
||
267 | |||
268 | |||
269 | /* Cygwin will probably never have full posix compliance due to little things |
||
270 | * like an inability to set the stackaddress. Cygwin is also using void * |
||
271 | * pointers rather than structs to ensure maximum binary compatability with |
||
272 | * previous releases. |
||
273 | * This means that we don't use the types defined here, but rather in |
||
274 | * |
||
275 | */ |
||
276 | #if defined(_POSIX_THREADS) && !defined(__CYGWIN__) |
||
277 | |||
278 | #include |
||
279 | |||
280 | /* |
||
281 | * 2.5 Primitive System Data Types, P1003.1c/D10, p. 19. |
||
282 | */ |
||
283 | |||
284 | #if defined(__XMK__) |
||
285 | typedef unsigned int pthread_t; /* identify a thread */ |
||
286 | #else |
||
287 | typedef __uint32_t pthread_t; /* identify a thread */ |
||
288 | #endif |
||
289 | |||
290 | /* P1003.1c/D10, p. 118-119 */ |
||
291 | #define PTHREAD_SCOPE_PROCESS 0 |
||
292 | #define PTHREAD_SCOPE_SYSTEM 1 |
||
293 | |||
294 | /* P1003.1c/D10, p. 111 */ |
||
295 | #define PTHREAD_INHERIT_SCHED 1 /* scheduling policy and associated */ |
||
296 | /* attributes are inherited from */ |
||
297 | /* the calling thread. */ |
||
298 | #define PTHREAD_EXPLICIT_SCHED 2 /* set from provided attribute object */ |
||
299 | |||
300 | /* P1003.1c/D10, p. 141 */ |
||
301 | #define PTHREAD_CREATE_DETACHED 0 |
||
302 | #define PTHREAD_CREATE_JOINABLE 1 |
||
303 | |||
304 | #if defined(__XMK__) || defined(__rtems__) |
||
305 | /* The following defines are part of the X/Open System Interface (XSI). */ |
||
306 | |||
307 | /* This type of mutex does not detect deadlock. A thread attempting to relock this mutex without first unlocking |
||
308 | * it shall deadlock. Attempting to unlock a mutex locked by a different thread results in undefined behavior. |
||
309 | * Attempting to unlock an unlocked mutex results in undefined behavior. |
||
310 | */ |
||
311 | #define PTHREAD_MUTEX_NORMAL 1 |
||
312 | |||
313 | /* |
||
314 | * This type of mutex provides error checking. A thread attempting to relock this mutex without first unlocking |
||
315 | * it shall return with an error. A thread attempting to unlock a mutex which another thread has locked shall return |
||
316 | * with an error. A thread attempting to unlock an unlocked mutex shall return with an error. |
||
317 | */ |
||
318 | #define PTHREAD_MUTEX_ERRORCHECK 2 |
||
319 | |||
320 | /* A thread attempting to relock this mutex without first unlocking it shall succeed in locking the mutex. |
||
321 | * The relocking deadlock which can occur with mutexes of type PTHREAD_MUTEX_NORMAL cannot occur with this type of mutex. |
||
322 | * Multiple locks of this mutex shall require the same number of unlocks to release the mutex before another thread can |
||
323 | * acquire the mutex. A thread attempting to unlock a mutex which another thread has locked shall return with an error. |
||
324 | * A thread attempting to unlock an unlocked mutex shall return with an error. |
||
325 | */ |
||
326 | #define PTHREAD_MUTEX_RECURSIVE 3 |
||
327 | |||
328 | /* Attempting to recursively lock a mutex of this type results in undefined behavior. Attempting to unlock a |
||
329 | * mutex of this type which was not locked by the calling thread results in undefined behavior. Attempting to |
||
330 | * unlock a mutex of this type which is not locked results in undefined behavior. An implementation may map this |
||
331 | * mutex to one of the other mutex types. |
||
332 | */ |
||
333 | #define PTHREAD_MUTEX_DEFAULT 4 |
||
334 | |||
335 | #endif /* defined(__XMK__) || defined(__rtems__) */ |
||
336 | |||
337 | #if defined(__XMK__) |
||
338 | typedef struct pthread_attr_s { |
||
339 | int contentionscope; |
||
340 | struct sched_param schedparam; |
||
341 | int detachstate; |
||
342 | void *stackaddr; |
||
343 | size_t stacksize; |
||
344 | } pthread_attr_t; |
||
345 | |||
346 | #define PTHREAD_STACK_MIN 200 |
||
347 | |||
348 | #else /* !defined(__XMK__) */ |
||
349 | typedef struct { |
||
350 | int is_initialized; |
||
351 | void *stackaddr; |
||
352 | int stacksize; |
||
353 | int contentionscope; |
||
354 | int inheritsched; |
||
355 | int schedpolicy; |
||
356 | struct sched_param schedparam; |
||
2168 | serge | 357 | #if defined(__rtems__) |
358 | size_t guardsize; |
||
359 | #endif |
||
1693 | serge | 360 | |
361 | /* P1003.4b/D8, p. 54 adds cputime_clock_allowed attribute. */ |
||
362 | #if defined(_POSIX_THREAD_CPUTIME) |
||
363 | int cputime_clock_allowed; /* see time.h */ |
||
364 | #endif |
||
365 | int detachstate; |
||
366 | |||
367 | } pthread_attr_t; |
||
368 | |||
369 | #endif /* !defined(__XMK__) */ |
||
370 | |||
371 | #if defined(_POSIX_THREAD_PROCESS_SHARED) |
||
372 | /* NOTE: P1003.1c/D10, p. 81 defines following values for process_shared. */ |
||
373 | |||
374 | #define PTHREAD_PROCESS_PRIVATE 0 /* visible within only the creating process */ |
||
375 | #define PTHREAD_PROCESS_SHARED 1 /* visible too all processes with access to */ |
||
376 | /* the memory where the resource is */ |
||
377 | /* located */ |
||
378 | #endif |
||
379 | |||
380 | #if defined(_POSIX_THREAD_PRIO_PROTECT) |
||
381 | /* Mutexes */ |
||
382 | |||
383 | /* Values for blocking protocol. */ |
||
384 | |||
385 | #define PTHREAD_PRIO_NONE 0 |
||
386 | #define PTHREAD_PRIO_INHERIT 1 |
||
387 | #define PTHREAD_PRIO_PROTECT 2 |
||
388 | #endif |
||
389 | |||
390 | #if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES) |
||
391 | |||
392 | /* Values for mutex type */ |
||
393 | |||
394 | #define PTHREAD_MUTEX_NORMAL 0 |
||
395 | #define PTHREAD_MUTEX_RECURSIVE 1 |
||
396 | #define PTHREAD_MUTEX_ERRORCHECK 2 |
||
397 | #define PTHREAD_MUTEX_DEFAULT 3 |
||
398 | |||
399 | #endif |
||
400 | |||
401 | #if defined(__XMK__) |
||
402 | typedef unsigned int pthread_mutex_t; /* identify a mutex */ |
||
403 | |||
404 | typedef struct { |
||
405 | int type; |
||
406 | } pthread_mutexattr_t; |
||
407 | |||
408 | #else /* !defined(__XMK__) */ |
||
409 | typedef __uint32_t pthread_mutex_t; /* identify a mutex */ |
||
410 | |||
411 | typedef struct { |
||
412 | int is_initialized; |
||
413 | #if defined(_POSIX_THREAD_PROCESS_SHARED) |
||
414 | int process_shared; /* allow mutex to be shared amongst processes */ |
||
415 | #endif |
||
416 | #if defined(_POSIX_THREAD_PRIO_PROTECT) |
||
417 | int prio_ceiling; |
||
418 | int protocol; |
||
419 | #endif |
||
420 | #if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES) |
||
421 | int type; |
||
422 | #endif |
||
423 | int recursive; |
||
424 | } pthread_mutexattr_t; |
||
425 | #endif /* !defined(__XMK__) */ |
||
426 | |||
427 | /* Condition Variables */ |
||
428 | |||
429 | typedef __uint32_t pthread_cond_t; /* identify a condition variable */ |
||
430 | |||
431 | typedef struct { |
||
432 | int is_initialized; |
||
433 | #if defined(_POSIX_THREAD_PROCESS_SHARED) |
||
434 | int process_shared; /* allow this to be shared amongst processes */ |
||
435 | #endif |
||
436 | } pthread_condattr_t; /* a condition attribute object */ |
||
437 | |||
438 | /* Keys */ |
||
439 | |||
440 | typedef __uint32_t pthread_key_t; /* thread-specific data keys */ |
||
441 | |||
442 | typedef struct { |
||
443 | int is_initialized; /* is this structure initialized? */ |
||
444 | int init_executed; /* has the initialization routine been run? */ |
||
445 | } pthread_once_t; /* dynamic package initialization */ |
||
446 | #else |
||
447 | #if defined (__CYGWIN__) |
||
448 | #include |
||
449 | #endif |
||
450 | #endif /* defined(_POSIX_THREADS) */ |
||
451 | |||
452 | /* POSIX Barrier Types */ |
||
453 | |||
454 | #if defined(_POSIX_BARRIERS) |
||
455 | typedef __uint32_t pthread_barrier_t; /* POSIX Barrier Object */ |
||
456 | typedef struct { |
||
457 | int is_initialized; /* is this structure initialized? */ |
||
458 | #if defined(_POSIX_THREAD_PROCESS_SHARED) |
||
459 | int process_shared; /* allow this to be shared amongst processes */ |
||
460 | #endif |
||
461 | } pthread_barrierattr_t; |
||
462 | #endif /* defined(_POSIX_BARRIERS) */ |
||
463 | |||
464 | /* POSIX Spin Lock Types */ |
||
465 | |||
466 | #if defined(_POSIX_SPIN_LOCKS) |
||
467 | typedef __uint32_t pthread_spinlock_t; /* POSIX Spin Lock Object */ |
||
468 | #endif /* defined(_POSIX_SPIN_LOCKS) */ |
||
469 | |||
470 | /* POSIX Reader/Writer Lock Types */ |
||
471 | |||
472 | #if !defined (__CYGWIN__) |
||
473 | #if defined(_POSIX_READER_WRITER_LOCKS) |
||
474 | typedef __uint32_t pthread_rwlock_t; /* POSIX RWLock Object */ |
||
475 | typedef struct { |
||
476 | int is_initialized; /* is this structure initialized? */ |
||
477 | #if defined(_POSIX_THREAD_PROCESS_SHARED) |
||
478 | int process_shared; /* allow this to be shared amongst processes */ |
||
479 | #endif |
||
480 | } pthread_rwlockattr_t; |
||
481 | #endif /* defined(_POSIX_READER_WRITER_LOCKS) */ |
||
482 | #endif /* __CYGWIN__ */ |
||
483 | |||
484 | #endif /* !__need_inttypes */ |
||
485 | |||
486 | #undef __need_inttypes |
||
487 | |||
488 | #endif /* _SYS_TYPES_H */>><>><>><> |