]>
git.saurik.com Git - apple/xnu.git/blob - bsd/sys/cdefs.h
2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 /* Copyright 1995 NeXT Computer, Inc. All rights reserved. */
30 * Copyright (c) 1991, 1993
31 * The Regents of the University of California. All rights reserved.
33 * This code is derived from software contributed to Berkeley by
34 * Berkeley Software Design, Inc.
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
44 * 3. All advertising materials mentioning features or use of this software
45 * must display the following acknowledgement:
46 * This product includes software developed by the University of
47 * California, Berkeley and its contributors.
48 * 4. Neither the name of the University nor the names of its contributors
49 * may be used to endorse or promote products derived from this software
50 * without specific prior written permission.
52 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
53 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
55 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
56 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
57 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
58 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
59 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
60 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
61 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 * @(#)cdefs.h 8.8 (Berkeley) 1/9/95
70 #if defined(__cplusplus)
71 #define __BEGIN_DECLS extern "C" {
79 * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
80 * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
81 * The __CONCAT macro is a bit tricky -- make sure you don't put spaces
82 * in between its arguments. __CONCAT can also concatenate double-quoted
83 * strings produced by the __STRING macro, but this only works with ANSI C.
85 #if defined(__STDC__) || defined(__cplusplus)
86 #define __P(protos) protos /* full-blown ANSI C */
87 #define __CONCAT(x,y) x ## y
88 #define __STRING(x) #x
90 #define __const const /* define reserved names to standard */
91 #define __signed signed
92 #define __volatile volatile
93 #if defined(__cplusplus)
94 #define __inline inline /* convert to C++ keyword */
97 #define __inline /* delete GCC keyword */
98 #endif /* !__GNUC__ */
99 #endif /* !__cplusplus */
101 #else /* !(__STDC__ || __cplusplus) */
102 #define __P(protos) () /* traditional C preprocessor */
103 #define __CONCAT(x,y) x/**/y
104 #define __STRING(x) "x"
107 #define __const /* delete pseudo-ANSI C keywords */
111 #endif /* !__GNUC__ */
114 * In non-ANSI C environments, new programs will want ANSI-only C keywords
115 * deleted from the program and old programs will want them left alone.
116 * When using a compiler other than gcc, programs using the ANSI C keywords
117 * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
118 * When using "gcc -traditional", we assume that this is the intent; if
119 * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
121 #ifndef NO_ANSI_KEYWORDS
122 #define const __const /* convert ANSI C keywords */
123 #define inline __inline
124 #define signed __signed
125 #define volatile __volatile
126 #endif /* !NO_ANSI_KEYWORDS */
127 #endif /* !(__STDC__ || __cplusplus) */
130 * GCC1 and some versions of GCC2 declare dead (non-returning) and
131 * pure (no side effects) functions using "volatile" and "const";
132 * unfortunately, these then cause warnings under "-ansi -pedantic".
133 * GCC2 uses a new, peculiar __attribute__((attrs)) style. All of
134 * these work for GNU C++ (modulo a slight glitch in the C++ grammar
135 * in the distribution version of 2.5.5).
137 #if defined(__MWERKS__) && (__MWERKS__ > 0x2400)
138 /* newer Metrowerks compilers support __attribute__() */
139 #elif __GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ >= 5
140 #define __dead2 __attribute__((__noreturn__))
141 #define __pure2 __attribute__((__const__))
142 #if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7
143 #define __unused /* no attribute */
145 #define __unused __attribute__((__unused__))
148 #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */
149 #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
150 /* __dead and __pure are depreciated. Use __dead2 and __pure2 instead */
151 #define __dead __volatile
152 #define __pure __const
156 /* Delete pseudo-keywords wherever they are not available or needed. */
168 * GCC 2.95 provides `__restrict' as an extension to C90 to support the
169 * C99-specific `restrict' type qualifier. We happen to use `__restrict' as
170 * a way to define the `restrict' type qualifier without disturbing older
171 * software that is unaware of C99 keywords.
173 #if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95)
174 #if __STDC_VERSION__ < 199901
177 #define __restrict restrict
182 * Compiler-dependent macros to declare that functions take printf-like
183 * or scanf-like arguments. They are null except for versions of gcc
184 * that are known to support the features properly. Functions declared
185 * with these attributes will cause compilation warnings if there is a
186 * mismatch between the format string and subsequent function parameter
189 #if __GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ >= 7
190 #define __printflike(fmtarg, firstvararg) \
191 __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
192 #define __scanflike(fmtarg, firstvararg) \
193 __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
195 #define __printflike(fmtarg, firstvararg)
196 #define __scanflike(fmtarg, firstvararg)
199 #define __IDSTRING(name,string) static const char name[] __unused = string
202 #define __COPYRIGHT(s) __IDSTRING(copyright,s)
206 #define __RCSID(s) __IDSTRING(rcsid,s)
210 #define __SCCSID(s) __IDSTRING(sccsid,s)
213 #ifndef __PROJECT_VERSION
214 #define __PROJECT_VERSION(s) __IDSTRING(project_version,s)
218 * The __DARWIN_ALIAS macros is used to do symbol renaming,
219 * they allow old code to use the old symbol thus maintiang binary
220 * compatability while new code can use a new improved version of the
223 * By default newly complied code will actually get the same symbols
224 * that the old code did. Defining any of _APPLE_C_SOURCE, _XOPEN_SOURCE,
225 * or _POSIX_C_SOURCE will give you the new symbols. Defining _XOPEN_SOURCE
226 * or _POSIX_C_SOURCE also restricts the avilable symbols to a subset of
229 * __DARWIN_ALIAS is used by itself if the function signature has not
230 * changed, it is used along with a #ifdef check for __DARWIN_UNIX03
231 * if the signature has changed. Because the __LP64__ enviroment
232 * only supports UNIX03 sementics it causes __DARWIN_UNIX03 to be
233 * defined, but causes __DARWIN_ALIAS to do no symbol mangling.
236 #if !defined(__DARWIN_UNIX03)
237 #if defined(_APPLE_C_SOURCE) || defined(_XOPEN_SOURCE) || defined(_POSIX_C_SOURCE) || defined(__LP64__)
238 #if defined(_NONSTD_SOURCE)
239 #error "Can't define both _NONSTD_SOURCE and any of _APPLE_C_SOURCE, _XOPEN_SOURCE, _POSIX_C_SOURCE, or __LP64__"
240 #endif /* _NONSTD_SOURCE */
241 #define __DARWIN_UNIX03 1
242 #elif defined(_NONSTD_SOURCE)
243 #define __DARWIN_UNIX03 0
245 #define __DARWIN_UNIX03 0
246 #endif /* _APPLE_C_SOURCE || _XOPEN_SOURCE || _POSIX_C_SOURCE || __LP64__ */
247 #endif /* !__DARWIN_UNIX03 */
249 #if __DARWIN_UNIX03 && !defined(__LP64__)
250 #define __DARWIN_ALIAS(sym) __asm("_" __STRING(sym) "$UNIX2003")
252 #define __DARWIN_ALIAS(sym)
257 * POSIX.1 requires that the macros we test be defined before any standard
258 * header file is included. This permits us to convert values for feature
259 * testing, as necessary, using only _POSIX_C_SOURCE.
261 * Here's a quick run-down of the versions:
262 * defined(_POSIX_SOURCE) 1003.1-1988
263 * _POSIX_C_SOURCE == 1L 1003.1-1990
264 * _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option
265 * _POSIX_C_SOURCE == 199309L 1003.1b-1993
266 * _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995,
267 * and the omnibus ISO/IEC 9945-1: 1996
268 * _POSIX_C_SOURCE == 200112L 1003.1-2001
270 * In addition, the X/Open Portability Guide, which is now the Single UNIX
271 * Specification, defines a feature-test macro which indicates the version of
272 * that specification, and which subsumes _POSIX_C_SOURCE.
275 /* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. */
276 #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1L
277 #undef _POSIX_C_SOURCE
278 #define _POSIX_C_SOURCE 199009L
281 /* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. */
282 #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2L
283 #undef _POSIX_C_SOURCE
284 #define _POSIX_C_SOURCE 199209L
287 /* Deal with various X/Open Portability Guides and Single UNIX Spec. */
289 #if _XOPEN_SOURCE - 0L >= 600L
290 #undef _POSIX_C_SOURCE
291 #define _POSIX_C_SOURCE 200112L
292 #elif _XOPEN_SOURCE - 0L >= 500L
293 #undef _POSIX_C_SOURCE
294 #define _POSIX_C_SOURCE 199506L
299 * Deal with all versions of POSIX. The ordering relative to the tests above is
302 #if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
303 #define _POSIX_C_SOURCE 198808L
307 * long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and
308 * c99 still want long longs. While not perfect, we allow long longs for
311 #define __DARWIN_NO_LONG_LONG (defined(__STRICT_ANSI__) \
312 && (__STDC_VERSION__-0 < 199901L) \
313 && !defined(__GNUG__))
316 * Long double compatibility macro allow selecting variant symbols based
317 * on the old (compatible) 64-bit long doubles, or the new 128-bit
318 * long doubles. This applies only to ppc; i386 already has long double
319 * support, while ppc64 doesn't have any backwards history.
322 # if defined(__LDBL_MANT_DIG__) && defined(__DBL_MANT_DIG__) && \
323 __LDBL_MANT_DIG__ > __DBL_MANT_DIG__
324 # if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0 < 1040
325 # define __DARWIN_LDBL_COMPAT(x) __asm("_" __STRING(x) "$LDBLStub")
327 # define __DARWIN_LDBL_COMPAT(x) __asm("_" __STRING(x) "$LDBL128")
329 # define __DARWIN_LDBL_COMPAT2(x) __asm("_" __STRING(x) "$LDBL128")
330 # define __DARWIN_LONG_DOUBLE_IS_DOUBLE 0
332 # define __DARWIN_LDBL_COMPAT(x) /* nothing */
333 # define __DARWIN_LDBL_COMPAT2(x) /* nothing */
334 # define __DARWIN_LONG_DOUBLE_IS_DOUBLE 1
336 #elif defined(__i386__) || defined(__ppc64__) || defined(__x86_64__)
337 # define __DARWIN_LDBL_COMPAT(x) /* nothing */
338 # define __DARWIN_LDBL_COMPAT2(x) /* nothing */
339 # define __DARWIN_LONG_DOUBLE_IS_DOUBLE 0
341 # error Unknown architecture
344 #endif /* !_CDEFS_H_ */