]> git.saurik.com Git - apple/xnu.git/blob - bsd/sys/_types.h
xnu-792.12.6.tar.gz
[apple/xnu.git] / bsd / sys / _types.h
1 /*
2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_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
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@
29 */
30
31 #ifndef _SYS__TYPES_H_
32 #define _SYS__TYPES_H_
33
34 #include <sys/cdefs.h>
35 #include <machine/_types.h>
36
37 /* Forward references */
38 #ifndef _POSIX_C_SOURCE
39 struct mcontext;
40 struct mcontext64;
41 #else /* _POSIX_C_SOURCE */
42 struct __darwin_mcontext;
43 #endif /* _POSIX_C_SOURCE */
44
45 /* pthread opaque structures */
46 #if defined(__LP64__)
47 #define __PTHREAD_SIZE__ 1168
48 #define __PTHREAD_ATTR_SIZE__ 56
49 #define __PTHREAD_MUTEXATTR_SIZE__ 8
50 #define __PTHREAD_MUTEX_SIZE__ 56
51 #define __PTHREAD_CONDATTR_SIZE__ 8
52 #define __PTHREAD_COND_SIZE__ 40
53 #define __PTHREAD_ONCE_SIZE__ 8
54 #define __PTHREAD_RWLOCK_SIZE__ 192
55 #define __PTHREAD_RWLOCKATTR_SIZE__ 16
56 #else /* __LP64__ */
57 #define __PTHREAD_SIZE__ 596
58 #define __PTHREAD_ATTR_SIZE__ 36
59 #define __PTHREAD_MUTEXATTR_SIZE__ 8
60 #define __PTHREAD_MUTEX_SIZE__ 40
61 #define __PTHREAD_CONDATTR_SIZE__ 4
62 #define __PTHREAD_COND_SIZE__ 24
63 #define __PTHREAD_ONCE_SIZE__ 4
64 #define __PTHREAD_RWLOCK_SIZE__ 124
65 #define __PTHREAD_RWLOCKATTR_SIZE__ 12
66 #endif /* __LP64__ */
67
68 struct __darwin_pthread_handler_rec
69 {
70 void (*__routine)(void *); /* Routine to call */
71 void *__arg; /* Argument to pass */
72 struct __darwin_pthread_handler_rec *__next;
73 };
74 struct _opaque_pthread_attr_t { long __sig; char __opaque[__PTHREAD_ATTR_SIZE__]; };
75 struct _opaque_pthread_cond_t { long __sig; char __opaque[__PTHREAD_COND_SIZE__]; };
76 struct _opaque_pthread_condattr_t { long __sig; char __opaque[__PTHREAD_CONDATTR_SIZE__]; };
77 struct _opaque_pthread_mutex_t { long __sig; char __opaque[__PTHREAD_MUTEX_SIZE__]; };
78 struct _opaque_pthread_mutexattr_t { long __sig; char __opaque[__PTHREAD_MUTEXATTR_SIZE__]; };
79 struct _opaque_pthread_once_t { long __sig; char __opaque[__PTHREAD_ONCE_SIZE__]; };
80 struct _opaque_pthread_rwlock_t { long __sig; char __opaque[__PTHREAD_RWLOCK_SIZE__]; };
81 struct _opaque_pthread_rwlockattr_t { long __sig; char __opaque[__PTHREAD_RWLOCKATTR_SIZE__]; };
82 struct _opaque_pthread_t { long __sig; struct __darwin_pthread_handler_rec *__cleanup_stack; char __opaque[__PTHREAD_SIZE__]; };
83
84 /*
85 * Type definitions; takes common type definitions that must be used
86 * in multiple header files due to [XSI], removes them from the system
87 * space, and puts them in the implementation space.
88 */
89
90 #ifdef __cplusplus
91 #ifdef __GNUG__
92 #define __DARWIN_NULL __null
93 #else /* ! __GNUG__ */
94 #ifdef __LP64__
95 #define __DARWIN_NULL (0L)
96 #else /* !__LP64__ */
97 #define __DARWIN_NULL 0
98 #endif /* __LP64__ */
99 #endif /* __GNUG__ */
100 #else /* ! __cplusplus */
101 #define __DARWIN_NULL ((void *)0)
102 #endif /* __cplusplus */
103
104 typedef __int64_t __darwin_blkcnt_t; /* total blocks */
105 typedef __int32_t __darwin_blksize_t; /* preferred block size */
106 typedef __int32_t __darwin_dev_t; /* dev_t */
107 typedef unsigned int __darwin_fsblkcnt_t; /* Used by statvfs and fstatvfs */
108 typedef unsigned int __darwin_fsfilcnt_t; /* Used by statvfs and fstatvfs */
109 typedef __uint32_t __darwin_gid_t; /* [???] process and group IDs */
110 typedef __uint32_t __darwin_id_t; /* [XSI] pid_t, uid_t, or gid_t*/
111 typedef __uint32_t __darwin_ino_t; /* [???] Used for inodes */
112 typedef __darwin_natural_t __darwin_mach_port_name_t; /* Used by mach */
113 typedef __darwin_mach_port_name_t __darwin_mach_port_t; /* Used by mach */
114 #ifndef _POSIX_C_SOURCE
115 typedef struct mcontext *__darwin_mcontext_t; /* [???] machine context */
116 typedef struct mcontext64 *__darwin_mcontext64_t; /* [???] machine context */
117 #else /* _POSIX_C_SOURCE */
118 typedef struct __darwin_mcontext *__darwin_mcontext_t; /* [???] machine context */
119 #endif /* _POSIX_C_SOURCE */
120 typedef __uint16_t __darwin_mode_t; /* [???] Some file attributes */
121 typedef __int64_t __darwin_off_t; /* [???] Used for file sizes */
122 typedef __int32_t __darwin_pid_t; /* [???] process and group IDs */
123 typedef struct _opaque_pthread_attr_t
124 __darwin_pthread_attr_t; /* [???] Used for pthreads */
125 typedef struct _opaque_pthread_cond_t
126 __darwin_pthread_cond_t; /* [???] Used for pthreads */
127 typedef struct _opaque_pthread_condattr_t
128 __darwin_pthread_condattr_t; /* [???] Used for pthreads */
129 typedef unsigned long __darwin_pthread_key_t; /* [???] Used for pthreads */
130 typedef struct _opaque_pthread_mutex_t
131 __darwin_pthread_mutex_t; /* [???] Used for pthreads */
132 typedef struct _opaque_pthread_mutexattr_t
133 __darwin_pthread_mutexattr_t; /* [???] Used for pthreads */
134 typedef struct _opaque_pthread_once_t
135 __darwin_pthread_once_t; /* [???] Used for pthreads */
136 typedef struct _opaque_pthread_rwlock_t
137 __darwin_pthread_rwlock_t; /* [???] Used for pthreads */
138 typedef struct _opaque_pthread_rwlockattr_t
139 __darwin_pthread_rwlockattr_t; /* [???] Used for pthreads */
140 typedef struct _opaque_pthread_t
141 *__darwin_pthread_t; /* [???] Used for pthreads */
142 typedef __uint32_t __darwin_sigset_t; /* [???] signal set */
143 typedef __int32_t __darwin_suseconds_t; /* [???] microseconds */
144 typedef __uint32_t __darwin_uid_t; /* [???] user IDs */
145 typedef __uint32_t __darwin_useconds_t; /* [???] microseconds */
146 typedef unsigned char __darwin_uuid_t[16];
147
148 /* Structure used in sigaltstack call. */
149 #ifndef _POSIX_C_SOURCE
150 struct sigaltstack
151 #else /* _POSIX_C_SOURCE */
152 struct __darwin_sigaltstack
153 #endif /* _POSIX_C_SOURCE */
154 {
155 void *ss_sp; /* signal stack base */
156 __darwin_size_t ss_size; /* signal stack length */
157 int ss_flags; /* SA_DISABLE and/or SA_ONSTACK */
158 };
159 #ifndef _POSIX_C_SOURCE
160 typedef struct sigaltstack __darwin_stack_t; /* [???] signal stack */
161 #else /* _POSIX_C_SOURCE */
162 typedef struct __darwin_sigaltstack __darwin_stack_t; /* [???] signal stack */
163 #endif /* _POSIX_C_SOURCE */
164
165 /* user context */
166 #ifndef _POSIX_C_SOURCE
167 struct ucontext
168 #else /* _POSIX_C_SOURCE */
169 struct __darwin_ucontext
170 #endif /* _POSIX_C_SOURCE */
171 {
172 int uc_onstack;
173 __darwin_sigset_t uc_sigmask; /* signal mask used by this context */
174 __darwin_stack_t uc_stack; /* stack used by this context */
175 #ifndef _POSIX_C_SOURCE
176 struct ucontext *uc_link; /* pointer to resuming context */
177 #else /* _POSIX_C_SOURCE */
178 struct __darwin_ucontext *uc_link; /* pointer to resuming context */
179 #endif /* _POSIX_C_SOURCE */
180 __darwin_size_t uc_mcsize; /* size of the machine context passed in */
181 __darwin_mcontext_t uc_mcontext; /* pointer to machine specific context */
182 };
183 #ifndef _POSIX_C_SOURCE
184 typedef struct ucontext __darwin_ucontext_t; /* [???] user context */
185 #else /* _POSIX_C_SOURCE */
186 typedef struct __darwin_ucontext __darwin_ucontext_t; /* [???] user context */
187 #endif /* _POSIX_C_SOURCE */
188
189 #ifndef _POSIX_C_SOURCE
190 struct ucontext64 {
191 int uc_onstack;
192 __darwin_sigset_t uc_sigmask; /* signal mask used by this context */
193 __darwin_stack_t uc_stack; /* stack used by this context */
194 struct ucontext64 *uc_link; /* pointer to resuming context */
195 __darwin_size_t uc_mcsize; /* size of the machine context passed in */
196 __darwin_mcontext64_t uc_mcontext64; /* pointer to machine specific context */
197 };
198 typedef struct ucontext64 __darwin_ucontext64_t; /* [???] user context */
199 #endif /* _POSIX_C_SOURCE */
200
201 #ifdef KERNEL
202 #ifndef offsetof
203 #define offsetof(type, member) ((size_t)(&((type *)0)->member))
204 #endif /* offsetof */
205 #endif /* KERNEL */
206 #endif /* _SYS__TYPES_H_ */