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:
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
22 #ifndef __INTTYPES_DEFINED__
23 #define __INTTYPES_DEFINED__
25 #include <machine/_types.h>
27 #if defined(__rtems__)
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.
36 typedef __uint8_t u_int8_t
;
38 #if ___int16_t_defined
39 typedef __uint16_t u_int16_t
;
41 #if ___int32_t_defined
42 typedef __uint32_t u_int32_t
;
45 #if ___int64_t_defined
46 typedef __uint64_t u_int64_t
;
49 typedef __uint64_t u_quad_t
;
50 typedef __int64_t quad_t
;
51 typedef quad_t
* qaddr_t
;
56 #endif /* ! __INTTYPES_DEFINED */
58 #ifndef __need_inttypes
61 #include <sys/_types.h>
64 #if defined (GO32) || defined (__MSDOS__)
70 # include <machine/types.h>
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
80 #define _ST_INT32 __attribute__ ((__mode__ (__SI__)))
85 # ifndef _POSIX_SOURCE
87 # define physadr physadr_t
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
99 typedef unsigned short ushort
; /* System V compatibility */
100 typedef unsigned int uint
; /* System V compatibility */
101 # endif /*!_POSIX_SOURCE */
103 #ifndef __clock_t_defined
104 typedef _CLOCK_T_
clock_t;
105 #define __clock_t_defined
108 #ifndef __time_t_defined
109 typedef _TIME_T_
time_t;
110 #define __time_t_defined
112 /* Time Value Specification Structures, P1003.1b-1993, p. 261 */
115 time_t tv_sec
; /* Seconds */
116 long tv_nsec
; /* Nanoseconds */
120 struct timespec it_interval
; /* Timer period */
121 struct timespec it_value
; /* Timer expiration */
125 typedef long daddr_t
;
126 typedef char * caddr_t
;
129 #if defined(__MS_types__) || defined(__rtems__)
130 typedef unsigned long ino_t
;
133 typedef unsigned long ino_t
;
135 typedef unsigned short ino_t
;
138 #endif /*__CYGWIN__*/
141 typedef unsigned long vm_offset_t
;
142 typedef unsigned long vm_size_t
;
144 #define __BIT_TYPES_DEFINED__
146 typedef signed char int8_t;
147 typedef unsigned char u_int8_t
;
148 typedef short int16_t;
149 typedef unsigned short u_int16_t
;
151 typedef unsigned int u_int32_t
;
152 typedef long long int64_t;
153 typedef unsigned long long u_int64_t
;
154 typedef int32_t register_t
;
155 #endif /* __MS_types__ */
158 * All these should be machine specific - right now they are all broken.
159 * However, for all of Cygnus' embedded targets, we want them to all be
160 * the same. Otherwise things like sizeof (struct stat) might depend on
161 * how the file was compiled (e.g. -mint16 vs -mint32, etc.).
164 #if defined(__rtems__)
165 /* device numbers are 32-bit major and and 32-bit minor */
166 typedef unsigned long long dev_t
;
173 #ifndef __CYGWIN__ /* which defines these types in it's own types.h. */
176 typedef unsigned short uid_t
;
177 typedef unsigned short gid_t
;
184 typedef _ssize_t ssize_t
;
188 typedef char * addr_t
;
191 #if defined (__sparc__) && !defined (__sparc_v9__)
193 typedef unsigned long mode_t
;
195 typedef unsigned short mode_t
;
198 typedef unsigned int mode_t _ST_INT32
;
200 #endif /* ! __MS_types__ */
201 #endif /*__CYGWIN__*/
203 typedef unsigned short nlink_t
;
205 /* We don't define fd_set and friends if we are compiling POSIX
206 source, or if we have included (or may include as indicated
207 by __USE_W32_SOCKETS) the W32api winsock[2].h header which
208 defines Windows versions of them. Note that a program which
209 includes the W32api winsock[2].h header must know what it is doing;
210 it must not call the cygwin32 select function.
212 # if !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS))
213 # define _SYS_TYPES_FD_SET
214 # define NBBY 8 /* number of bits in a byte */
216 * Select uses bit masks of file descriptors in longs.
217 * These macros manipulate such bit fields (the filesystem macros use chars).
218 * FD_SETSIZE may be defined by the user, but the default here
219 * should be >= NOFILE (param.h).
222 # define FD_SETSIZE 64
225 typedef long fd_mask
;
226 # define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */
228 # define howmany(x,y) (((x)+((y)-1))/(y))
231 /* We use a macro for fd_set so that including Sockets.h afterwards
233 typedef struct _types_fd_set
{
234 fd_mask fds_bits
[howmany(FD_SETSIZE
, NFDBITS
)];
237 #define fd_set _types_fd_set
239 # define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS)))
240 # define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS)))
241 # define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS)))
242 # define FD_ZERO(p) (__extension__ (void)({ \
244 char *__tmp = (char *)p; \
245 for (__i = 0; __i < sizeof (*(p)); ++__i) \
249 # endif /* !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS)) */
254 /* The following are actually standard POSIX 1003.1b-1993 threads, mutexes,
255 condition variables, and keys. But since RTEMS is currently the only
256 newlib user of these, the ifdef is just on RTEMS. */
258 #if defined(__rtems__) || defined(__CYGWIN__)
260 #ifndef __clockid_t_defined
261 typedef _CLOCKID_T_ clockid_t
;
262 #define __clockid_t_defined
265 #ifndef __timer_t_defined
266 typedef _TIMER_T_ timer_t
;
267 #define __timer_t_defined
270 #if defined(__CYGWIN__) || defined(__rtems__)
271 typedef long useconds_t
;
274 #include <sys/features.h>
277 /* Cygwin will probably never have full posix compliance due to little things
278 * like an inability to set the stackaddress. Cygwin is also using void *
279 * pointers rather than structs to ensure maximum binary compatability with
281 * This means that we don't use the types defined here, but rather in
284 #if defined(_POSIX_THREADS) && !defined(__CYGWIN__)
286 #include <sys/sched.h>
289 * 2.5 Primitive System Data Types, P1003.1c/D10, p. 19.
292 typedef __uint32_t pthread_t
; /* identify a thread */
294 /* P1003.1c/D10, p. 118-119 */
295 #define PTHREAD_SCOPE_PROCESS 0
296 #define PTHREAD_SCOPE_SYSTEM 1
298 /* P1003.1c/D10, p. 111 */
299 #define PTHREAD_INHERIT_SCHED 1 /* scheduling policy and associated */
300 /* attributes are inherited from */
301 /* the calling thread. */
302 #define PTHREAD_EXPLICIT_SCHED 2 /* set from provided attribute object */
304 /* P1003.1c/D10, p. 141 */
305 #define PTHREAD_CREATE_DETACHED 0
306 #define PTHREAD_CREATE_JOINABLE 1
315 struct sched_param schedparam
;
317 /* P1003.4b/D8, p. 54 adds cputime_clock_allowed attribute. */
318 #if defined(_POSIX_THREAD_CPUTIME)
319 int cputime_clock_allowed
; /* see time.h */
325 #if defined(_POSIX_THREAD_PROCESS_SHARED)
326 /* NOTE: P1003.1c/D10, p. 81 defines following values for process_shared. */
328 #define PTHREAD_PROCESS_PRIVATE 0 /* visible within only the creating process */
329 #define PTHREAD_PROCESS_SHARED 1 /* visible too all processes with access to */
330 /* the memory where the resource is */
334 #if defined(_POSIX_THREAD_PRIO_PROTECT)
337 /* Values for blocking protocol. */
339 #define PTHREAD_PRIO_NONE 0
340 #define PTHREAD_PRIO_INHERIT 1
341 #define PTHREAD_PRIO_PROTECT 2
344 typedef __uint32_t pthread_mutex_t
; /* identify a mutex */
348 #if defined(_POSIX_THREAD_PROCESS_SHARED)
349 int process_shared
; /* allow mutex to be shared amongst processes */
351 #if defined(_POSIX_THREAD_PRIO_PROTECT)
356 } pthread_mutexattr_t
;
358 /* Condition Variables */
360 typedef __uint32_t pthread_cond_t
; /* identify a condition variable */
364 #if defined(_POSIX_THREAD_PROCESS_SHARED)
365 int process_shared
; /* allow this to be shared amongst processes */
367 } pthread_condattr_t
; /* a condition attribute object */
371 typedef __uint32_t pthread_key_t
; /* thread-specific data keys */
374 int is_initialized
; /* is this structure initialized? */
375 int init_executed
; /* has the initialization routine been run? */
376 } pthread_once_t
; /* dynamic package initialization */
378 #if defined (__CYGWIN__)
379 #include <cygwin/types.h>
381 #endif /* defined(_POSIX_THREADS) */
383 #endif /* defined(__rtems__) */
385 #endif /* !__need_inttypes */
387 #undef __need_inttypes
389 #endif /* _SYS_TYPES_H */