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