]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
8ad349bb | 2 | * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 3 | * |
8ad349bb | 4 | * @APPLE_LICENSE_OSREFERENCE_HEADER_START@ |
1c79356b | 5 | * |
8ad349bb A |
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 | |
14 | * agreement. | |
15 | * | |
16 | * Please obtain a copy of the License at | |
17 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
18 | * file. | |
19 | * | |
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. | |
27 | * | |
28 | * @APPLE_LICENSE_OSREFERENCE_HEADER_END@ | |
1c79356b A |
29 | */ |
30 | /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ | |
31 | /*- | |
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. | |
39 | * | |
40 | * Redistribution and use in source and binary forms, with or without | |
41 | * modification, are permitted provided that the following conditions | |
42 | * are met: | |
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. | |
55 | * | |
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 | |
66 | * SUCH DAMAGE. | |
67 | * | |
68 | * @(#)types.h 8.4 (Berkeley) 1/21/94 | |
69 | */ | |
70 | ||
71 | #ifndef _SYS_TYPES_H_ | |
72 | #define _SYS_TYPES_H_ | |
73 | ||
9bccf70c A |
74 | #include <sys/appleapiopts.h> |
75 | ||
1c79356b A |
76 | #ifndef __ASSEMBLER__ |
77 | #include <sys/cdefs.h> | |
78 | ||
79 | /* Machine type dependent parameters. */ | |
80 | #include <machine/types.h> | |
91447636 | 81 | #include <sys/_types.h> |
1c79356b | 82 | |
1c79356b A |
83 | #include <machine/endian.h> |
84 | ||
91447636 A |
85 | #ifndef _POSIX_C_SOURCE |
86 | typedef unsigned char u_char; | |
87 | typedef unsigned short u_short; | |
88 | typedef unsigned int u_int; | |
89 | #ifndef _U_LONG | |
90 | typedef unsigned long u_long; | |
91 | #define _U_LONG | |
92 | #endif | |
93 | typedef unsigned short ushort; /* Sys V compatibility */ | |
94 | typedef unsigned int uint; /* Sys V compatibility */ | |
95 | #endif | |
96 | ||
97 | typedef u_int64_t u_quad_t; /* quads */ | |
98 | typedef int64_t quad_t; | |
99 | typedef quad_t * qaddr_t; | |
100 | ||
101 | typedef char * caddr_t; /* core address */ | |
102 | typedef int32_t daddr_t; /* disk address */ | |
103 | ||
104 | #ifndef _DEV_T | |
105 | typedef __darwin_dev_t dev_t; /* device number */ | |
106 | #define _DEV_T | |
107 | #endif | |
108 | ||
109 | typedef u_int32_t fixpt_t; /* fixed point number */ | |
110 | ||
111 | #ifndef _BLKCNT_T | |
112 | typedef __darwin_blkcnt_t blkcnt_t; | |
113 | #define _BLKCNT_T | |
114 | #endif | |
115 | ||
116 | #ifndef _BLKSIZE_T | |
117 | typedef __darwin_blksize_t blksize_t; | |
118 | #define _BLKSIZE_T | |
119 | #endif | |
120 | ||
121 | #ifndef _GID_T | |
122 | typedef __darwin_gid_t gid_t; | |
123 | #define _GID_T | |
124 | #endif | |
125 | ||
126 | #ifndef _IN_ADDR_T | |
127 | #define _IN_ADDR_T | |
128 | typedef __uint32_t in_addr_t; /* base type for internet address */ | |
129 | #endif | |
130 | ||
131 | #ifndef _IN_PORT_T | |
132 | #define _IN_PORT_T | |
133 | typedef __uint16_t in_port_t; | |
134 | #endif | |
135 | ||
136 | #ifndef _INO_T | |
137 | typedef __darwin_ino_t ino_t; /* inode number */ | |
138 | #define _INO_T | |
139 | #endif | |
140 | ||
141 | #ifndef _KEY_T | |
142 | #define _KEY_T | |
143 | typedef __int32_t key_t; /* IPC key (for Sys V IPC) */ | |
144 | #endif | |
145 | ||
146 | #ifndef _MODE_T | |
147 | typedef __darwin_mode_t mode_t; | |
148 | #define _MODE_T | |
149 | #endif | |
150 | ||
151 | #ifndef _NLINK_T | |
152 | typedef __uint16_t nlink_t; /* link count */ | |
153 | #define _NLINK_T | |
154 | #endif | |
155 | ||
156 | #ifndef _ID_T | |
157 | #define _ID_T | |
158 | typedef __darwin_id_t id_t; /* can hold pid_t, gid_t, or uid_t */ | |
159 | #endif | |
160 | ||
161 | #ifndef _PID_T | |
162 | typedef __darwin_pid_t pid_t; | |
163 | #define _PID_T | |
164 | #endif | |
165 | ||
166 | #ifndef _OFF_T | |
167 | typedef __darwin_off_t off_t; | |
168 | #define _OFF_T | |
169 | #endif | |
170 | ||
171 | typedef int32_t segsz_t; /* segment size */ | |
172 | typedef int32_t swblk_t; /* swap offset */ | |
173 | ||
174 | #ifndef _UID_T | |
175 | typedef __darwin_uid_t uid_t; /* user id */ | |
176 | #define _UID_T | |
177 | #endif | |
178 | ||
179 | #ifndef _ID_T | |
180 | typedef __darwin_id_t id_t; | |
181 | #define _ID_T | |
182 | #endif | |
183 | ||
184 | #ifndef _POSIX_C_SOURCE | |
1c79356b A |
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))) | |
189 | #endif | |
190 | ||
91447636 A |
191 | #ifndef _CLOCK_T |
192 | #define _CLOCK_T | |
193 | typedef __darwin_clock_t clock_t; | |
1c79356b A |
194 | #endif |
195 | ||
91447636 A |
196 | #ifndef _SIZE_T |
197 | #define _SIZE_T | |
198 | /* DO NOT REMOVE THIS COMMENT: fixincludes needs to see | |
199 | * _GCC_SIZE_T */ | |
200 | typedef __darwin_size_t size_t; | |
1c79356b A |
201 | #endif |
202 | ||
91447636 A |
203 | #ifndef _SSIZE_T |
204 | #define _SSIZE_T | |
205 | typedef __darwin_ssize_t ssize_t; | |
1c79356b A |
206 | #endif |
207 | ||
91447636 A |
208 | #ifndef _TIME_T |
209 | #define _TIME_T | |
210 | typedef __darwin_time_t time_t; | |
1c79356b A |
211 | #endif |
212 | ||
91447636 A |
213 | #ifndef _USECONDS_T |
214 | #define _USECONDS_T | |
215 | typedef __darwin_useconds_t useconds_t; | |
216 | #endif | |
217 | ||
218 | #ifndef _SUSECONDS_T | |
219 | #define _SUSECONDS_T | |
220 | typedef __darwin_suseconds_t suseconds_t; | |
221 | #endif | |
222 | ||
223 | #ifndef _POSIX_C_SOURCE | |
224 | /* | |
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. | |
228 | */ | |
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; | |
233 | ||
234 | ||
235 | /* | |
236 | * Note: We use _FD_SET to protect all select related | |
237 | * types and macros | |
238 | */ | |
239 | #ifndef _FD_SET | |
240 | #define _FD_SET | |
1c79356b A |
241 | |
242 | /* | |
243 | * Select uses bit masks of file descriptors in longs. These macros | |
91447636 A |
244 | * manipulate such bit fields (the filesystem macros use chars). The |
245 | * extra protection here is to permit application redefinition above | |
246 | * the default size. | |
1c79356b A |
247 | */ |
248 | #ifndef FD_SETSIZE | |
0b4e3aa0 | 249 | #define FD_SETSIZE 1024 |
1c79356b A |
250 | #endif |
251 | ||
91447636 A |
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? */ | |
1c79356b | 255 | |
91447636 | 256 | __BEGIN_DECLS |
1c79356b | 257 | typedef struct fd_set { |
91447636 | 258 | __int32_t fds_bits[__DARWIN_howmany(FD_SETSIZE, __DARWIN_NFDBITS)]; |
1c79356b | 259 | } fd_set; |
91447636 | 260 | __END_DECLS |
1c79356b | 261 | |
91447636 A |
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 | |
266 | /* | |
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. | |
269 | */ | |
270 | #define FD_ZERO(p) __builtin_bzero(p, sizeof(*(p))) | |
271 | #else | |
1c79356b | 272 | #define FD_ZERO(p) bzero(p, sizeof(*(p))) |
91447636 A |
273 | #endif |
274 | #ifndef _POSIX_C_SOURCE | |
275 | #define FD_COPY(f, t) bcopy(f, t, sizeof(*(f))) | |
276 | #endif /* !_POSIX_C_SOURCE */ | |
277 | ||
278 | #endif /* !_FD_SET */ | |
279 | ||
1c79356b A |
280 | |
281 | #if defined(__STDC__) && defined(KERNEL) | |
282 | /* | |
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. | |
286 | */ | |
287 | struct proc; | |
288 | struct pgrp; | |
289 | struct ucred; | |
290 | struct rusage; | |
291 | struct file; | |
292 | struct buf; | |
293 | struct tty; | |
294 | struct uio; | |
295 | #endif | |
296 | ||
91447636 | 297 | #endif /* !_POSIX_C_SOURCE */ |
1c79356b A |
298 | #endif /* __ASSEMBLER__ */ |
299 | ||
1c79356b A |
300 | #ifndef __POSIX_LIB__ |
301 | ||
91447636 A |
302 | #ifndef _PTHREAD_ATTR_T |
303 | #define _PTHREAD_ATTR_T | |
304 | typedef __darwin_pthread_attr_t pthread_attr_t; | |
305 | #endif | |
306 | #ifndef _PTHREAD_COND_T | |
307 | #define _PTHREAD_COND_T | |
308 | typedef __darwin_pthread_cond_t pthread_cond_t; | |
309 | #endif | |
310 | #ifndef _PTHREAD_CONDATTR_T | |
311 | #define _PTHREAD_CONDATTR_T | |
312 | typedef __darwin_pthread_condattr_t pthread_condattr_t; | |
313 | #endif | |
314 | #ifndef _PTHREAD_MUTEX_T | |
315 | #define _PTHREAD_MUTEX_T | |
316 | typedef __darwin_pthread_mutex_t pthread_mutex_t; | |
317 | #endif | |
318 | #ifndef _PTHREAD_MUTEXATTR_T | |
319 | #define _PTHREAD_MUTEXATTR_T | |
320 | typedef __darwin_pthread_mutexattr_t pthread_mutexattr_t; | |
321 | #endif | |
322 | #ifndef _PTHREAD_ONCE_T | |
323 | #define _PTHREAD_ONCE_T | |
324 | typedef __darwin_pthread_once_t pthread_once_t; | |
325 | #endif | |
326 | #ifndef _PTHREAD_RWLOCK_T | |
327 | #define _PTHREAD_RWLOCK_T | |
328 | typedef __darwin_pthread_rwlock_t pthread_rwlock_t; | |
329 | #endif | |
330 | #ifndef _PTHREAD_RWLOCKATTR_T | |
331 | #define _PTHREAD_RWLOCKATTR_T | |
332 | typedef __darwin_pthread_rwlockattr_t pthread_rwlockattr_t; | |
333 | #endif | |
334 | #ifndef _PTHREAD_T | |
335 | #define _PTHREAD_T | |
336 | typedef __darwin_pthread_t pthread_t; | |
337 | #endif | |
9bccf70c | 338 | |
91447636 | 339 | #endif /* __POSIX_LIB__ */ |
9bccf70c | 340 | |
91447636 A |
341 | #ifndef _PTHREAD_KEY_T |
342 | #define _PTHREAD_KEY_T | |
343 | typedef __darwin_pthread_key_t pthread_key_t; | |
344 | #endif | |
1c79356b | 345 | |
91447636 A |
346 | /* statvfs and fstatvfs */ |
347 | #ifndef _FSBLKCNT_T | |
348 | #define _FSBLKCNT_T | |
349 | typedef __darwin_fsblkcnt_t fsblkcnt_t; | |
350 | #endif | |
1c79356b | 351 | |
91447636 A |
352 | #ifndef _FSFILCNT_T |
353 | #define _FSFILCNT_T | |
354 | typedef __darwin_fsfilcnt_t fsfilcnt_t; | |
355 | #endif | |
1c79356b A |
356 | |
357 | #endif /* !_SYS_TYPES_H_ */ |