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