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