2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
30 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
32 * Copyright (c) 1982, 1986, 1991, 1993, 1994
33 * The Regents of the University of California. All rights reserved.
34 * (c) UNIX System Laboratories, Inc.
35 * All or some portions of this file are derived from material licensed
36 * to the University of California by American Telephone and Telegraph
37 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
38 * the permission of UNIX System Laboratories, Inc.
40 * Redistribution and use in source and binary forms, with or without
41 * modification, are permitted provided that the following conditions
43 * 1. Redistributions of source code must retain the above copyright
44 * notice, this list of conditions and the following disclaimer.
45 * 2. Redistributions in binary form must reproduce the above copyright
46 * notice, this list of conditions and the following disclaimer in the
47 * documentation and/or other materials provided with the distribution.
48 * 3. All advertising materials mentioning features or use of this software
49 * must display the following acknowledgement:
50 * This product includes software developed by the University of
51 * California, Berkeley and its contributors.
52 * 4. Neither the name of the University nor the names of its contributors
53 * may be used to endorse or promote products derived from this software
54 * without specific prior written permission.
56 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
57 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
59 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
60 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
61 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
62 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
64 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
65 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 * @(#)types.h 8.4 (Berkeley) 1/21/94
74 #include <sys/appleapiopts.h>
77 #include <sys/cdefs.h>
79 /* Machine type dependent parameters. */
80 #include <machine/types.h>
81 #include <sys/_types.h>
83 #include <machine/endian.h>
85 #ifndef _POSIX_C_SOURCE
86 typedef unsigned char u_char
;
87 typedef unsigned short u_short
;
88 typedef unsigned int u_int
;
90 typedef unsigned long u_long
;
93 typedef unsigned short ushort
; /* Sys V compatibility */
94 typedef unsigned int uint
; /* Sys V compatibility */
97 typedef u_int64_t u_quad_t
; /* quads */
98 typedef int64_t quad_t
;
99 typedef quad_t
* qaddr_t
;
101 typedef char * caddr_t
; /* core address */
102 typedef int32_t daddr_t
; /* disk address */
105 typedef __darwin_dev_t dev_t
; /* device number */
109 typedef u_int32_t fixpt_t
; /* fixed point number */
112 typedef __darwin_blkcnt_t blkcnt_t
;
117 typedef __darwin_blksize_t blksize_t
;
122 typedef __darwin_gid_t gid_t
;
128 typedef __uint32_t in_addr_t
; /* base type for internet address */
133 typedef __uint16_t in_port_t
;
137 typedef __darwin_ino_t ino_t
; /* inode number */
143 typedef __int32_t key_t
; /* IPC key (for Sys V IPC) */
147 typedef __darwin_mode_t mode_t
;
152 typedef __uint16_t nlink_t
; /* link count */
158 typedef __darwin_id_t id_t
; /* can hold pid_t, gid_t, or uid_t */
162 typedef __darwin_pid_t pid_t
;
167 typedef __darwin_off_t off_t
;
171 typedef int32_t segsz_t
; /* segment size */
172 typedef int32_t swblk_t
; /* swap offset */
175 typedef __darwin_uid_t uid_t
; /* user id */
180 typedef __darwin_id_t id_t
;
184 #ifndef _POSIX_C_SOURCE
185 /* Major, minor numbers, dev_t's. */
186 #define major(x) ((int32_t)(((u_int32_t)(x) >> 24) & 0xff))
187 #define minor(x) ((int32_t)((x) & 0xffffff))
188 #define makedev(x,y) ((dev_t)(((x) << 24) | (y)))
193 typedef __darwin_clock_t
clock_t;
198 /* DO NOT REMOVE THIS COMMENT: fixincludes needs to see
200 typedef __darwin_size_t
size_t;
205 typedef __darwin_ssize_t ssize_t
;
210 typedef __darwin_time_t
time_t;
215 typedef __darwin_useconds_t useconds_t
;
220 typedef __darwin_suseconds_t suseconds_t
;
223 #ifndef _POSIX_C_SOURCE
225 * This code is present here in order to maintain historical backward
226 * compatability, and is intended to be removed at some point in the
227 * future; please include <sys/select.h> instead.
229 #define NBBY 8 /* bits in a byte */
230 #define NFDBITS (sizeof(__int32_t) * NBBY) /* bits per mask */
231 #define howmany(x, y) (((x) + ((y) - 1)) / (y)) /* # y's == x bits? */
232 typedef __int32_t fd_mask
;
236 * Note: We use _FD_SET to protect all select related
243 * Select uses bit masks of file descriptors in longs. These macros
244 * manipulate such bit fields (the filesystem macros use chars). The
245 * extra protection here is to permit application redefinition above
249 #define FD_SETSIZE 1024
252 #define __DARWIN_NBBY 8 /* bits in a byte */
253 #define __DARWIN_NFDBITS (sizeof(__int32_t) * __DARWIN_NBBY) /* bits per mask */
254 #define __DARWIN_howmany(x, y) (((x) + ((y) - 1)) / (y)) /* # y's == x bits? */
257 typedef struct fd_set
{
258 __int32_t fds_bits
[__DARWIN_howmany(FD_SETSIZE
, __DARWIN_NFDBITS
)];
262 #define FD_SET(n, p) ((p)->fds_bits[(n)/__DARWIN_NFDBITS] |= (1<<((n) % __DARWIN_NFDBITS)))
263 #define FD_CLR(n, p) ((p)->fds_bits[(n)/__DARWIN_NFDBITS] &= ~(1<<((n) % __DARWIN_NFDBITS)))
264 #define FD_ISSET(n, p) ((p)->fds_bits[(n)/__DARWIN_NFDBITS] & (1<<((n) % __DARWIN_NFDBITS)))
265 #if __GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 3
267 * Use the built-in bzero function instead of the library version so that
268 * we do not pollute the namespace or introduce prototype warnings.
270 #define FD_ZERO(p) __builtin_bzero(p, sizeof(*(p)))
272 #define FD_ZERO(p) bzero(p, sizeof(*(p)))
274 #ifndef _POSIX_C_SOURCE
275 #define FD_COPY(f, t) bcopy(f, t, sizeof(*(f)))
276 #endif /* !_POSIX_C_SOURCE */
278 #endif /* !_FD_SET */
281 #if defined(__STDC__) && defined(KERNEL)
283 * Forward structure declarations for function prototypes. We include the
284 * common structures that cross subsystem boundaries here; others are mostly
285 * used in the same place that the structure is defined.
297 #endif /* !_POSIX_C_SOURCE */
298 #endif /* __ASSEMBLER__ */
300 #ifndef __POSIX_LIB__
302 #ifndef _PTHREAD_ATTR_T
303 #define _PTHREAD_ATTR_T
304 typedef __darwin_pthread_attr_t pthread_attr_t
;
306 #ifndef _PTHREAD_COND_T
307 #define _PTHREAD_COND_T
308 typedef __darwin_pthread_cond_t pthread_cond_t
;
310 #ifndef _PTHREAD_CONDATTR_T
311 #define _PTHREAD_CONDATTR_T
312 typedef __darwin_pthread_condattr_t pthread_condattr_t
;
314 #ifndef _PTHREAD_MUTEX_T
315 #define _PTHREAD_MUTEX_T
316 typedef __darwin_pthread_mutex_t pthread_mutex_t
;
318 #ifndef _PTHREAD_MUTEXATTR_T
319 #define _PTHREAD_MUTEXATTR_T
320 typedef __darwin_pthread_mutexattr_t pthread_mutexattr_t
;
322 #ifndef _PTHREAD_ONCE_T
323 #define _PTHREAD_ONCE_T
324 typedef __darwin_pthread_once_t pthread_once_t
;
326 #ifndef _PTHREAD_RWLOCK_T
327 #define _PTHREAD_RWLOCK_T
328 typedef __darwin_pthread_rwlock_t pthread_rwlock_t
;
330 #ifndef _PTHREAD_RWLOCKATTR_T
331 #define _PTHREAD_RWLOCKATTR_T
332 typedef __darwin_pthread_rwlockattr_t pthread_rwlockattr_t
;
336 typedef __darwin_pthread_t pthread_t
;
339 #endif /* __POSIX_LIB__ */
341 #ifndef _PTHREAD_KEY_T
342 #define _PTHREAD_KEY_T
343 typedef __darwin_pthread_key_t pthread_key_t
;
346 /* statvfs and fstatvfs */
349 typedef __darwin_fsblkcnt_t fsblkcnt_t
;
354 typedef __darwin_fsfilcnt_t fsfilcnt_t
;
357 #endif /* !_SYS_TYPES_H_ */