]>
git.saurik.com Git - apple/libc.git/blob - fbsdcompat/sys/cdefs.h
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
5 * This code is derived from software contributed to Berkeley by
6 * Berkeley Software Design, Inc.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * @(#)cdefs.h 8.8 (Berkeley) 1/9/95
37 * $FreeBSD: /repoman/r/ncvs/src/sys/sys/cdefs.h,v 1.68 2002/10/21 20:50:30 mike Exp $
43 * Compiler-dependent macros to help declare dead (non-returning) and
44 * pure (no side effects) functions, and unused variables. They are
45 * null except for versions of gcc that are known to support the features
46 * properly (old versions of gcc-2 supported the dead and pure features
47 * in a different (wrong) way). If we do not provide an implementation
48 * for a given compiler, let the compile fail if it is told to use
49 * a feature that we cannot live without.
56 #if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3
57 #define __packed __attribute__((__packed__))
58 #define __aligned(x) __attribute__((__aligned__(x)))
59 #define __section(x) __attribute__((__section__(x)))
63 /* XXX: should use `#if __STDC_VERSION__ < 199901'. */
64 #if !(__GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3)
68 #if __GNUC__ >= 2 && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901
69 #define __LONG_LONG_SUPPORTED
73 * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
76 #define __offsetof(type, field) ((size_t)(&((type *)0)->field))
78 /* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
79 #if __FreeBSD_cc_version >= 300001 && __FreeBSD_cc_version < 500003
80 #define __printf0like(fmtarg, firstvararg) \
81 __attribute__((__format__ (__printf0__, fmtarg, firstvararg)))
83 #define __printf0like(fmtarg, firstvararg)
87 #define __strong_reference(sym,aliassym) \
88 extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)));
90 #define __weak_reference(sym,alias)
91 #define __warn_references(sym,msg)
94 #define __weak_reference(sym,alias) \
95 __asm__(".weak " #alias); \
96 __asm__(".equ " #alias ", " #sym)
97 #define __warn_references(sym,msg) \
98 __asm__(".section .gnu.warning." #sym); \
99 __asm__(".asciz \"" msg "\""); \
102 #define __weak_reference(sym,alias) \
103 __asm__(".weak alias"); \
104 __asm__(".equ alias, sym")
105 #define __warn_references(sym,msg) \
106 __asm__(".section .gnu.warning.sym"); \
107 __asm__(".asciz \"msg\""); \
109 #endif /* __STDC__ */
111 #endif /* __GNUC__ */
114 * Embed the rcs id of a source file in the resulting library. Note that in
115 * more recent ELF binutils, we use .ident allowing the ID to be stripped.
117 * __FBSDID("$FreeBSD: /repoman/r/ncvs/src/sys/sys/cdefs.h,v 1.68 2002/10/21 20:50:30 mike Exp $");
120 #if !defined(lint) && !defined(STRIP_FBSDID)
121 #define __FBSDID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
123 #define __FBSDID(s) struct __hack
129 #define __RCSID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
135 #ifndef __RCSID_SOURCE
136 #ifndef NO__RCSID_SOURCE
137 #define __RCSID_SOURCE(s) __IDSTRING(__CONCAT(__rcsid_source_,__LINE__),s)
139 #define __RCSID_SOURCE(s)
145 #define __SCCSID(s) __IDSTRING(__CONCAT(__sccsid_,__LINE__),s)
152 #ifndef NO__COPYRIGHT
153 #define __COPYRIGHT(s) __IDSTRING(__CONCAT(__copyright_,__LINE__),s)
155 #define __COPYRIGHT(s)
160 #define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var))
164 #define __DEVOLATILE(type, var) ((type)(uintptr_t)(volatile void *)(var))
168 #define __DEQUALIFY(type, var) ((type)(uintptr_t)(const volatile void *)(var))
172 * Now include the Apple version of sys/cdefs.h
175 #include_next <sys/cdefs.h>
178 * Use FreeBSD version of __CONCAT
180 #if defined(__STDC__) || defined(__cplusplus)
183 #define __CONCAT1(x,y) x ## y
184 #define __CONCAT(x,y) __CONCAT1(x,y)
188 * Deal with all versions of POSIX. The ordering relative to the tests above is
191 #ifdef _POSIX_C_SOURCE
192 #if _POSIX_C_SOURCE >= 200112
193 #define __POSIX_VISIBLE 200112
194 #define __ISO_C_VISIBLE 1999
195 #elif _POSIX_C_SOURCE >= 199506
196 #define __POSIX_VISIBLE 199506
197 #define __ISO_C_VISIBLE 1990
198 #elif _POSIX_C_SOURCE >= 199309
199 #define __POSIX_VISIBLE 199309
200 #define __ISO_C_VISIBLE 1990
201 #elif _POSIX_C_SOURCE >= 199209
202 #define __POSIX_VISIBLE 199209
203 #define __ISO_C_VISIBLE 1990
204 #elif _POSIX_C_SOURCE >= 199009
205 #define __POSIX_VISIBLE 199009
206 #define __ISO_C_VISIBLE 1990
208 #define __POSIX_VISIBLE 198808
209 #define __ISO_C_VISIBLE 0
210 #endif /* _POSIX_C_SOURCE */
213 * Deal with _ANSI_SOURCE:
214 * If it is defined, and no other compilation environment is explicitly
215 * requested, then define our internal feature-test macros to zero. This
216 * makes no difference to the preprocessor (undefined symbols in preprocessing
217 * expressions are defined to have value zero), but makes it more convenient for
218 * a test program to print out the values.
220 * If a program mistakenly defines _ANSI_SOURCE and some other macro such as
221 * _POSIX_C_SOURCE, we will assume that it wants the broader compilation
222 * environment (and in fact we will never get here).
224 #if defined(_ANSI_SOURCE) /* Hide almost everything. */
225 #define __POSIX_VISIBLE 0
226 #define __XSI_VISIBLE 0
227 #define __BSD_VISIBLE 0
228 #define __ISO_C_VISIBLE 1990
229 #elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */
230 #define __POSIX_VISIBLE 0
231 #define __XSI_VISIBLE 0
232 #define __BSD_VISIBLE 0
233 #define __ISO_C_VISIBLE 1999
234 #else /* Default environment: show everything. */
235 #define __POSIX_VISIBLE 200112
236 #define __XSI_VISIBLE 600
237 #define __BSD_VISIBLE 1
238 #define __ISO_C_VISIBLE 1999
242 #endif /* !_SYS_CDEFS_H_ */