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