]> sourceware.org Git - newlib-cygwin.git/blob - newlib/libc/include/sys/types.h
* libc/include/grp.h: Include Cygwin specific header.
[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 #if defined(__MS_types__) || defined(__rtems__)
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 #ifndef __CYGWIN__ /* which defines these types in it's own types.h. */
132 typedef long off_t;
133
134 typedef unsigned short uid_t;
135 typedef unsigned short gid_t;
136 #endif
137
138 typedef int pid_t;
139 typedef long key_t;
140 typedef long ssize_t;
141
142 #ifdef __MS_types__
143 typedef char * addr_t;
144 typedef int mode_t;
145 #else
146 #if defined (__sparc__) && !defined (__sparc_v9__)
147 #ifdef __svr4__
148 typedef unsigned long mode_t;
149 #else
150 typedef unsigned short mode_t;
151 #endif
152 #else
153 typedef unsigned int mode_t _ST_INT32;
154 #endif
155 #endif /* ! __MS_types__ */
156
157 typedef unsigned short nlink_t;
158
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.
165 */
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 */
169 /*
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).
174 */
175 # ifndef FD_SETSIZE
176 # define FD_SETSIZE 64
177 # endif
178
179 typedef long fd_mask;
180 # define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */
181 # ifndef howmany
182 # define howmany(x,y) (((x)+((y)-1))/(y))
183 # endif
184
185 /* We use a macro for fd_set so that including Sockets.h afterwards
186 can work. */
187 typedef struct _types_fd_set {
188 fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
189 } _types_fd_set;
190
191 #define fd_set _types_fd_set
192
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)({ \
197 size_t __i; \
198 char *__tmp = (char *)p; \
199 for (__i = 0; __i < sizeof (*(p)); ++__i) \
200 *__tmp++ = 0; \
201 }))
202
203 # endif /* !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS)) */
204
205 #undef __MS_types__
206 #undef _ST_INT32
207
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. */
211
212 #if defined(__rtems__) || defined(__CYGWIN__)
213
214 #ifndef __clockid_t_defined
215 typedef _CLOCKID_T_ clockid_t;
216 #define __clockid_t_defined
217 #endif
218
219 #ifndef __timer_t_defined
220 typedef _TIMER_T_ timer_t;
221 #define __timer_t_defined
222 #endif
223
224 #if defined(__CYGWIN__) || defined(__rtems__)
225 typedef long useconds_t;
226 #endif
227
228 #include <sys/features.h>
229
230
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
234 * previous releases.
235 * This means that we don't use the types defined here, but rather in
236 * <cygwin/types.h>
237 */
238 #if defined(_POSIX_THREADS) && !defined(__CYGWIN__)
239
240 #include <sys/sched.h>
241
242 /*
243 * 2.5 Primitive System Data Types, P1003.1c/D10, p. 19.
244 */
245
246 typedef __uint32_t pthread_t; /* identify a thread */
247
248 /* P1003.1c/D10, p. 118-119 */
249 #define PTHREAD_SCOPE_PROCESS 0
250 #define PTHREAD_SCOPE_SYSTEM 1
251
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 */
257
258 /* P1003.1c/D10, p. 141 */
259 #define PTHREAD_CREATE_DETACHED 0
260 #define PTHREAD_CREATE_JOINABLE 1
261
262 typedef struct {
263 int is_initialized;
264 void *stackaddr;
265 int stacksize;
266 int contentionscope;
267 int inheritsched;
268 int schedpolicy;
269 struct sched_param schedparam;
270
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 */
274 #endif
275 int detachstate;
276
277 } pthread_attr_t;
278
279 #if defined(_POSIX_THREAD_PROCESS_SHARED)
280 /* NOTE: P1003.1c/D10, p. 81 defines following values for process_shared. */
281
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 */
285 /* located */
286 #endif
287
288 #if defined(_POSIX_THREAD_PRIO_PROTECT)
289 /* Mutexes */
290
291 /* Values for blocking protocol. */
292
293 #define PTHREAD_PRIO_NONE 0
294 #define PTHREAD_PRIO_INHERIT 1
295 #define PTHREAD_PRIO_PROTECT 2
296 #endif
297
298 typedef __uint32_t pthread_mutex_t; /* identify a mutex */
299
300 typedef struct {
301 int is_initialized;
302 #if defined(_POSIX_THREAD_PROCESS_SHARED)
303 int process_shared; /* allow mutex to be shared amongst processes */
304 #endif
305 #if defined(_POSIX_THREAD_PRIO_PROTECT)
306 int prio_ceiling;
307 int protocol;
308 #endif
309 int recursive;
310 } pthread_mutexattr_t;
311
312 /* Condition Variables */
313
314 typedef __uint32_t pthread_cond_t; /* identify a condition variable */
315
316 typedef struct {
317 int is_initialized;
318 #if defined(_POSIX_THREAD_PROCESS_SHARED)
319 int process_shared; /* allow this to be shared amongst processes */
320 #endif
321 } pthread_condattr_t; /* a condition attribute object */
322
323 /* Keys */
324
325 typedef __uint32_t pthread_key_t; /* thread-specific data keys */
326
327 typedef struct {
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 */
331 #else
332 #if defined (__CYGWIN__)
333 #include <cygwin/types.h>
334 #endif
335 #endif /* defined(_POSIX_THREADS) */
336
337 #endif /* defined(__rtems__) */
338
339 #endif /* _SYS_TYPES_H */
This page took 0.064269 seconds and 6 git commands to generate.