]> sourceware.org Git - newlib-cygwin.git/blob - newlib/libc/include/sys/types.h
* libc/include/sys/types.h: Define useconds_t.
[newlib-cygwin.git] / newlib / libc / include / sys / types.h
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 #define _SYS_TYPES_H
20
21 #if defined (_WIN32) || defined (__CYGWIN__)
22 #define __MS_types__
23 #endif
24
25 #ifdef __i386__
26 #if defined (GO32) || defined (__MSDOS__)
27 #define __MS_types__
28 #endif
29 #endif
30
31 # include <stddef.h>
32 # include <machine/types.h>
33
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
40 until necessary. */
41 #ifdef __GNUC__
42 #define _ST_INT32 __attribute__ ((__mode__ (__SI__)))
43 #else
44 #define _ST_INT32
45 #endif
46
47 # ifndef _POSIX_SOURCE
48
49 # define physadr physadr_t
50 # define quad quad_t
51
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
59 #endif
60
61 typedef unsigned short ushort; /* System V compatibility */
62 typedef unsigned int uint; /* System V compatibility */
63 # endif /*!_POSIX_SOURCE */
64
65 #ifndef __clock_t_defined
66 typedef _CLOCK_T_ clock_t;
67 #define __clock_t_defined
68 #endif
69
70 #ifndef __time_t_defined
71 typedef _TIME_T_ time_t;
72 #define __time_t_defined
73
74 /* Time Value Specification Structures, P1003.1b-1993, p. 261 */
75
76 struct timespec {
77 time_t tv_sec; /* Seconds */
78 long tv_nsec; /* Nanoseconds */
79 };
80
81 struct itimerspec {
82 struct timespec it_interval; /* Timer period */
83 struct timespec it_value; /* Timer expiration */
84 };
85 #endif
86
87 typedef long daddr_t;
88 typedef char * caddr_t;
89
90 #ifdef __MS_types__
91 typedef unsigned long ino_t;
92 #else
93 #ifdef __sparc__
94 typedef unsigned long ino_t;
95 #else
96 typedef unsigned short ino_t;
97 #endif
98 #endif
99
100 #ifdef __MS_types__
101 typedef unsigned long vm_offset_t;
102 typedef unsigned long vm_size_t;
103
104 #define __BIT_TYPES_DEFINED__
105
106 typedef char int8_t;
107 typedef unsigned char u_int8_t;
108 typedef short int16_t;
109 typedef unsigned short u_int16_t;
110 typedef int int32_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__ */
116
117 /*
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.).
122 */
123
124 #if defined(__rtems__)
125 /* device numbers are 32-bit major and and 32-bit minor */
126 typedef unsigned long long dev_t;
127 #else
128 typedef short dev_t;
129 #endif
130
131 typedef long off_t;
132
133 typedef unsigned short uid_t;
134 typedef unsigned short gid_t;
135 typedef int pid_t;
136 typedef long key_t;
137 typedef long ssize_t;
138
139 #ifdef __MS_types__
140 typedef char * addr_t;
141 typedef int mode_t;
142 #else
143 #if defined (__sparc__) && !defined (__sparc_v9__)
144 #ifdef __svr4__
145 typedef unsigned long mode_t;
146 #else
147 typedef unsigned short mode_t;
148 #endif
149 #else
150 typedef unsigned int mode_t _ST_INT32;
151 #endif
152 #endif /* ! __MS_types__ */
153
154 typedef unsigned short nlink_t;
155
156 /* We don't define fd_set and friends if we are compiling POSIX
157 source, or if we have included (or may include as indicated
158 by __USE_W32_SOCKETS) the W32api winsock[2].h header which
159 defines Windows versions of them. Note that a program which
160 includes the W32api winsock[2].h header must know what it is doing;
161 it must not call the cygwin32 select function.
162 */
163 # if !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS))
164 # define _SYS_TYPES_FD_SET
165 # define NBBY 8 /* number of bits in a byte */
166 /*
167 * Select uses bit masks of file descriptors in longs.
168 * These macros manipulate such bit fields (the filesystem macros use chars).
169 * FD_SETSIZE may be defined by the user, but the default here
170 * should be >= NOFILE (param.h).
171 */
172 # ifndef FD_SETSIZE
173 # define FD_SETSIZE 64
174 # endif
175
176 typedef long fd_mask;
177 # define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */
178 # ifndef howmany
179 # define howmany(x,y) (((x)+((y)-1))/(y))
180 # endif
181
182 /* We use a macro for fd_set so that including Sockets.h afterwards
183 can work. */
184 typedef struct _types_fd_set {
185 fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
186 } _types_fd_set;
187
188 #define fd_set _types_fd_set
189
190 # define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS)))
191 # define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS)))
192 # define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS)))
193 # define FD_ZERO(p) (__extension__ (void)({ \
194 size_t __i; \
195 char *__tmp = (char *)p; \
196 for (__i = 0; __i < sizeof (*(p)); ++__i) \
197 *__tmp++ = 0; \
198 }))
199
200 # endif /* !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS)) */
201
202 #undef __MS_types__
203 #undef _ST_INT32
204
205 /* The following are actually standard POSIX 1003.1b-1993 threads, mutexes,
206 condition variables, and keys. But since RTEMS is currently the only
207 newlib user of these, the ifdef is just on RTEMS. */
208
209 #if defined(__rtems__) || defined(__CYGWIN__)
210
211 #ifndef __clockid_t_defined
212 typedef _CLOCKID_T_ clockid_t;
213 #define __clockid_t_defined
214 #endif
215
216 #ifndef __timer_t_defined
217 typedef _TIMER_T_ timer_t;
218 #define __timer_t_defined
219 #endif
220
221 #ifdef __CYGWIN__
222 typedef long useconds_t;
223 #endif
224
225 #include <sys/features.h>
226
227
228 /* Cygwin will probably never have full posix compliance due to little things
229 * like an inability to set the stackaddress. Cygwin is also using void *
230 * pointers rather than structs to ensure maximum binary compatability with
231 * previous releases.
232 * This means that we don't use the types defined here, but rather in
233 * <cygwin/types.h>
234 */
235 #if defined(_POSIX_THREADS) && !defined(__CYGWIN__)
236
237 #include <sys/sched.h>
238
239 /*
240 * 2.5 Primitive System Data Types, P1003.1c/D10, p. 19.
241 */
242
243 typedef __uint32_t pthread_t; /* identify a thread */
244
245 /* P1003.1c/D10, p. 118-119 */
246 #define PTHREAD_SCOPE_PROCESS 0
247 #define PTHREAD_SCOPE_SYSTEM 1
248
249 /* P1003.1c/D10, p. 111 */
250 #define PTHREAD_INHERIT_SCHED 1 /* scheduling policy and associated */
251 /* attributes are inherited from */
252 /* the calling thread. */
253 #define PTHREAD_EXPLICIT_SCHED 2 /* set from provided attribute object */
254
255 /* P1003.1c/D10, p. 141 */
256 #define PTHREAD_CREATE_DETACHED 0
257 #define PTHREAD_CREATE_JOINABLE 1
258
259 typedef struct {
260 int is_initialized;
261 void *stackaddr;
262 int stacksize;
263 int contentionscope;
264 int inheritsched;
265 int schedpolicy;
266 struct sched_param schedparam;
267
268 /* P1003.4b/D8, p. 54 adds cputime_clock_allowed attribute. */
269 #if defined(_POSIX_THREAD_CPUTIME)
270 int cputime_clock_allowed; /* see time.h */
271 #endif
272 int detachstate;
273
274 } pthread_attr_t;
275
276 #if defined(_POSIX_THREAD_PROCESS_SHARED)
277 /* NOTE: P1003.1c/D10, p. 81 defines following values for process_shared. */
278
279 #define PTHREAD_PROCESS_PRIVATE 0 /* visible within only the creating process */
280 #define PTHREAD_PROCESS_SHARED 1 /* visible too all processes with access to */
281 /* the memory where the resource is */
282 /* located */
283 #endif
284
285 #if defined(_POSIX_THREAD_PRIO_PROTECT)
286 /* Mutexes */
287
288 /* Values for blocking protocol. */
289
290 #define PTHREAD_PRIO_NONE 0
291 #define PTHREAD_PRIO_INHERIT 1
292 #define PTHREAD_PRIO_PROTECT 2
293 #endif
294
295 typedef __uint32_t pthread_mutex_t; /* identify a mutex */
296
297 typedef struct {
298 int is_initialized;
299 #if defined(_POSIX_THREAD_PROCESS_SHARED)
300 int process_shared; /* allow mutex to be shared amongst processes */
301 #endif
302 #if defined(_POSIX_THREAD_PRIO_PROTECT)
303 int prio_ceiling;
304 int protocol;
305 #endif
306 int recursive;
307 } pthread_mutexattr_t;
308
309 /* Condition Variables */
310
311 typedef __uint32_t pthread_cond_t; /* identify a condition variable */
312
313 typedef struct {
314 int is_initialized;
315 #if defined(_POSIX_THREAD_PROCESS_SHARED)
316 int process_shared; /* allow this to be shared amongst processes */
317 #endif
318 } pthread_condattr_t; /* a condition attribute object */
319
320 /* Keys */
321
322 typedef __uint32_t pthread_key_t; /* thread-specific data keys */
323
324 typedef struct {
325 int is_initialized; /* is this structure initialized? */
326 int init_executed; /* has the initialization routine been run? */
327 } pthread_once_t; /* dynamic package initialization */
328 #else
329 #if defined (__CYGWIN__)
330 #include <cygwin/types.h>
331 #endif
332 #endif /* defined(_POSIX_THREADS) */
333
334 #endif /* defined(__rtems__) */
335
336 #endif /* _SYS_TYPES_H */
This page took 0.052047 seconds and 6 git commands to generate.