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
21 #if defined (_WIN32) || defined (__CYGWIN__)
26 #if defined (GO32) || defined (__MSDOS__)
32 # include <machine/types.h>
34 /* To ensure the stat struct's layout doesn't change when sizeof(int), etc.
35 changes, we assume sizeof short and long never change and have all types
36 used to define struct stat use them and not int where possible.
37 Where not possible, _ST_INTxx are used. It would be preferable to not have
38 such assumptions, but until the extra fluff is necessary, it's avoided.
39 No 64 bit targets use stat yet. What to do about them is postponed
42 #define _ST_INT32 __attribute__ ((__mode__ (__SI__)))
47 # ifndef _POSIX_SOURCE
49 # define physadr physadr_t
52 #ifndef _BSDTYPES_DEFINED
53 /* also defined in mingw/gmon.h and in w32api/winsock[2].h */
54 typedef unsigned char u_char
;
55 typedef unsigned short u_short
;
56 typedef unsigned int u_int
;
57 typedef unsigned long u_long
;
58 #define _BSDTYPES_DEFINED
61 typedef unsigned short ushort
; /* System V compatibility */
62 typedef unsigned int uint
; /* System V compatibility */
63 # endif /*!_POSIX_SOURCE */
65 #ifndef __clock_t_defined
66 typedef _CLOCK_T_
clock_t;
67 #define __clock_t_defined
70 #ifndef __time_t_defined
71 typedef _TIME_T_
time_t;
72 #define __time_t_defined
74 /* Time Value Specification Structures, P1003.1b-1993, p. 261 */
77 time_t tv_sec
; /* Seconds */
78 long tv_nsec
; /* Nanoseconds */
82 struct timespec it_interval
; /* Timer period */
83 struct timespec it_value
; /* Timer expiration */
88 typedef char * caddr_t
;
90 #if defined(__MS_types__) || defined(__rtems__)
91 typedef unsigned long ino_t
;
94 typedef unsigned long ino_t
;
96 typedef unsigned short ino_t
;
101 typedef unsigned long vm_offset_t
;
102 typedef unsigned long vm_size_t
;
104 #define __BIT_TYPES_DEFINED__
107 typedef unsigned char u_int8_t
;
108 typedef short int16_t;
109 typedef unsigned short u_int16_t
;
111 typedef unsigned int u_int32_t
;
112 typedef long long int64_t;
113 typedef unsigned long long u_int64_t
;
114 typedef int32_t register_t
;
115 #endif /* __MS_types__ */
118 * All these should be machine specific - right now they are all broken.
119 * However, for all of Cygnus' embedded targets, we want them to all be
120 * the same. Otherwise things like sizeof (struct stat) might depend on
121 * how the file was compiled (e.g. -mint16 vs -mint32, etc.).
124 #if defined(__rtems__)
125 /* device numbers are 32-bit major and and 32-bit minor */
126 typedef unsigned long long dev_t
;
131 #ifndef __CYGWIN__ /* which defines these types in it's own types.h. */
134 typedef unsigned short uid_t
;
135 typedef unsigned short gid_t
;
140 typedef long ssize_t
;
143 typedef char * addr_t
;
146 #if defined (__sparc__) && !defined (__sparc_v9__)
148 typedef unsigned long mode_t
;
150 typedef unsigned short mode_t
;
153 typedef unsigned int mode_t _ST_INT32
;
155 #endif /* ! __MS_types__ */
157 typedef unsigned short nlink_t
;
159 /* We don't define fd_set and friends if we are compiling POSIX
160 source, or if we have included (or may include as indicated
161 by __USE_W32_SOCKETS) the W32api winsock[2].h header which
162 defines Windows versions of them. Note that a program which
163 includes the W32api winsock[2].h header must know what it is doing;
164 it must not call the cygwin32 select function.
166 # if !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS))
167 # define _SYS_TYPES_FD_SET
168 # define NBBY 8 /* number of bits in a byte */
170 * Select uses bit masks of file descriptors in longs.
171 * These macros manipulate such bit fields (the filesystem macros use chars).
172 * FD_SETSIZE may be defined by the user, but the default here
173 * should be >= NOFILE (param.h).
176 # define FD_SETSIZE 64
179 typedef long fd_mask
;
180 # define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */
182 # define howmany(x,y) (((x)+((y)-1))/(y))
185 /* We use a macro for fd_set so that including Sockets.h afterwards
187 typedef struct _types_fd_set
{
188 fd_mask fds_bits
[howmany(FD_SETSIZE
, NFDBITS
)];
191 #define fd_set _types_fd_set
193 # define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS)))
194 # define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS)))
195 # define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS)))
196 # define FD_ZERO(p) (__extension__ (void)({ \
198 char *__tmp = (char *)p; \
199 for (__i = 0; __i < sizeof (*(p)); ++__i) \
203 # endif /* !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS)) */
208 /* The following are actually standard POSIX 1003.1b-1993 threads, mutexes,
209 condition variables, and keys. But since RTEMS is currently the only
210 newlib user of these, the ifdef is just on RTEMS. */
212 #if defined(__rtems__) || defined(__CYGWIN__)
214 #ifndef __clockid_t_defined
215 typedef _CLOCKID_T_ clockid_t
;
216 #define __clockid_t_defined
219 #ifndef __timer_t_defined
220 typedef _TIMER_T_ timer_t
;
221 #define __timer_t_defined
224 #if defined(__CYGWIN__) || defined(__rtems__)
225 typedef long useconds_t
;
228 #include <sys/features.h>
231 /* Cygwin will probably never have full posix compliance due to little things
232 * like an inability to set the stackaddress. Cygwin is also using void *
233 * pointers rather than structs to ensure maximum binary compatability with
235 * This means that we don't use the types defined here, but rather in
238 #if defined(_POSIX_THREADS) && !defined(__CYGWIN__)
240 #include <sys/sched.h>
243 * 2.5 Primitive System Data Types, P1003.1c/D10, p. 19.
246 typedef __uint32_t pthread_t
; /* identify a thread */
248 /* P1003.1c/D10, p. 118-119 */
249 #define PTHREAD_SCOPE_PROCESS 0
250 #define PTHREAD_SCOPE_SYSTEM 1
252 /* P1003.1c/D10, p. 111 */
253 #define PTHREAD_INHERIT_SCHED 1 /* scheduling policy and associated */
254 /* attributes are inherited from */
255 /* the calling thread. */
256 #define PTHREAD_EXPLICIT_SCHED 2 /* set from provided attribute object */
258 /* P1003.1c/D10, p. 141 */
259 #define PTHREAD_CREATE_DETACHED 0
260 #define PTHREAD_CREATE_JOINABLE 1
269 struct sched_param schedparam
;
271 /* P1003.4b/D8, p. 54 adds cputime_clock_allowed attribute. */
272 #if defined(_POSIX_THREAD_CPUTIME)
273 int cputime_clock_allowed
; /* see time.h */
279 #if defined(_POSIX_THREAD_PROCESS_SHARED)
280 /* NOTE: P1003.1c/D10, p. 81 defines following values for process_shared. */
282 #define PTHREAD_PROCESS_PRIVATE 0 /* visible within only the creating process */
283 #define PTHREAD_PROCESS_SHARED 1 /* visible too all processes with access to */
284 /* the memory where the resource is */
288 #if defined(_POSIX_THREAD_PRIO_PROTECT)
291 /* Values for blocking protocol. */
293 #define PTHREAD_PRIO_NONE 0
294 #define PTHREAD_PRIO_INHERIT 1
295 #define PTHREAD_PRIO_PROTECT 2
298 typedef __uint32_t pthread_mutex_t
; /* identify a mutex */
302 #if defined(_POSIX_THREAD_PROCESS_SHARED)
303 int process_shared
; /* allow mutex to be shared amongst processes */
305 #if defined(_POSIX_THREAD_PRIO_PROTECT)
310 } pthread_mutexattr_t
;
312 /* Condition Variables */
314 typedef __uint32_t pthread_cond_t
; /* identify a condition variable */
318 #if defined(_POSIX_THREAD_PROCESS_SHARED)
319 int process_shared
; /* allow this to be shared amongst processes */
321 } pthread_condattr_t
; /* a condition attribute object */
325 typedef __uint32_t pthread_key_t
; /* thread-specific data keys */
328 int is_initialized
; /* is this structure initialized? */
329 int init_executed
; /* has the initialization routine been run? */
330 } pthread_once_t
; /* dynamic package initialization */
332 #if defined (__CYGWIN__)
333 #include <cygwin/types.h>
335 #endif /* defined(_POSIX_THREADS) */
337 #endif /* defined(__rtems__) */
339 #endif /* _SYS_TYPES_H */