2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_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 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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
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.
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
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.
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
66 * @(#)types.h 8.4 (Berkeley) 1/21/94
72 #include <sys/appleapiopts.h>
75 #include <sys/cdefs.h>
77 /* Machine type dependent parameters. */
78 #include <machine/types.h>
79 #include <sys/_types.h>
81 #include <machine/endian.h>
83 #ifndef _POSIX_C_SOURCE
84 typedef unsigned char u_char
;
85 typedef unsigned short u_short
;
86 typedef unsigned int u_int
;
88 typedef unsigned long u_long
;
91 typedef unsigned short ushort
; /* Sys V compatibility */
92 typedef unsigned int uint
; /* Sys V compatibility */
95 typedef u_int64_t u_quad_t
; /* quads */
96 typedef int64_t quad_t
;
97 typedef quad_t
* qaddr_t
;
99 typedef char * caddr_t
; /* core address */
100 typedef int32_t daddr_t
; /* disk address */
103 typedef __darwin_dev_t dev_t
; /* device number */
107 typedef u_int32_t fixpt_t
; /* fixed point number */
110 typedef __darwin_blkcnt_t blkcnt_t
;
115 typedef __darwin_blksize_t blksize_t
;
120 typedef __darwin_gid_t gid_t
;
126 typedef __uint32_t in_addr_t
; /* base type for internet address */
131 typedef __uint16_t in_port_t
;
135 typedef __darwin_ino_t ino_t
; /* inode number */
141 typedef __int32_t key_t
; /* IPC key (for Sys V IPC) */
145 typedef __darwin_mode_t mode_t
;
150 typedef __uint16_t nlink_t
; /* link count */
156 typedef __darwin_id_t id_t
; /* can hold pid_t, gid_t, or uid_t */
160 typedef __darwin_pid_t pid_t
;
165 typedef __darwin_off_t off_t
;
169 typedef int32_t segsz_t
; /* segment size */
170 typedef int32_t swblk_t
; /* swap offset */
173 typedef __darwin_uid_t uid_t
; /* user id */
178 typedef __darwin_id_t id_t
;
182 #ifndef _POSIX_C_SOURCE
183 /* Major, minor numbers, dev_t's. */
184 #define major(x) ((int32_t)(((u_int32_t)(x) >> 24) & 0xff))
185 #define minor(x) ((int32_t)((x) & 0xffffff))
186 #define makedev(x,y) ((dev_t)(((x) << 24) | (y)))
191 typedef __darwin_clock_t
clock_t;
196 /* DO NOT REMOVE THIS COMMENT: fixincludes needs to see
198 typedef __darwin_size_t
size_t;
203 typedef __darwin_ssize_t ssize_t
;
208 typedef __darwin_time_t
time_t;
213 typedef __darwin_useconds_t useconds_t
;
218 typedef __darwin_suseconds_t suseconds_t
;
221 #ifndef _POSIX_C_SOURCE
223 * This code is present here in order to maintain historical backward
224 * compatability, and is intended to be removed at some point in the
225 * future; please include <sys/select.h> instead.
227 #define NBBY 8 /* bits in a byte */
228 #define NFDBITS (sizeof(__int32_t) * NBBY) /* bits per mask */
229 #define howmany(x, y) (((x) + ((y) - 1)) / (y)) /* # y's == x bits? */
230 typedef __int32_t fd_mask
;
234 * Note: We use _FD_SET to protect all select related
241 * Select uses bit masks of file descriptors in longs. These macros
242 * manipulate such bit fields (the filesystem macros use chars). The
243 * extra protection here is to permit application redefinition above
247 #define FD_SETSIZE 1024
250 #define __DARWIN_NBBY 8 /* bits in a byte */
251 #define __DARWIN_NFDBITS (sizeof(__int32_t) * __DARWIN_NBBY) /* bits per mask */
252 #define __DARWIN_howmany(x, y) (((x) + ((y) - 1)) / (y)) /* # y's == x bits? */
255 typedef struct fd_set
{
256 __int32_t fds_bits
[__DARWIN_howmany(FD_SETSIZE
, __DARWIN_NFDBITS
)];
260 #define FD_SET(n, p) ((p)->fds_bits[(n)/__DARWIN_NFDBITS] |= (1<<((n) % __DARWIN_NFDBITS)))
261 #define FD_CLR(n, p) ((p)->fds_bits[(n)/__DARWIN_NFDBITS] &= ~(1<<((n) % __DARWIN_NFDBITS)))
262 #define FD_ISSET(n, p) ((p)->fds_bits[(n)/__DARWIN_NFDBITS] & (1<<((n) % __DARWIN_NFDBITS)))
263 #if __GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 3
265 * Use the built-in bzero function instead of the library version so that
266 * we do not pollute the namespace or introduce prototype warnings.
268 #define FD_ZERO(p) __builtin_bzero(p, sizeof(*(p)))
270 #define FD_ZERO(p) bzero(p, sizeof(*(p)))
272 #ifndef _POSIX_C_SOURCE
273 #define FD_COPY(f, t) bcopy(f, t, sizeof(*(f)))
274 #endif /* !_POSIX_C_SOURCE */
276 #endif /* !_FD_SET */
279 #if defined(__STDC__) && defined(KERNEL)
281 * Forward structure declarations for function prototypes. We include the
282 * common structures that cross subsystem boundaries here; others are mostly
283 * used in the same place that the structure is defined.
295 #endif /* !_POSIX_C_SOURCE */
296 #endif /* __ASSEMBLER__ */
298 #ifndef __POSIX_LIB__
300 #ifndef _PTHREAD_ATTR_T
301 #define _PTHREAD_ATTR_T
302 typedef __darwin_pthread_attr_t pthread_attr_t
;
304 #ifndef _PTHREAD_COND_T
305 #define _PTHREAD_COND_T
306 typedef __darwin_pthread_cond_t pthread_cond_t
;
308 #ifndef _PTHREAD_CONDATTR_T
309 #define _PTHREAD_CONDATTR_T
310 typedef __darwin_pthread_condattr_t pthread_condattr_t
;
312 #ifndef _PTHREAD_MUTEX_T
313 #define _PTHREAD_MUTEX_T
314 typedef __darwin_pthread_mutex_t pthread_mutex_t
;
316 #ifndef _PTHREAD_MUTEXATTR_T
317 #define _PTHREAD_MUTEXATTR_T
318 typedef __darwin_pthread_mutexattr_t pthread_mutexattr_t
;
320 #ifndef _PTHREAD_ONCE_T
321 #define _PTHREAD_ONCE_T
322 typedef __darwin_pthread_once_t pthread_once_t
;
324 #ifndef _PTHREAD_RWLOCK_T
325 #define _PTHREAD_RWLOCK_T
326 typedef __darwin_pthread_rwlock_t pthread_rwlock_t
;
328 #ifndef _PTHREAD_RWLOCKATTR_T
329 #define _PTHREAD_RWLOCKATTR_T
330 typedef __darwin_pthread_rwlockattr_t pthread_rwlockattr_t
;
334 typedef __darwin_pthread_t pthread_t
;
337 #endif /* __POSIX_LIB__ */
339 #ifndef _PTHREAD_KEY_T
340 #define _PTHREAD_KEY_T
341 typedef __darwin_pthread_key_t pthread_key_t
;
344 /* statvfs and fstatvfs */
347 typedef __darwin_fsblkcnt_t fsblkcnt_t
;
352 typedef __darwin_fsfilcnt_t fsfilcnt_t
;
355 #endif /* !_SYS_TYPES_H_ */