Chameleon

View _structs.h

1/*
2 * Copyright (c) 2004-2006 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_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 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
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29#include <sys/cdefs.h>
30#include <sys/_types.h>
31
32#ifdef __need_ucontext_t
33#ifndef __need_struct_ucontext
34#define __need_struct_ucontext
35#endif /* __need_struct_ucontext */
36#endif /* __need_ucontext_t */
37
38#ifdef __need_ucontext64_t
39#ifndef __need_struct_ucontext64
40#define __need_struct_ucontext64
41#endif /* __need_struct_ucontext64 */
42#endif /* __need_ucontext64_t */
43
44#ifdef __need_struct_ucontext
45#ifndef __need_struct_mcontext
46#define __need_struct_mcontext
47#endif /* __need_struct_mcontext */
48#endif /* __need_struct_ucontext */
49
50#ifdef __need_struct_ucontext64
51#ifndef __need_struct_mcontext64
52#define __need_struct_mcontext64
53#endif /* __need_struct_mcontext64 */
54#endif /* __need_struct_ucontext64 */
55
56#if defined(__need_struct_mcontext) || defined(__need_struct_mcontext64)
57#include <machine/_structs.h>
58#endif /* __need_struct_mcontext || __need_struct_mcontext64 */
59
60#if defined(__need_stack_t) || defined(__need_struct_ucontext) || defined(__need_struct_ucontext64)
61#ifndef __need_struct_sigaltstack
62#define __need_struct_sigaltstack
63#endif /* __need_struct_sigaltstack */
64#endif /* __need_stack_t || __need_struct_ucontext || __need_struct_ucontext64 */
65
66#ifdef __need_struct_sigaltstack
67#undef __need_struct_sigaltstack
68/* Structure used in sigaltstack call. */
69#ifndef _STRUCT_SIGALTSTACK
70#if __DARWIN_UNIX03
71#define _STRUCT_SIGALTSTACKstruct __darwin_sigaltstack
72#else /* !__DARWIN_UNIX03 */
73#define _STRUCT_SIGALTSTACKstruct sigaltstack
74#endif /* __DARWIN_UNIX03 */
75_STRUCT_SIGALTSTACK
76{
77void*ss_sp;/* signal stack base */
78__darwin_size_t ss_size;/* signal stack length */
79intss_flags;/* SA_DISABLE and/or SA_ONSTACK */
80};
81#endif /* _STRUCT_SIGALTSTACK */
82#endif /* __need_struct_sigaltstack */
83
84#ifdef __need_struct_timespec
85#undef __need_struct_timespec
86#ifndef _STRUCT_TIMESPEC
87#define _STRUCT_TIMESPECstruct timespec
88_STRUCT_TIMESPEC
89{
90__darwin_time_ttv_sec;
91longtv_nsec;
92};
93#endif /* _STRUCT_TIMESPEC */
94#endif /* __need_struct_timespec */
95
96#ifdef __need_struct_timeval
97#undef __need_struct_timeval
98#ifndef _STRUCT_TIMEVAL
99#define _STRUCT_TIMEVALstruct timeval
100_STRUCT_TIMEVAL
101{
102__darwin_time_ttv_sec;/* seconds */
103__darwin_suseconds_ttv_usec;/* and microseconds */
104};
105#endif /* _STRUCT_TIMEVAL */
106#endif /* __need_struct_timeval */
107
108#ifdef __need_struct_timeval32
109#undef __need_struct_timeval32
110#ifndef _STRUCT_TIMEVAL32
111#define _STRUCT_TIMEVAL32struct timeval32
112_STRUCT_TIMEVAL32
113{
114__int32_ttv_sec;/* seconds */
115__int32_ttv_usec;/* and microseconds */
116};
117#endif /* _STRUCT_TIMEVAL32 */
118#endif /* __need_struct_timeval32 */
119
120#ifdef __need_struct_ucontext
121#undef __need_struct_ucontext
122#ifndef _STRUCT_UCONTEXT
123#if __DARWIN_UNIX03
124#define _STRUCT_UCONTEXTstruct __darwin_ucontext
125#else /* !__DARWIN_UNIX03 */
126#define _STRUCT_UCONTEXTstruct ucontext
127#endif /* __DARWIN_UNIX03 */
128_STRUCT_UCONTEXT
129{
130intuc_onstack;
131__darwin_sigset_tuc_sigmask;/* signal mask used by this context */
132_STRUCT_SIGALTSTACK uc_stack;/* stack used by this context */
133_STRUCT_UCONTEXT*uc_link;/* pointer to resuming context */
134__darwin_size_tuc_mcsize;/* size of the machine context passed in */
135_STRUCT_MCONTEXT*uc_mcontext;/* pointer to machine specific context */
136#ifdef _XOPEN_SOURCE
137_STRUCT_MCONTEXT__mcontext_data;
138#endif /* _XOPEN_SOURCE */
139};
140#endif /* _STRUCT_UCONTEXT */
141#endif /* __need_struct_ucontext */
142
143#ifdef __need_struct_ucontext64
144#undef __need_struct_ucontext64
145#ifndef _STRUCT_UCONTEXT64
146#if __DARWIN_UNIX03
147#define _STRUCT_UCONTEXT64struct __darwin_ucontext64
148#else /* !__DARWIN_UNIX03 */
149#define _STRUCT_UCONTEXT64struct ucontext64
150#endif /* __DARWIN_UNIX03 */
151_STRUCT_UCONTEXT64
152{
153intuc_onstack;
154__darwin_sigset_tuc_sigmask;/* signal mask used by this context */
155_STRUCT_SIGALTSTACK uc_stack;/* stack used by this context */
156_STRUCT_UCONTEXT64*uc_link;/* pointer to resuming context */
157__darwin_size_tuc_mcsize;/* size of the machine context passed in */
158_STRUCT_MCONTEXT64*uc_mcontext64;/* pointer to machine specific context */
159};
160#endif /* _STRUCT_UCONTEXT64 */
161#endif /* __need_struct_ucontext64 */
162
163
164#ifdef __need_fd_set
165#undef __need_fd_set
166#ifndef _FD_SET
167#define _FD_SET
168/*
169 * Select uses bit masks of file descriptors in longs. These macros
170 * manipulate such bit fields (the filesystem macros use chars). The
171 * extra protection here is to permit application redefinition above
172 * the default size.
173 */
174#ifdef FD_SETSIZE
175#define__DARWIN_FD_SETSIZEFD_SETSIZE
176#else /* !FD_SETSIZE */
177#define__DARWIN_FD_SETSIZE1024
178#endif /* FD_SETSIZE */
179#define__DARWIN_NBBY8/* bits in a byte */
180#define __DARWIN_NFDBITS(sizeof(__int32_t) * __DARWIN_NBBY) /* bits per mask */
181#define__DARWIN_howmany(x, y) (((x) + ((y) - 1)) / (y))/* # y's == x bits? */
182
183__BEGIN_DECLS
184typedefstruct fd_set {
185__int32_tfds_bits[__DARWIN_howmany(__DARWIN_FD_SETSIZE, __DARWIN_NFDBITS)];
186} fd_set;
187__END_DECLS
188
189/* This inline avoids argument side-effect issues with FD_ISSET() */
190static __inline int
191__darwin_fd_isset(int _n, struct fd_set *_p)
192{
193return (_p->fds_bits[_n/__DARWIN_NFDBITS] & (1<<(_n % __DARWIN_NFDBITS)));
194}
195
196#define__DARWIN_FD_SET(n, p)do { int __fd = (n); ((p)->fds_bits[__fd/__DARWIN_NFDBITS] |= (1<<(__fd % __DARWIN_NFDBITS))); } while(0)
197#define__DARWIN_FD_CLR(n, p)do { int __fd = (n); ((p)->fds_bits[__fd/__DARWIN_NFDBITS] &= ~(1<<(__fd % __DARWIN_NFDBITS))); } while(0)
198#define__DARWIN_FD_ISSET(n, p)__darwin_fd_isset((n), (p))
199
200#if __GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 3
201/*
202 * Use the built-in bzero function instead of the library version so that
203 * we do not pollute the namespace or introduce prototype warnings.
204 */
205#define__DARWIN_FD_ZERO(p)__builtin_bzero(p, sizeof(*(p)))
206#else
207#define__DARWIN_FD_ZERO(p)bzero(p, sizeof(*(p)))
208#endif
209
210#define__DARWIN_FD_COPY(f, t)bcopy(f, t, sizeof(*(f)))
211#endif /* _FD_SET */
212#endif /* __need_fd_set */
213
214#ifdef __need_stack_t
215#undef __need_stack_t
216#ifndef _STACK_T
217#define _STACK_T
218typedef _STRUCT_SIGALTSTACKstack_t; /* [???] signal stack */
219#endif /* _STACK_T */
220#endif /* __need_stack_t */
221
222#ifdef __need_ucontext_t
223#undef __need_ucontext_t
224/* user context */
225#ifndef _UCONTEXT_T
226#define _UCONTEXT_T
227typedef _STRUCT_UCONTEXTucontext_t;/* [???] user context */
228#endif /* _UCONTEXT_T */
229#endif /* __need_ucontext_t */
230
231#ifdef __need_ucontext64_t
232#undef __need_ucontext64_t
233#ifndef _UCONTEXT64_T
234#define _UCONTEXT64_T
235typedef _STRUCT_UCONTEXT64ucontext64_t;/* [???] user context */
236#endif /* _UCONTEXT64_T */
237#endif /* __need_ucontext64_t */
238

Archive Download this file

Attachment to issue 295

Created: 11 years 5 months ago by makom leroy