OpenCores
URL https://opencores.org/ocsvn/altor32/altor32/trunk

Subversion Repositories altor32

[/] [altor32/] [trunk/] [gcc-x64/] [or1knd-elf/] [or1knd-elf/] [include/] [sys/] [types.h] - Blame information for rev 35

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 35 ultra_embe
/* 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 <machine/_types.h>
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 <sys/_types.h>
62
 
63
#ifdef __i386__
64
#if defined (GO32) || defined (__MSDOS__)
65
#define __MS_types__
66
#endif
67
#endif
68
 
69
# include <stddef.h>
70
# include <machine/types.h>
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 */
101
typedef unsigned long   ulong;          /* System V compatibility */
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
#endif
113
 
114
#ifndef __timespec_defined
115
#define __timespec_defined
116
/* Time Value Specification Structures, P1003.1b-1993, p. 261 */
117
 
118
struct timespec {
119
  time_t  tv_sec;   /* Seconds */
120
  long    tv_nsec;  /* Nanoseconds */
121
};
122
#endif
123
 
124
struct itimerspec {
125
  struct timespec  it_interval;  /* Timer period */
126
  struct timespec  it_value;     /* Timer expiration */
127
};
128
 
129
typedef long    daddr_t;
130
typedef char *  caddr_t;
131
 
132
#ifndef __CYGWIN__
133
#if defined(__MS_types__) || defined(__rtems__) || \
134
    defined(__sparc__) || defined(__SPU__)
135
typedef unsigned long   ino_t;
136
#else
137
typedef unsigned short  ino_t;
138
#endif
139
#endif /*__CYGWIN__*/
140
 
141
#ifdef __MS_types__
142
typedef unsigned long vm_offset_t;
143
typedef unsigned long vm_size_t;
144
 
145
#define __BIT_TYPES_DEFINED__
146
 
147
typedef signed char int8_t;
148
typedef unsigned char u_int8_t;
149
typedef short int16_t;
150
typedef unsigned short u_int16_t;
151
typedef int int32_t;
152
typedef unsigned int u_int32_t;
153
typedef long long int64_t;
154
typedef unsigned long long u_int64_t;
155
typedef int32_t register_t;
156
#endif /* __MS_types__ */
157
 
158
/*
159
 * All these should be machine specific - right now they are all broken.
160
 * However, for all of Cygnus' embedded targets, we want them to all be
161
 * the same.  Otherwise things like sizeof (struct stat) might depend on
162
 * how the file was compiled (e.g. -mint16 vs -mint32, etc.).
163
 */
164
 
165
#ifndef __CYGWIN__      /* which defines these types in it's own types.h. */
166
typedef _off_t  off_t;
167
typedef __dev_t dev_t;
168
typedef __uid_t uid_t;
169
typedef __gid_t gid_t;
170
#endif
171
 
172
#if defined(__XMK__)
173
typedef signed char pid_t;
174
#else
175
typedef int pid_t;
176
#endif
177
 
178
#if defined(__rtems__)
179
typedef _mode_t mode_t;
180
#endif
181
 
182
#ifndef __CYGWIN__
183
typedef long key_t;
184
#endif
185
typedef _ssize_t ssize_t;
186
 
187
#if !defined(__CYGWIN__) && !defined(__rtems__)
188
#ifdef __MS_types__
189
typedef char *  addr_t;
190
typedef int mode_t;
191
#else
192
#if defined (__sparc__) && !defined (__sparc_v9__)
193
#ifdef __svr4__
194
typedef unsigned long mode_t;
195
#else
196
typedef unsigned short mode_t;
197
#endif
198
#else
199
typedef unsigned int mode_t _ST_INT32;
200
#endif
201
#endif /* ! __MS_types__ */
202
#endif /*__CYGWIN__*/
203
 
204
typedef unsigned short nlink_t;
205
 
206
/* We don't define fd_set and friends if we are compiling POSIX
207
   source, or if we have included (or may include as indicated
208
   by __USE_W32_SOCKETS) the W32api winsock[2].h header which
209
   defines Windows versions of them.   Note that a program which
210
   includes the W32api winsock[2].h header must know what it is doing;
211
   it must not call the cygwin32 select function.
212
*/
213
# if !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (_WINSOCKAPI_) || defined (__USE_W32_SOCKETS)) 
214
#  define _SYS_TYPES_FD_SET
215
#  define       NBBY    8               /* number of bits in a byte */
216
/*
217
 * Select uses bit masks of file descriptors in longs.
218
 * These macros manipulate such bit fields (the filesystem macros use chars).
219
 * FD_SETSIZE may be defined by the user, but the default here
220
 * should be >= NOFILE (param.h).
221
 */
222
#  ifndef       FD_SETSIZE
223
#       define  FD_SETSIZE      64
224
#  endif
225
 
226
typedef long    fd_mask;
227
#  define       NFDBITS (sizeof (fd_mask) * NBBY)       /* bits per mask */
228
#  ifndef       howmany
229
#       define  howmany(x,y)    (((x)+((y)-1))/(y))
230
#  endif
231
 
232
/* We use a macro for fd_set so that including Sockets.h afterwards
233
   can work.  */
234
typedef struct _types_fd_set {
235
        fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
236
} _types_fd_set;
237
 
238
#define fd_set _types_fd_set
239
 
240
#  define       FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS)))
241
#  define       FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS)))
242
#  define       FD_ISSET(n, p)  ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS)))
243
#  define       FD_ZERO(p)      (__extension__ (void)({ \
244
     size_t __i; \
245
     char *__tmp = (char *)p; \
246
     for (__i = 0; __i < sizeof (*(p)); ++__i) \
247
       *__tmp++ = 0; \
248
}))
249
 
250
# endif /* !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (_WINSOCKAPI_) || defined (__USE_W32_SOCKETS)) */
251
 
252
#undef __MS_types__
253
#undef _ST_INT32
254
 
255
 
256
#ifndef __clockid_t_defined
257
typedef _CLOCKID_T_ clockid_t;
258
#define __clockid_t_defined
259
#endif
260
 
261
#ifndef __timer_t_defined
262
typedef _TIMER_T_ timer_t;
263
#define __timer_t_defined
264
#endif
265
 
266
typedef unsigned long useconds_t;
267
typedef long suseconds_t;
268
 
269
#include <sys/features.h>
270
 
271
 
272
/* Cygwin will probably never have full posix compliance due to little things
273
 * like an inability to set the stackaddress. Cygwin is also using void *
274
 * pointers rather than structs to ensure maximum binary compatability with
275
 * previous releases.
276
 * This means that we don't use the types defined here, but rather in
277
 * <cygwin/types.h>
278
 */
279
#if defined(_POSIX_THREADS) && !defined(__CYGWIN__)
280
 
281
#include <sys/sched.h>
282
 
283
/*
284
 *  2.5 Primitive System Data Types,  P1003.1c/D10, p. 19.
285
 */
286
 
287
#if defined(__XMK__)
288
typedef unsigned int pthread_t;          /* identify a thread */
289
#else
290
typedef __uint32_t pthread_t;            /* identify a thread */
291
#endif
292
 
293
/* P1003.1c/D10, p. 118-119 */
294
#define PTHREAD_SCOPE_PROCESS 0
295
#define PTHREAD_SCOPE_SYSTEM  1
296
 
297
/* P1003.1c/D10, p. 111 */
298
#define PTHREAD_INHERIT_SCHED  1      /* scheduling policy and associated */
299
                                      /*   attributes are inherited from */
300
                                      /*   the calling thread. */
301
#define PTHREAD_EXPLICIT_SCHED 2      /* set from provided attribute object */
302
 
303
/* P1003.1c/D10, p. 141 */
304
#define PTHREAD_CREATE_DETACHED 0
305
#define PTHREAD_CREATE_JOINABLE  1
306
 
307
#if defined(__XMK__)
308
typedef struct pthread_attr_s {
309
  int contentionscope;
310
  struct sched_param schedparam;
311
  int  detachstate;
312
  void *stackaddr;
313
  size_t stacksize;
314
} pthread_attr_t;
315
 
316
#define PTHREAD_STACK_MIN       200
317
 
318
#else /* !defined(__XMK__) */
319
typedef struct {
320
  int is_initialized;
321
  void *stackaddr;
322
  int stacksize;
323
  int contentionscope;
324
  int inheritsched;
325
  int schedpolicy;
326
  struct sched_param schedparam;
327
#if defined(__rtems__)
328
  size_t guardsize;
329
#endif
330
 
331
  /* P1003.4b/D8, p. 54 adds cputime_clock_allowed attribute.  */
332
#if defined(_POSIX_THREAD_CPUTIME)
333
  int  cputime_clock_allowed;  /* see time.h */
334
#endif
335
  int  detachstate;
336
 
337
} pthread_attr_t;
338
 
339
#endif /* !defined(__XMK__) */
340
 
341
#if defined(_POSIX_THREAD_PROCESS_SHARED)
342
/* NOTE: P1003.1c/D10, p. 81 defines following values for process_shared.  */
343
 
344
#define PTHREAD_PROCESS_PRIVATE 0 /* visible within only the creating process */
345
#define PTHREAD_PROCESS_SHARED  1 /* visible too all processes with access to */
346
                                  /*   the memory where the resource is */
347
                                  /*   located */
348
#endif
349
 
350
#if defined(_POSIX_THREAD_PRIO_PROTECT)
351
/* Mutexes */
352
 
353
/* Values for blocking protocol. */
354
 
355
#define PTHREAD_PRIO_NONE    0
356
#define PTHREAD_PRIO_INHERIT 1
357
#define PTHREAD_PRIO_PROTECT 2
358
#endif
359
 
360
#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
361
 
362
/* Values for mutex type */
363
 
364
/* The following defines are part of the X/Open System Interface (XSI). */
365
 
366
/*
367
 * This type of mutex does not detect deadlock. A thread attempting to
368
 * relock this mutex without first unlocking it shall deadlock. Attempting
369
 * to unlock a mutex locked by a different thread results in undefined
370
 * behavior.  Attempting to unlock an unlocked mutex results in undefined
371
 * behavior.
372
 */
373
#define PTHREAD_MUTEX_NORMAL     0
374
 
375
/*
376
 * A thread attempting to relock this mutex without first unlocking
377
 * it shall succeed in locking the mutex.  The relocking deadlock which
378
 * can occur with mutexes of type PTHREAD_MUTEX_NORMAL cannot occur with
379
 * this type of mutex.  Multiple locks of this mutex shall require the
380
 * same number of unlocks to release the mutex before another thread can
381
 * acquire the mutex. A thread attempting to unlock a mutex which another
382
 * thread has locked shall return with an error.  A thread attempting to
383
 * unlock an unlocked mutex shall return with an error.
384
 */
385
#define PTHREAD_MUTEX_RECURSIVE  1
386
 
387
/*
388
 * This type of mutex provides error checking. A thread attempting
389
 * to relock this mutex without first unlocking it shall return with an
390
 * error. A thread attempting to unlock a mutex which another thread has
391
 * locked shall return with an error. A thread attempting to unlock an
392
 * unlocked mutex shall return with an error.
393
 */
394
#define PTHREAD_MUTEX_ERRORCHECK 2
395
 
396
/*
397
 * Attempting to recursively lock a mutex of this type results
398
 * in undefined behavior. Attempting to unlock a mutex of this type
399
 * which was not locked by the calling thread results in undefined
400
 * behavior. Attempting to unlock a mutex of this type which is not locked
401
 * results in undefined behavior. An implementation may map this mutex to
402
 * one of the other mutex types.
403
 */
404
#define PTHREAD_MUTEX_DEFAULT    3
405
 
406
#endif /* !defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES) */
407
 
408
#if defined(__XMK__)
409
typedef unsigned int pthread_mutex_t;    /* identify a mutex */
410
 
411
typedef struct {
412
  int type;
413
} pthread_mutexattr_t;
414
 
415
#else /* !defined(__XMK__) */
416
typedef __uint32_t pthread_mutex_t;      /* identify a mutex */
417
 
418
typedef struct {
419
  int   is_initialized;
420
#if defined(_POSIX_THREAD_PROCESS_SHARED)
421
  int   process_shared;  /* allow mutex to be shared amongst processes */
422
#endif
423
#if defined(_POSIX_THREAD_PRIO_PROTECT)
424
  int   prio_ceiling;
425
  int   protocol;
426
#endif
427
#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
428
  int type;
429
#endif
430
  int   recursive;
431
} pthread_mutexattr_t;
432
#endif /* !defined(__XMK__) */
433
 
434
/* Condition Variables */
435
 
436
typedef __uint32_t pthread_cond_t;       /* identify a condition variable */
437
 
438
typedef struct {
439
  int   is_initialized;
440
#if defined(_POSIX_THREAD_PROCESS_SHARED)
441
  int   process_shared;       /* allow this to be shared amongst processes */
442
#endif
443
} pthread_condattr_t;         /* a condition attribute object */
444
 
445
/* Keys */
446
 
447
typedef __uint32_t pthread_key_t;        /* thread-specific data keys */
448
 
449
typedef struct {
450
  int   is_initialized;  /* is this structure initialized? */
451
  int   init_executed;   /* has the initialization routine been run? */
452
} pthread_once_t;       /* dynamic package initialization */
453
#else
454
#if defined (__CYGWIN__)
455
#include <cygwin/types.h>
456
#endif
457
#endif /* defined(_POSIX_THREADS) */
458
 
459
/* POSIX Barrier Types */
460
 
461
#if defined(_POSIX_BARRIERS)
462
typedef __uint32_t pthread_barrier_t;        /* POSIX Barrier Object */
463
typedef struct {
464
  int   is_initialized;  /* is this structure initialized? */
465
#if defined(_POSIX_THREAD_PROCESS_SHARED)
466
  int   process_shared;       /* allow this to be shared amongst processes */
467
#endif
468
} pthread_barrierattr_t;
469
#endif /* defined(_POSIX_BARRIERS) */
470
 
471
/* POSIX Spin Lock Types */
472
 
473
#if !defined (__CYGWIN__)
474
#if defined(_POSIX_SPIN_LOCKS)
475
typedef __uint32_t pthread_spinlock_t;        /* POSIX Spin Lock Object */
476
#endif /* defined(_POSIX_SPIN_LOCKS) */
477
 
478
/* POSIX Reader/Writer Lock Types */
479
 
480
#if defined(_POSIX_READER_WRITER_LOCKS)
481
typedef __uint32_t pthread_rwlock_t;         /* POSIX RWLock Object */
482
typedef struct {
483
  int   is_initialized;       /* is this structure initialized? */
484
#if defined(_POSIX_THREAD_PROCESS_SHARED)
485
  int   process_shared;       /* allow this to be shared amongst processes */
486
#endif
487
} pthread_rwlockattr_t;
488
#endif /* defined(_POSIX_READER_WRITER_LOCKS) */
489
#endif /* __CYGWIN__ */
490
 
491
#endif  /* !__need_inttypes */
492
 
493
#undef __need_inttypes
494
 
495
#endif  /* _SYS_TYPES_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.