]> git.saurik.com Git - apple/xnu.git/blame - bsd/sys/cdefs.h
xnu-1699.32.7.tar.gz
[apple/xnu.git] / bsd / sys / cdefs.h
CommitLineData
1c79356b 1/*
b0d623f7 2 * Copyright (c) 2000-2009 Apple Inc. All rights reserved.
5d5c5d0d 3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 5 *
2d21ac55
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. 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.
8f6c56a5 14 *
2d21ac55
A
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
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
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.
8f6c56a5 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b
A
27 */
28/* Copyright 1995 NeXT Computer, Inc. All rights reserved. */
29/*
30 * Copyright (c) 1991, 1993
31 * The Regents of the University of California. All rights reserved.
32 *
33 * This code is derived from software contributed to Berkeley by
34 * Berkeley Software Design, Inc.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
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.
51 *
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
62 * SUCH DAMAGE.
63 *
64 * @(#)cdefs.h 8.8 (Berkeley) 1/9/95
65 */
66
67#ifndef _CDEFS_H_
68#define _CDEFS_H_
69
70#if defined(__cplusplus)
71#define __BEGIN_DECLS extern "C" {
72#define __END_DECLS }
73#else
74#define __BEGIN_DECLS
75#define __END_DECLS
76#endif
77
78/*
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.
84 */
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
89
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 */
95#else
96#ifndef __GNUC__
97#define __inline /* delete GCC keyword */
98#endif /* !__GNUC__ */
99#endif /* !__cplusplus */
100
101#else /* !(__STDC__ || __cplusplus) */
102#define __P(protos) () /* traditional C preprocessor */
103#define __CONCAT(x,y) x/**/y
104#define __STRING(x) "x"
105
106#ifndef __GNUC__
107#define __const /* delete pseudo-ANSI C keywords */
108#define __inline
109#define __signed
110#define __volatile
111#endif /* !__GNUC__ */
112
113/*
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.
120 */
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) */
128
129/*
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).
136 */
0b4e3aa0
A
137#if defined(__MWERKS__) && (__MWERKS__ > 0x2400)
138 /* newer Metrowerks compilers support __attribute__() */
55e303ae
A
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 */
144#else
145#define __unused __attribute__((__unused__))
146#endif
147#else
1c79356b
A
148#define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */
149#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
55e303ae 150/* __dead and __pure are depreciated. Use __dead2 and __pure2 instead */
1c79356b
A
151#define __dead __volatile
152#define __pure __const
153#endif
154#endif
155
156/* Delete pseudo-keywords wherever they are not available or needed. */
157#ifndef __dead
158#define __dead
159#define __pure
160#endif
55e303ae
A
161#ifndef __dead2
162#define __dead2
163#define __pure2
164#define __unused
165#endif
1c79356b 166
6d2010ae
A
167#if defined(__GNUC__) && __GNUC__ >= 4
168#define __used __attribute__((__used__))
169#else
170#define __used
171#endif
172
91447636
A
173/*
174 * GCC 2.95 provides `__restrict' as an extension to C90 to support the
175 * C99-specific `restrict' type qualifier. We happen to use `__restrict' as
176 * a way to define the `restrict' type qualifier without disturbing older
177 * software that is unaware of C99 keywords.
178 */
179#if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95)
180#if __STDC_VERSION__ < 199901
181#define __restrict
182#else
183#define __restrict restrict
184#endif
185#endif
186
187/*
188 * Compiler-dependent macros to declare that functions take printf-like
189 * or scanf-like arguments. They are null except for versions of gcc
190 * that are known to support the features properly. Functions declared
191 * with these attributes will cause compilation warnings if there is a
192 * mismatch between the format string and subsequent function parameter
193 * types.
194 */
195#if __GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ >= 7
196#define __printflike(fmtarg, firstvararg) \
197 __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
198#define __scanflike(fmtarg, firstvararg) \
199 __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
200#else
201#define __printflike(fmtarg, firstvararg)
202#define __scanflike(fmtarg, firstvararg)
203#endif
204
6d2010ae 205#define __IDSTRING(name,string) static const char name[] __used = string
1c79356b
A
206
207#ifndef __COPYRIGHT
208#define __COPYRIGHT(s) __IDSTRING(copyright,s)
209#endif
210
211#ifndef __RCSID
212#define __RCSID(s) __IDSTRING(rcsid,s)
213#endif
214
215#ifndef __SCCSID
216#define __SCCSID(s) __IDSTRING(sccsid,s)
217#endif
218
219#ifndef __PROJECT_VERSION
220#define __PROJECT_VERSION(s) __IDSTRING(project_version,s)
221#endif
222
91447636 223/*
6d2010ae 224 * COMPILATION ENVIRONMENTS -- see compat(5) for additional detail
2d21ac55
A
225 *
226 * DEFAULT By default newly complied code will get POSIX APIs plus
227 * Apple API extensions in scope.
228 *
229 * Most users will use this compilation environment to avoid
b0d623f7 230 * behavioral differences between 32 and 64 bit code.
2d21ac55
A
231 *
232 * LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple
233 * API extensions in scope.
234 *
235 * This is generally equivalent to the Tiger release compilation
236 * environment, except that it cannot be applied to 64 bit code;
237 * its use is discouraged.
238 *
239 * We expect this environment to be deprecated in the future.
240 *
241 * STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the
242 * available APIs to exactly the set of APIs defined by the
243 * corresponding standard, based on the value defined.
91447636 244 *
2d21ac55
A
245 * A correct, portable definition for _POSIX_C_SOURCE is 200112L.
246 * A correct, portable definition for _XOPEN_SOURCE is 600L.
247 *
248 * Apple API extensions are not visible in this environment,
249 * which can cause Apple specific code to fail to compile,
250 * or behave incorrectly if prototypes are not in scope or
251 * warnings about missing prototypes are not enabled or ignored.
252 *
253 * In any compilation environment, for correct symbol resolution to occur,
254 * function prototypes must be in scope. It is recommended that all Apple
b0d623f7 255 * tools users add either the "-Wall" or "-Wimplicit-function-declaration"
2d21ac55
A
256 * compiler flags to their projects to be warned when a function is being
257 * used without a prototype in scope.
258 */
259
593a1d5f
A
260/* These settings are particular to each product. */
261#ifdef KERNEL
262#define __DARWIN_ONLY_64_BIT_INO_T 0
263#define __DARWIN_ONLY_UNIX_CONFORMANCE 0
264#define __DARWIN_ONLY_VERS_1050 0
b0d623f7
A
265#define __DARWIN_SUF_DARWIN10 "_darwin10"
266#define __DARWIN10_ALIAS(sym) __asm("_" __STRING(sym) __DARWIN_SUF_DARWIN10)
593a1d5f 267#else /* !KERNEL */
6d2010ae
A
268#ifdef PLATFORM_iPhoneOS
269/* Platform: iPhoneOS */
593a1d5f
A
270#define __DARWIN_ONLY_64_BIT_INO_T 1
271#define __DARWIN_ONLY_UNIX_CONFORMANCE 1
272#define __DARWIN_ONLY_VERS_1050 1
6d2010ae
A
273#endif /* PLATFORM_iPhoneOS */
274#ifdef PLATFORM_iPhoneSimulator
275/* Platform: iPhoneSimulator */
593a1d5f
A
276#define __DARWIN_ONLY_64_BIT_INO_T 1
277#define __DARWIN_ONLY_UNIX_CONFORMANCE 1
278#define __DARWIN_ONLY_VERS_1050 1
6d2010ae
A
279#endif /* PLATFORM_iPhoneSimulator */
280#ifdef PLATFORM_MacOSX
281/* Platform: MacOSX */
593a1d5f
A
282#define __DARWIN_ONLY_64_BIT_INO_T 0
283/* #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) */
284#define __DARWIN_ONLY_VERS_1050 0
6d2010ae 285#endif /* PLATFORM_MacOSX */
593a1d5f
A
286#endif /* KERNEL */
287
2d21ac55
A
288/*
289 * The __DARWIN_ALIAS macros are used to do symbol renaming; they allow
b0d623f7 290 * legacy code to use the old symbol, thus maintaining binary compatibility
2d21ac55 291 * while new code can use a standards compliant version of the same function.
91447636
A
292 *
293 * __DARWIN_ALIAS is used by itself if the function signature has not
294 * changed, it is used along with a #ifdef check for __DARWIN_UNIX03
b0d623f7
A
295 * if the signature has changed. Because the __LP64__ environment
296 * only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be
91447636 297 * defined, but causes __DARWIN_ALIAS to do no symbol mangling.
2d21ac55
A
298 *
299 * As a special case, when XCode is used to target a specific version of the
300 * OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
301 * will be defined by the compiler, with the digits representing major version
b0d623f7 302 * time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting
2d21ac55
A
303 * pre-10.5, and it is the default compilation environment, revert the
304 * compilation environment to pre-__DARWIN_UNIX03.
91447636 305 */
593a1d5f
A
306#if !defined(__DARWIN_ONLY_UNIX_CONFORMANCE)
307# if defined(__LP64__)
308# define __DARWIN_ONLY_UNIX_CONFORMANCE 1
309# else /* !__LP64__ */
310# define __DARWIN_ONLY_UNIX_CONFORMANCE 0
311# endif /* __LP64__ */
312#endif /* !__DARWIN_ONLY_UNIX_CONFORMANCE */
313
91447636 314#if !defined(__DARWIN_UNIX03)
593a1d5f
A
315# if defined(KERNEL)
316# define __DARWIN_UNIX03 0
317# elif __DARWIN_ONLY_UNIX_CONFORMANCE
2d21ac55 318# if defined(_NONSTD_SOURCE)
593a1d5f 319# error "Can't define _NONSTD_SOURCE when only UNIX conformance is available."
2d21ac55
A
320# endif /* _NONSTD_SOURCE */
321# define __DARWIN_UNIX03 1
6d2010ae
A
322# elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) < 1040)
323# define __DARWIN_UNIX03 0
593a1d5f
A
324# elif defined(_DARWIN_C_SOURCE) || defined(_XOPEN_SOURCE) || defined(_POSIX_C_SOURCE)
325# if defined(_NONSTD_SOURCE)
326# error "Can't define both _NONSTD_SOURCE and any of _DARWIN_C_SOURCE, _XOPEN_SOURCE or _POSIX_C_SOURCE."
327# endif /* _NONSTD_SOURCE */
328# define __DARWIN_UNIX03 1
329# elif defined(_NONSTD_SOURCE)
2d21ac55
A
330# define __DARWIN_UNIX03 0
331# else /* default */
332# if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) < 1050)
333# define __DARWIN_UNIX03 0
334# else /* __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050 */
335# define __DARWIN_UNIX03 1
336# endif /* __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050 */
337# endif /* _DARWIN_C_SOURCE || _XOPEN_SOURCE || _POSIX_C_SOURCE || __LP64__ */
91447636
A
338#endif /* !__DARWIN_UNIX03 */
339
2d21ac55 340#if !defined(__DARWIN_64_BIT_INO_T)
593a1d5f
A
341# if defined(KERNEL)
342# define __DARWIN_64_BIT_INO_T 0
343# elif defined(_DARWIN_USE_64_BIT_INODE)
344# if defined(_DARWIN_NO_64_BIT_INODE)
345# error "Can't define both _DARWIN_USE_64_BIT_INODE and _DARWIN_NO_64_BIT_INODE."
346# endif /* _DARWIN_NO_64_BIT_INODE */
2d21ac55 347# define __DARWIN_64_BIT_INO_T 1
593a1d5f
A
348# elif defined(_DARWIN_NO_64_BIT_INODE)
349# if __DARWIN_ONLY_64_BIT_INO_T
350# error "Can't define _DARWIN_NO_64_BIT_INODE when only 64-bit inodes are available."
351# endif /* __DARWIN_ONLY_64_BIT_INO_T */
2d21ac55
A
352# define __DARWIN_64_BIT_INO_T 0
353# else /* default */
593a1d5f
A
354# if __DARWIN_ONLY_64_BIT_INO_T
355# define __DARWIN_64_BIT_INO_T 1
b0d623f7 356# elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) < 1060) || __DARWIN_UNIX03 == 0
593a1d5f 357# define __DARWIN_64_BIT_INO_T 0
b0d623f7
A
358# else /* default */
359# define __DARWIN_64_BIT_INO_T 1
593a1d5f 360# endif /* __DARWIN_ONLY_64_BIT_INO_T */
2d21ac55
A
361# endif
362#endif /* !__DARWIN_64_BIT_INO_T */
363
593a1d5f 364#if !defined(__DARWIN_VERS_1050)
2d21ac55 365# if defined(KERNEL)
593a1d5f
A
366# define __DARWIN_VERS_1050 0
367# elif __DARWIN_ONLY_VERS_1050
368# define __DARWIN_VERS_1050 1
b0d623f7 369# elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) < 1050) || __DARWIN_UNIX03 == 0
593a1d5f 370# define __DARWIN_VERS_1050 0
b0d623f7
A
371# else /* default */
372# define __DARWIN_VERS_1050 1
2d21ac55 373# endif
593a1d5f 374#endif /* !__DARWIN_VERS_1050 */
2d21ac55 375
593a1d5f
A
376#if !defined(__DARWIN_NON_CANCELABLE)
377# if defined(KERNEL)
378# define __DARWIN_NON_CANCELABLE 0
2d21ac55 379# else /* default */
593a1d5f 380# define __DARWIN_NON_CANCELABLE 0
2d21ac55
A
381# endif
382#endif /* !__DARWIN_NON_CANCELABLE */
383
384/*
385 * symbol suffixes used for symbol versioning
386 */
387#if __DARWIN_UNIX03
593a1d5f 388# if __DARWIN_ONLY_UNIX_CONFORMANCE
2d21ac55 389# define __DARWIN_SUF_UNIX03 /* nothing */
593a1d5f
A
390# else /* !__DARWIN_ONLY_UNIX_CONFORMANCE */
391# define __DARWIN_SUF_UNIX03 "$UNIX2003"
392# endif /* __DARWIN_ONLY_UNIX_CONFORMANCE */
2d21ac55
A
393
394# if __DARWIN_64_BIT_INO_T
593a1d5f
A
395# if __DARWIN_ONLY_64_BIT_INO_T
396# define __DARWIN_SUF_64_BIT_INO_T /* nothing */
397# else /* !__DARWIN_ONLY_64_BIT_INO_T */
398# define __DARWIN_SUF_64_BIT_INO_T "$INODE64"
399# endif /* __DARWIN_ONLY_64_BIT_INO_T */
2d21ac55
A
400# else /* !__DARWIN_64_BIT_INO_T */
401# define __DARWIN_SUF_64_BIT_INO_T /* nothing */
593a1d5f
A
402# endif /* __DARWIN_64_BIT_INO_T */
403
404# if __DARWIN_VERS_1050
405# if __DARWIN_ONLY_VERS_1050
406# define __DARWIN_SUF_1050 /* nothing */
407# else /* !__DARWIN_ONLY_VERS_1050 */
408# define __DARWIN_SUF_1050 "$1050"
409# endif /* __DARWIN_ONLY_VERS_1050 */
410# else /* !__DARWIN_VERS_1050 */
411# define __DARWIN_SUF_1050 /* nothing */
412# endif /* __DARWIN_VERS_1050 */
2d21ac55
A
413
414# if __DARWIN_NON_CANCELABLE
415# define __DARWIN_SUF_NON_CANCELABLE "$NOCANCEL"
416# else /* !__DARWIN_NON_CANCELABLE */
417# define __DARWIN_SUF_NON_CANCELABLE /* nothing */
418# endif /* __DARWIN_NON_CANCELABLE */
419
2d21ac55
A
420#else /* !__DARWIN_UNIX03 */
421# define __DARWIN_SUF_UNIX03 /* nothing */
2d21ac55
A
422# define __DARWIN_SUF_64_BIT_INO_T /* nothing */
423# define __DARWIN_SUF_NON_CANCELABLE /* nothing */
424# define __DARWIN_SUF_1050 /* nothing */
425#endif /* __DARWIN_UNIX03 */
426
427#define __DARWIN_SUF_EXTSN "$DARWIN_EXTSN"
428
429/*
430 * symbol versioning macros
431 */
432#define __DARWIN_ALIAS(sym) __asm("_" __STRING(sym) __DARWIN_SUF_UNIX03)
433#define __DARWIN_ALIAS_C(sym) __asm("_" __STRING(sym) __DARWIN_SUF_NON_CANCELABLE __DARWIN_SUF_UNIX03)
434#define __DARWIN_ALIAS_I(sym) __asm("_" __STRING(sym) __DARWIN_SUF_64_BIT_INO_T __DARWIN_SUF_UNIX03)
435#define __DARWIN_INODE64(sym) __asm("_" __STRING(sym) __DARWIN_SUF_64_BIT_INO_T)
436
437#define __DARWIN_1050(sym) __asm("_" __STRING(sym) __DARWIN_SUF_1050)
438#define __DARWIN_1050ALIAS(sym) __asm("_" __STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_UNIX03)
439#define __DARWIN_1050ALIAS_C(sym) __asm("_" __STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_NON_CANCELABLE __DARWIN_SUF_UNIX03)
440#define __DARWIN_1050ALIAS_I(sym) __asm("_" __STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_64_BIT_INO_T __DARWIN_SUF_UNIX03)
441#define __DARWIN_1050INODE64(sym) __asm("_" __STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_64_BIT_INO_T)
442
443#define __DARWIN_EXTSN(sym) __asm("_" __STRING(sym) __DARWIN_SUF_EXTSN)
444#define __DARWIN_EXTSN_C(sym) __asm("_" __STRING(sym) __DARWIN_SUF_EXTSN __DARWIN_SUF_NON_CANCELABLE)
91447636 445
b0d623f7
A
446/*
447 * symbol release macros
448 */
6d2010ae
A
449#ifdef KERNEL
450#define __DARWIN_ALIAS_STARTING(_mac, _iphone, x)
451#else
452#include <sys/_symbol_aliasing.h>
453
454#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
455#define __DARWIN_ALIAS_STARTING(_mac, _iphone, x) __DARWIN_ALIAS_STARTING_IPHONE_##_iphone(x)
456#elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
457#define __DARWIN_ALIAS_STARTING(_mac, _iphone, x) __DARWIN_ALIAS_STARTING_MAC_##_mac(x)
458#else
459#define __DARWIN_ALIAS_STARTING(_mac, _iphone, x)
b0d623f7 460#endif
6d2010ae 461#endif /* KERNEL */
b0d623f7 462
91447636
A
463
464/*
465 * POSIX.1 requires that the macros we test be defined before any standard
466 * header file is included. This permits us to convert values for feature
467 * testing, as necessary, using only _POSIX_C_SOURCE.
468 *
469 * Here's a quick run-down of the versions:
470 * defined(_POSIX_SOURCE) 1003.1-1988
471 * _POSIX_C_SOURCE == 1L 1003.1-1990
472 * _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option
473 * _POSIX_C_SOURCE == 199309L 1003.1b-1993
474 * _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995,
475 * and the omnibus ISO/IEC 9945-1: 1996
476 * _POSIX_C_SOURCE == 200112L 1003.1-2001
6d2010ae 477 * _POSIX_C_SOURCE == 200809L 1003.1-2008
91447636
A
478 *
479 * In addition, the X/Open Portability Guide, which is now the Single UNIX
480 * Specification, defines a feature-test macro which indicates the version of
481 * that specification, and which subsumes _POSIX_C_SOURCE.
482 */
483
484/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. */
485#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1L
486#undef _POSIX_C_SOURCE
487#define _POSIX_C_SOURCE 199009L
488#endif
489
490/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. */
491#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2L
492#undef _POSIX_C_SOURCE
493#define _POSIX_C_SOURCE 199209L
494#endif
495
496/* Deal with various X/Open Portability Guides and Single UNIX Spec. */
497#ifdef _XOPEN_SOURCE
6d2010ae
A
498#if _XOPEN_SOURCE - 0L >= 700L && (!defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE - 0L < 200809L)
499#undef _POSIX_C_SOURCE
500#define _POSIX_C_SOURCE 200809L
501#elif _XOPEN_SOURCE - 0L >= 600L && (!defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE - 0L < 200112L)
91447636
A
502#undef _POSIX_C_SOURCE
503#define _POSIX_C_SOURCE 200112L
6d2010ae 504#elif _XOPEN_SOURCE - 0L >= 500L && (!defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE - 0L < 199506L)
91447636
A
505#undef _POSIX_C_SOURCE
506#define _POSIX_C_SOURCE 199506L
507#endif
508#endif
509
510/*
511 * Deal with all versions of POSIX. The ordering relative to the tests above is
512 * important.
513 */
514#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
515#define _POSIX_C_SOURCE 198808L
516#endif
517
6d2010ae
A
518/*
519 * Deprecation macro
520 */
521#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
522#define __deprecated __attribute__((deprecated))
523#define __unavailable __attribute__((unavailable))
524#else
525#define __deprecated /* nothing */
526#define __unavailable /* nothing */
527#endif
528
529/* POSIX C deprecation macros */
530#ifdef KERNEL
531#define __POSIX_C_DEPRECATED(ver)
532#else
533#include <sys/_posix_availability.h>
534
535#define __POSIX_C_DEPRECATED(ver) ___POSIX_C_DEPRECATED_STARTING_##ver
536#endif
537
538/*
539 * Set a single macro which will always be defined and can be used to determine
540 * the appropriate namespace. For POSIX, these values will correspond to
541 * _POSIX_C_SOURCE value. Currently there are two additional levels corresponding
542 * to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE)
543 */
544#define __DARWIN_C_ANSI 010000L
545#define __DARWIN_C_FULL 900000L
546
547#if defined(_ANSI_SOURCE)
548#define __DARWIN_C_LEVEL __DARWIN_C_ANSI
549#elif defined(_POSIX_C_SOURCE) && !defined(_DARWIN_C_SOURCE) && !defined(_NONSTD_SOURCE)
550#define __DARWIN_C_LEVEL _POSIX_C_SOURCE
551#else
552#define __DARWIN_C_LEVEL __DARWIN_C_FULL
553#endif
554
555
91447636
A
556/*
557 * long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and
558 * c99 still want long longs. While not perfect, we allow long longs for
559 * g++.
560 */
561#define __DARWIN_NO_LONG_LONG (defined(__STRICT_ANSI__) \
562 && (__STDC_VERSION__-0 < 199901L) \
563 && !defined(__GNUG__))
564
565/*
566 * Long double compatibility macro allow selecting variant symbols based
567 * on the old (compatible) 64-bit long doubles, or the new 128-bit
568 * long doubles. This applies only to ppc; i386 already has long double
569 * support, while ppc64 doesn't have any backwards history.
570 */
6d2010ae 571#if defined(__i386__) || defined(__x86_64__)
91447636
A
572# define __DARWIN_LDBL_COMPAT(x) /* nothing */
573# define __DARWIN_LDBL_COMPAT2(x) /* nothing */
574# define __DARWIN_LONG_DOUBLE_IS_DOUBLE 0
575#else
576# error Unknown architecture
577#endif
578
2d21ac55
A
579/*****************************************
580 * Public darwin-specific feature macros
581 *****************************************/
582
593a1d5f
A
583/*
584 * _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and
585 * structures modified for 64-bit inodes (like struct stat) will be used.
586 */
587#if __DARWIN_64_BIT_INO_T
588#define _DARWIN_FEATURE_64_BIT_INODE 1
589#endif
590
2d21ac55
A
591/*
592 * _DARWIN_FEATURE_LONG_DOUBLE_IS_DOUBLE indicates when the long double type
593a1d5f 593 * is the same as the double type (ppc and arm only)
2d21ac55
A
594 */
595#if __DARWIN_LONG_DOUBLE_IS_DOUBLE
596#define _DARWIN_FEATURE_LONG_DOUBLE_IS_DOUBLE 1
597#endif
598
599/*
593a1d5f
A
600 * _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only
601 * be 64-bit; there is no support for 32-bit ino_t when this macro is defined
602 * (and non-zero). There is no struct stat64 either, as the regular
603 * struct stat will already be the 64-bit version.
2d21ac55 604 */
593a1d5f
A
605#if __DARWIN_ONLY_64_BIT_INO_T
606#define _DARWIN_FEATURE_ONLY_64_BIT_INODE 1
2d21ac55
A
607#endif
608
609/*
593a1d5f
A
610 * _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated
611 * in 10.5 exists; no pre-10.5 variants are available.
2d21ac55 612 */
593a1d5f
A
613#if __DARWIN_ONLY_VERS_1050
614#define _DARWIN_FEATURE_ONLY_VERS_1050 1
615#endif
616
617/*
618 * _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API
619 * are available (the legacy BSD APIs are not available)
620 */
621#if __DARWIN_ONLY_UNIX_CONFORMANCE
622#define _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE 1
623#endif
624
625/*
626 * _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on,
627 * and specifies the conformance level (3 is SUSv3)
628 */
629#if __DARWIN_UNIX03
630#define _DARWIN_FEATURE_UNIX_CONFORMANCE 3
2d21ac55
A
631#endif
632
b0d623f7
A
633/*
634 * This macro casts away the qualifier from the variable
635 *
636 * Note: use at your own risk, removing qualifiers can result in
637 * catastrophic run-time failures.
638 */
639#ifndef __CAST_AWAY_QUALIFIER
6d2010ae 640#define __CAST_AWAY_QUALIFIER(variable, qualifier, type) (type) (long)(variable)
b0d623f7
A
641#endif
642
1c79356b 643#endif /* !_CDEFS_H_ */