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