]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
91447636 | 2 | * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. |
1c79356b A |
3 | * |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
ff6e181a 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. Please obtain a copy of the License at | |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | * file. | |
1c79356b | 12 | * |
ff6e181a A |
13 | * The Original Code and all software distributed under the License are |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
ff6e181a A |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
18 | * Please see the License for the specific language governing rights and | |
19 | * limitations under the License. | |
1c79356b A |
20 | * |
21 | * @APPLE_LICENSE_HEADER_END@ | |
22 | */ | |
23 | /* Copyright 1995 NeXT Computer, Inc. All rights reserved. */ | |
24 | /* | |
25 | * Copyright (c) 1991, 1993 | |
26 | * The Regents of the University of California. All rights reserved. | |
27 | * | |
28 | * This code is derived from software contributed to Berkeley by | |
29 | * Berkeley Software Design, Inc. | |
30 | * | |
31 | * Redistribution and use in source and binary forms, with or without | |
32 | * modification, are permitted provided that the following conditions | |
33 | * are met: | |
34 | * 1. Redistributions of source code must retain the above copyright | |
35 | * notice, this list of conditions and the following disclaimer. | |
36 | * 2. Redistributions in binary form must reproduce the above copyright | |
37 | * notice, this list of conditions and the following disclaimer in the | |
38 | * documentation and/or other materials provided with the distribution. | |
39 | * 3. All advertising materials mentioning features or use of this software | |
40 | * must display the following acknowledgement: | |
41 | * This product includes software developed by the University of | |
42 | * California, Berkeley and its contributors. | |
43 | * 4. Neither the name of the University nor the names of its contributors | |
44 | * may be used to endorse or promote products derived from this software | |
45 | * without specific prior written permission. | |
46 | * | |
47 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
48 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
49 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
50 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
51 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
52 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
53 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
54 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
55 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
56 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
57 | * SUCH DAMAGE. | |
58 | * | |
59 | * @(#)cdefs.h 8.8 (Berkeley) 1/9/95 | |
60 | */ | |
61 | ||
62 | #ifndef _CDEFS_H_ | |
63 | #define _CDEFS_H_ | |
64 | ||
65 | #if defined(__cplusplus) | |
66 | #define __BEGIN_DECLS extern "C" { | |
67 | #define __END_DECLS } | |
68 | #else | |
69 | #define __BEGIN_DECLS | |
70 | #define __END_DECLS | |
71 | #endif | |
72 | ||
73 | /* | |
74 | * The __CONCAT macro is used to concatenate parts of symbol names, e.g. | |
75 | * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. | |
76 | * The __CONCAT macro is a bit tricky -- make sure you don't put spaces | |
77 | * in between its arguments. __CONCAT can also concatenate double-quoted | |
78 | * strings produced by the __STRING macro, but this only works with ANSI C. | |
79 | */ | |
80 | #if defined(__STDC__) || defined(__cplusplus) | |
81 | #define __P(protos) protos /* full-blown ANSI C */ | |
82 | #define __CONCAT(x,y) x ## y | |
83 | #define __STRING(x) #x | |
84 | ||
85 | #define __const const /* define reserved names to standard */ | |
86 | #define __signed signed | |
87 | #define __volatile volatile | |
88 | #if defined(__cplusplus) | |
89 | #define __inline inline /* convert to C++ keyword */ | |
90 | #else | |
91 | #ifndef __GNUC__ | |
92 | #define __inline /* delete GCC keyword */ | |
93 | #endif /* !__GNUC__ */ | |
94 | #endif /* !__cplusplus */ | |
95 | ||
96 | #else /* !(__STDC__ || __cplusplus) */ | |
97 | #define __P(protos) () /* traditional C preprocessor */ | |
98 | #define __CONCAT(x,y) x/**/y | |
99 | #define __STRING(x) "x" | |
100 | ||
101 | #ifndef __GNUC__ | |
102 | #define __const /* delete pseudo-ANSI C keywords */ | |
103 | #define __inline | |
104 | #define __signed | |
105 | #define __volatile | |
106 | #endif /* !__GNUC__ */ | |
107 | ||
108 | /* | |
109 | * In non-ANSI C environments, new programs will want ANSI-only C keywords | |
110 | * deleted from the program and old programs will want them left alone. | |
111 | * When using a compiler other than gcc, programs using the ANSI C keywords | |
112 | * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS. | |
113 | * When using "gcc -traditional", we assume that this is the intent; if | |
114 | * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone. | |
115 | */ | |
116 | #ifndef NO_ANSI_KEYWORDS | |
117 | #define const __const /* convert ANSI C keywords */ | |
118 | #define inline __inline | |
119 | #define signed __signed | |
120 | #define volatile __volatile | |
121 | #endif /* !NO_ANSI_KEYWORDS */ | |
122 | #endif /* !(__STDC__ || __cplusplus) */ | |
123 | ||
124 | /* | |
125 | * GCC1 and some versions of GCC2 declare dead (non-returning) and | |
126 | * pure (no side effects) functions using "volatile" and "const"; | |
127 | * unfortunately, these then cause warnings under "-ansi -pedantic". | |
128 | * GCC2 uses a new, peculiar __attribute__((attrs)) style. All of | |
129 | * these work for GNU C++ (modulo a slight glitch in the C++ grammar | |
130 | * in the distribution version of 2.5.5). | |
131 | */ | |
0b4e3aa0 A |
132 | #if defined(__MWERKS__) && (__MWERKS__ > 0x2400) |
133 | /* newer Metrowerks compilers support __attribute__() */ | |
55e303ae A |
134 | #elif __GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ >= 5 |
135 | #define __dead2 __attribute__((__noreturn__)) | |
136 | #define __pure2 __attribute__((__const__)) | |
137 | #if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7 | |
138 | #define __unused /* no attribute */ | |
139 | #else | |
140 | #define __unused __attribute__((__unused__)) | |
141 | #endif | |
142 | #else | |
1c79356b A |
143 | #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ |
144 | #if defined(__GNUC__) && !defined(__STRICT_ANSI__) | |
55e303ae | 145 | /* __dead and __pure are depreciated. Use __dead2 and __pure2 instead */ |
1c79356b A |
146 | #define __dead __volatile |
147 | #define __pure __const | |
148 | #endif | |
149 | #endif | |
150 | ||
151 | /* Delete pseudo-keywords wherever they are not available or needed. */ | |
152 | #ifndef __dead | |
153 | #define __dead | |
154 | #define __pure | |
155 | #endif | |
55e303ae A |
156 | #ifndef __dead2 |
157 | #define __dead2 | |
158 | #define __pure2 | |
159 | #define __unused | |
160 | #endif | |
1c79356b | 161 | |
91447636 A |
162 | /* |
163 | * GCC 2.95 provides `__restrict' as an extension to C90 to support the | |
164 | * C99-specific `restrict' type qualifier. We happen to use `__restrict' as | |
165 | * a way to define the `restrict' type qualifier without disturbing older | |
166 | * software that is unaware of C99 keywords. | |
167 | */ | |
168 | #if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95) | |
169 | #if __STDC_VERSION__ < 199901 | |
170 | #define __restrict | |
171 | #else | |
172 | #define __restrict restrict | |
173 | #endif | |
174 | #endif | |
175 | ||
176 | /* | |
177 | * Compiler-dependent macros to declare that functions take printf-like | |
178 | * or scanf-like arguments. They are null except for versions of gcc | |
179 | * that are known to support the features properly. Functions declared | |
180 | * with these attributes will cause compilation warnings if there is a | |
181 | * mismatch between the format string and subsequent function parameter | |
182 | * types. | |
183 | */ | |
184 | #if __GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ >= 7 | |
185 | #define __printflike(fmtarg, firstvararg) \ | |
186 | __attribute__((__format__ (__printf__, fmtarg, firstvararg))) | |
187 | #define __scanflike(fmtarg, firstvararg) \ | |
188 | __attribute__((__format__ (__scanf__, fmtarg, firstvararg))) | |
189 | #else | |
190 | #define __printflike(fmtarg, firstvararg) | |
191 | #define __scanflike(fmtarg, firstvararg) | |
192 | #endif | |
193 | ||
55e303ae | 194 | #define __IDSTRING(name,string) static const char name[] __unused = string |
1c79356b A |
195 | |
196 | #ifndef __COPYRIGHT | |
197 | #define __COPYRIGHT(s) __IDSTRING(copyright,s) | |
198 | #endif | |
199 | ||
200 | #ifndef __RCSID | |
201 | #define __RCSID(s) __IDSTRING(rcsid,s) | |
202 | #endif | |
203 | ||
204 | #ifndef __SCCSID | |
205 | #define __SCCSID(s) __IDSTRING(sccsid,s) | |
206 | #endif | |
207 | ||
208 | #ifndef __PROJECT_VERSION | |
209 | #define __PROJECT_VERSION(s) __IDSTRING(project_version,s) | |
210 | #endif | |
211 | ||
91447636 A |
212 | /* |
213 | * The __DARWIN_ALIAS macros is used to do symbol renaming, | |
214 | * they allow old code to use the old symbol thus maintiang binary | |
215 | * compatability while new code can use a new improved version of the | |
216 | * same function. | |
217 | * | |
218 | * By default newly complied code will actually get the same symbols | |
219 | * that the old code did. Defining any of _APPLE_C_SOURCE, _XOPEN_SOURCE, | |
220 | * or _POSIX_C_SOURCE will give you the new symbols. Defining _XOPEN_SOURCE | |
221 | * or _POSIX_C_SOURCE also restricts the avilable symbols to a subset of | |
222 | * Apple's APIs. | |
223 | * | |
224 | * __DARWIN_ALIAS is used by itself if the function signature has not | |
225 | * changed, it is used along with a #ifdef check for __DARWIN_UNIX03 | |
226 | * if the signature has changed. Because the __LP64__ enviroment | |
227 | * only supports UNIX03 sementics it causes __DARWIN_UNIX03 to be | |
228 | * defined, but causes __DARWIN_ALIAS to do no symbol mangling. | |
229 | */ | |
230 | ||
231 | #if !defined(__DARWIN_UNIX03) | |
232 | #if defined(_APPLE_C_SOURCE) || defined(_XOPEN_SOURCE) || defined(_POSIX_C_SOURCE) || defined(__LP64__) | |
233 | #if defined(_NONSTD_SOURCE) | |
234 | #error "Can't define both _NONSTD_SOURCE and any of _APPLE_C_SOURCE, _XOPEN_SOURCE, _POSIX_C_SOURCE, or __LP64__" | |
235 | #endif /* _NONSTD_SOURCE */ | |
236 | #define __DARWIN_UNIX03 1 | |
237 | #elif defined(_NONSTD_SOURCE) | |
238 | #define __DARWIN_UNIX03 0 | |
239 | #else /* default */ | |
240 | #define __DARWIN_UNIX03 0 | |
241 | #endif /* _APPLE_C_SOURCE || _XOPEN_SOURCE || _POSIX_C_SOURCE || __LP64__ */ | |
242 | #endif /* !__DARWIN_UNIX03 */ | |
243 | ||
244 | #if __DARWIN_UNIX03 && !defined(__LP64__) | |
245 | #define __DARWIN_ALIAS(sym) __asm("_" __STRING(sym) "$UNIX2003") | |
246 | #else | |
247 | #define __DARWIN_ALIAS(sym) | |
248 | #endif | |
249 | ||
250 | ||
251 | /* | |
252 | * POSIX.1 requires that the macros we test be defined before any standard | |
253 | * header file is included. This permits us to convert values for feature | |
254 | * testing, as necessary, using only _POSIX_C_SOURCE. | |
255 | * | |
256 | * Here's a quick run-down of the versions: | |
257 | * defined(_POSIX_SOURCE) 1003.1-1988 | |
258 | * _POSIX_C_SOURCE == 1L 1003.1-1990 | |
259 | * _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option | |
260 | * _POSIX_C_SOURCE == 199309L 1003.1b-1993 | |
261 | * _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, | |
262 | * and the omnibus ISO/IEC 9945-1: 1996 | |
263 | * _POSIX_C_SOURCE == 200112L 1003.1-2001 | |
264 | * | |
265 | * In addition, the X/Open Portability Guide, which is now the Single UNIX | |
266 | * Specification, defines a feature-test macro which indicates the version of | |
267 | * that specification, and which subsumes _POSIX_C_SOURCE. | |
268 | */ | |
269 | ||
270 | /* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. */ | |
271 | #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1L | |
272 | #undef _POSIX_C_SOURCE | |
273 | #define _POSIX_C_SOURCE 199009L | |
274 | #endif | |
275 | ||
276 | /* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. */ | |
277 | #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2L | |
278 | #undef _POSIX_C_SOURCE | |
279 | #define _POSIX_C_SOURCE 199209L | |
280 | #endif | |
281 | ||
282 | /* Deal with various X/Open Portability Guides and Single UNIX Spec. */ | |
283 | #ifdef _XOPEN_SOURCE | |
284 | #if _XOPEN_SOURCE - 0L >= 600L | |
285 | #undef _POSIX_C_SOURCE | |
286 | #define _POSIX_C_SOURCE 200112L | |
287 | #elif _XOPEN_SOURCE - 0L >= 500L | |
288 | #undef _POSIX_C_SOURCE | |
289 | #define _POSIX_C_SOURCE 199506L | |
290 | #endif | |
291 | #endif | |
292 | ||
293 | /* | |
294 | * Deal with all versions of POSIX. The ordering relative to the tests above is | |
295 | * important. | |
296 | */ | |
297 | #if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) | |
298 | #define _POSIX_C_SOURCE 198808L | |
299 | #endif | |
300 | ||
301 | /* | |
302 | * long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and | |
303 | * c99 still want long longs. While not perfect, we allow long longs for | |
304 | * g++. | |
305 | */ | |
306 | #define __DARWIN_NO_LONG_LONG (defined(__STRICT_ANSI__) \ | |
307 | && (__STDC_VERSION__-0 < 199901L) \ | |
308 | && !defined(__GNUG__)) | |
309 | ||
310 | /* | |
311 | * Long double compatibility macro allow selecting variant symbols based | |
312 | * on the old (compatible) 64-bit long doubles, or the new 128-bit | |
313 | * long doubles. This applies only to ppc; i386 already has long double | |
314 | * support, while ppc64 doesn't have any backwards history. | |
315 | */ | |
316 | #if defined(__ppc__) | |
317 | # if defined(__LDBL_MANT_DIG__) && defined(__DBL_MANT_DIG__) && \ | |
318 | __LDBL_MANT_DIG__ > __DBL_MANT_DIG__ | |
319 | # if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0 < 1040 | |
320 | # define __DARWIN_LDBL_COMPAT(x) __asm("_" __STRING(x) "$LDBLStub") | |
321 | # else | |
322 | # define __DARWIN_LDBL_COMPAT(x) __asm("_" __STRING(x) "$LDBL128") | |
323 | # endif | |
324 | # define __DARWIN_LDBL_COMPAT2(x) __asm("_" __STRING(x) "$LDBL128") | |
325 | # define __DARWIN_LONG_DOUBLE_IS_DOUBLE 0 | |
326 | # else | |
327 | # define __DARWIN_LDBL_COMPAT(x) /* nothing */ | |
328 | # define __DARWIN_LDBL_COMPAT2(x) /* nothing */ | |
329 | # define __DARWIN_LONG_DOUBLE_IS_DOUBLE 1 | |
330 | # endif | |
331 | #elif defined(__i386__) || defined(__ppc64__) | |
332 | # define __DARWIN_LDBL_COMPAT(x) /* nothing */ | |
333 | # define __DARWIN_LDBL_COMPAT2(x) /* nothing */ | |
334 | # define __DARWIN_LONG_DOUBLE_IS_DOUBLE 0 | |
335 | #else | |
336 | # error Unknown architecture | |
337 | #endif | |
338 | ||
339 | /* | |
340 | * Structure alignment control macros. These specify how certain | |
341 | * shared structures should be aligned. Some may need backward | |
342 | * compatible legacy (POWER) alignment, while others may need | |
343 | * forward compatible (NATURAL) alignment. | |
344 | */ | |
345 | #if !defined(__DARWIN_ALIGN_POWER) | |
346 | #if defined(__ppc64__) | |
347 | #define __DARWIN_ALIGN_POWER 1 | |
348 | #else | |
349 | #define __DARWIN_ALIGN_POWER 0 | |
350 | #endif | |
351 | #endif /* __DARWIN_ALIGN_POWER */ | |
352 | ||
353 | #if !defined(__DARWIN_ALIGN_NATURAL) | |
354 | #if defined(__ppc__) && defined(KERNEL) | |
355 | #define __DARWIN_ALIGN_NATURAL 1 | |
356 | #else | |
357 | #define __DARWIN_ALIGN_NATURAL 0 | |
358 | #endif | |
359 | #endif /* __DARWIN_ALIGN_NATURAL */ | |
360 | ||
1c79356b | 361 | #endif /* !_CDEFS_H_ */ |