]> git.saurik.com Git - apple/xnu.git/blob - bsd/sys/types.h
ab5c23f631b88ede05e64f96aadeb7d0f6b34d71
[apple/xnu.git] / bsd / sys / types.h
1 /*
2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
24 /*-
25 * Copyright (c) 1982, 1986, 1991, 1993, 1994
26 * The Regents of the University of California. All rights reserved.
27 * (c) UNIX System Laboratories, Inc.
28 * All or some portions of this file are derived from material licensed
29 * to the University of California by American Telephone and Telegraph
30 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
31 * the permission of UNIX System Laboratories, Inc.
32 *
33 * Redistribution and use in source and binary forms, with or without
34 * modification, are permitted provided that the following conditions
35 * are met:
36 * 1. Redistributions of source code must retain the above copyright
37 * notice, this list of conditions and the following disclaimer.
38 * 2. Redistributions in binary form must reproduce the above copyright
39 * notice, this list of conditions and the following disclaimer in the
40 * documentation and/or other materials provided with the distribution.
41 * 3. All advertising materials mentioning features or use of this software
42 * must display the following acknowledgement:
43 * This product includes software developed by the University of
44 * California, Berkeley and its contributors.
45 * 4. Neither the name of the University nor the names of its contributors
46 * may be used to endorse or promote products derived from this software
47 * without specific prior written permission.
48 *
49 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
50 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
51 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
52 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
53 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
54 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
55 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
56 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
57 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
58 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59 * SUCH DAMAGE.
60 *
61 * @(#)types.h 8.4 (Berkeley) 1/21/94
62 */
63
64 #ifndef _SYS_TYPES_H_
65 #define _SYS_TYPES_H_
66
67 #include <sys/appleapiopts.h>
68
69 #ifndef __ASSEMBLER__
70 #include <sys/cdefs.h>
71
72 /* Machine type dependent parameters. */
73 #include <machine/types.h>
74 #include <sys/_types.h>
75
76 #include <machine/endian.h>
77
78 #ifndef _POSIX_C_SOURCE
79 typedef unsigned char u_char;
80 typedef unsigned short u_short;
81 typedef unsigned int u_int;
82 #ifndef _U_LONG
83 typedef unsigned long u_long;
84 #define _U_LONG
85 #endif
86 typedef unsigned short ushort; /* Sys V compatibility */
87 typedef unsigned int uint; /* Sys V compatibility */
88 #endif
89
90 typedef u_int64_t u_quad_t; /* quads */
91 typedef int64_t quad_t;
92 typedef quad_t * qaddr_t;
93
94 typedef char * caddr_t; /* core address */
95 typedef int32_t daddr_t; /* disk address */
96
97 #ifndef _DEV_T
98 typedef __darwin_dev_t dev_t; /* device number */
99 #define _DEV_T
100 #endif
101
102 typedef u_int32_t fixpt_t; /* fixed point number */
103
104 #ifndef _BLKCNT_T
105 typedef __darwin_blkcnt_t blkcnt_t;
106 #define _BLKCNT_T
107 #endif
108
109 #ifndef _BLKSIZE_T
110 typedef __darwin_blksize_t blksize_t;
111 #define _BLKSIZE_T
112 #endif
113
114 #ifndef _GID_T
115 typedef __darwin_gid_t gid_t;
116 #define _GID_T
117 #endif
118
119 #ifndef _IN_ADDR_T
120 #define _IN_ADDR_T
121 typedef __uint32_t in_addr_t; /* base type for internet address */
122 #endif
123
124 #ifndef _IN_PORT_T
125 #define _IN_PORT_T
126 typedef __uint16_t in_port_t;
127 #endif
128
129 #ifndef _INO_T
130 typedef __darwin_ino_t ino_t; /* inode number */
131 #define _INO_T
132 #endif
133
134 #ifndef _KEY_T
135 #define _KEY_T
136 typedef __int32_t key_t; /* IPC key (for Sys V IPC) */
137 #endif
138
139 #ifndef _MODE_T
140 typedef __darwin_mode_t mode_t;
141 #define _MODE_T
142 #endif
143
144 #ifndef _NLINK_T
145 typedef __uint16_t nlink_t; /* link count */
146 #define _NLINK_T
147 #endif
148
149 #ifndef _ID_T
150 #define _ID_T
151 typedef __darwin_id_t id_t; /* can hold pid_t, gid_t, or uid_t */
152 #endif
153
154 #ifndef _PID_T
155 typedef __darwin_pid_t pid_t;
156 #define _PID_T
157 #endif
158
159 #ifndef _OFF_T
160 typedef __darwin_off_t off_t;
161 #define _OFF_T
162 #endif
163
164 typedef int32_t segsz_t; /* segment size */
165 typedef int32_t swblk_t; /* swap offset */
166
167 #ifndef _UID_T
168 typedef __darwin_uid_t uid_t; /* user id */
169 #define _UID_T
170 #endif
171
172 #ifndef _ID_T
173 typedef __darwin_id_t id_t;
174 #define _ID_T
175 #endif
176
177 #ifndef _POSIX_C_SOURCE
178 /* Major, minor numbers, dev_t's. */
179 #define major(x) ((int32_t)(((u_int32_t)(x) >> 24) & 0xff))
180 #define minor(x) ((int32_t)((x) & 0xffffff))
181 #define makedev(x,y) ((dev_t)(((x) << 24) | (y)))
182 #endif
183
184 #ifndef _CLOCK_T
185 #define _CLOCK_T
186 typedef __darwin_clock_t clock_t;
187 #endif
188
189 #ifndef _SIZE_T
190 #define _SIZE_T
191 /* DO NOT REMOVE THIS COMMENT: fixincludes needs to see
192 * _GCC_SIZE_T */
193 typedef __darwin_size_t size_t;
194 #endif
195
196 #ifndef _SSIZE_T
197 #define _SSIZE_T
198 typedef __darwin_ssize_t ssize_t;
199 #endif
200
201 #ifndef _TIME_T
202 #define _TIME_T
203 typedef __darwin_time_t time_t;
204 #endif
205
206 #ifndef _USECONDS_T
207 #define _USECONDS_T
208 typedef __darwin_useconds_t useconds_t;
209 #endif
210
211 #ifndef _SUSECONDS_T
212 #define _SUSECONDS_T
213 typedef __darwin_suseconds_t suseconds_t;
214 #endif
215
216 #ifndef _POSIX_C_SOURCE
217 /*
218 * This code is present here in order to maintain historical backward
219 * compatability, and is intended to be removed at some point in the
220 * future; please include <sys/select.h> instead.
221 */
222 #define NBBY 8 /* bits in a byte */
223 #define NFDBITS (sizeof(__int32_t) * NBBY) /* bits per mask */
224 #define howmany(x, y) (((x) + ((y) - 1)) / (y)) /* # y's == x bits? */
225 typedef __int32_t fd_mask;
226
227
228 /*
229 * Note: We use _FD_SET to protect all select related
230 * types and macros
231 */
232 #ifndef _FD_SET
233 #define _FD_SET
234
235 /*
236 * Select uses bit masks of file descriptors in longs. These macros
237 * manipulate such bit fields (the filesystem macros use chars). The
238 * extra protection here is to permit application redefinition above
239 * the default size.
240 */
241 #ifndef FD_SETSIZE
242 #define FD_SETSIZE 1024
243 #endif
244
245 #define __DARWIN_NBBY 8 /* bits in a byte */
246 #define __DARWIN_NFDBITS (sizeof(__int32_t) * __DARWIN_NBBY) /* bits per mask */
247 #define __DARWIN_howmany(x, y) (((x) + ((y) - 1)) / (y)) /* # y's == x bits? */
248
249 __BEGIN_DECLS
250 typedef struct fd_set {
251 __int32_t fds_bits[__DARWIN_howmany(FD_SETSIZE, __DARWIN_NFDBITS)];
252 } fd_set;
253 __END_DECLS
254
255 #define FD_SET(n, p) ((p)->fds_bits[(n)/__DARWIN_NFDBITS] |= (1<<((n) % __DARWIN_NFDBITS)))
256 #define FD_CLR(n, p) ((p)->fds_bits[(n)/__DARWIN_NFDBITS] &= ~(1<<((n) % __DARWIN_NFDBITS)))
257 #define FD_ISSET(n, p) ((p)->fds_bits[(n)/__DARWIN_NFDBITS] & (1<<((n) % __DARWIN_NFDBITS)))
258 #if __GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 3
259 /*
260 * Use the built-in bzero function instead of the library version so that
261 * we do not pollute the namespace or introduce prototype warnings.
262 */
263 #define FD_ZERO(p) __builtin_bzero(p, sizeof(*(p)))
264 #else
265 #define FD_ZERO(p) bzero(p, sizeof(*(p)))
266 #endif
267 #ifndef _POSIX_C_SOURCE
268 #define FD_COPY(f, t) bcopy(f, t, sizeof(*(f)))
269 #endif /* !_POSIX_C_SOURCE */
270
271 #endif /* !_FD_SET */
272
273
274 #if defined(__STDC__) && defined(KERNEL)
275 /*
276 * Forward structure declarations for function prototypes. We include the
277 * common structures that cross subsystem boundaries here; others are mostly
278 * used in the same place that the structure is defined.
279 */
280 struct proc;
281 struct pgrp;
282 struct ucred;
283 struct rusage;
284 struct file;
285 struct buf;
286 struct tty;
287 struct uio;
288 #endif
289
290 #endif /* !_POSIX_C_SOURCE */
291 #endif /* __ASSEMBLER__ */
292
293 #ifndef __POSIX_LIB__
294
295 #ifndef _PTHREAD_ATTR_T
296 #define _PTHREAD_ATTR_T
297 typedef __darwin_pthread_attr_t pthread_attr_t;
298 #endif
299 #ifndef _PTHREAD_COND_T
300 #define _PTHREAD_COND_T
301 typedef __darwin_pthread_cond_t pthread_cond_t;
302 #endif
303 #ifndef _PTHREAD_CONDATTR_T
304 #define _PTHREAD_CONDATTR_T
305 typedef __darwin_pthread_condattr_t pthread_condattr_t;
306 #endif
307 #ifndef _PTHREAD_MUTEX_T
308 #define _PTHREAD_MUTEX_T
309 typedef __darwin_pthread_mutex_t pthread_mutex_t;
310 #endif
311 #ifndef _PTHREAD_MUTEXATTR_T
312 #define _PTHREAD_MUTEXATTR_T
313 typedef __darwin_pthread_mutexattr_t pthread_mutexattr_t;
314 #endif
315 #ifndef _PTHREAD_ONCE_T
316 #define _PTHREAD_ONCE_T
317 typedef __darwin_pthread_once_t pthread_once_t;
318 #endif
319 #ifndef _PTHREAD_RWLOCK_T
320 #define _PTHREAD_RWLOCK_T
321 typedef __darwin_pthread_rwlock_t pthread_rwlock_t;
322 #endif
323 #ifndef _PTHREAD_RWLOCKATTR_T
324 #define _PTHREAD_RWLOCKATTR_T
325 typedef __darwin_pthread_rwlockattr_t pthread_rwlockattr_t;
326 #endif
327 #ifndef _PTHREAD_T
328 #define _PTHREAD_T
329 typedef __darwin_pthread_t pthread_t;
330 #endif
331
332 #endif /* __POSIX_LIB__ */
333
334 #ifndef _PTHREAD_KEY_T
335 #define _PTHREAD_KEY_T
336 typedef __darwin_pthread_key_t pthread_key_t;
337 #endif
338
339 /* statvfs and fstatvfs */
340 #ifndef _FSBLKCNT_T
341 #define _FSBLKCNT_T
342 typedef __darwin_fsblkcnt_t fsblkcnt_t;
343 #endif
344
345 #ifndef _FSFILCNT_T
346 #define _FSFILCNT_T
347 typedef __darwin_fsfilcnt_t fsfilcnt_t;
348 #endif
349
350 #endif /* !_SYS_TYPES_H_ */