]> git.saurik.com Git - apple/libc.git/blob - fbsdcompat/sys/cdefs.h
Libc-763.11.tar.gz
[apple/libc.git] / fbsdcompat / sys / cdefs.h
1 /*
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Berkeley Software Design, Inc.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
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.
23 *
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
34 * SUCH DAMAGE.
35 *
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 $
38 */
39
40 #ifndef _SYS_CDEFS_H_
41
42 /*
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.
50 */
51 #ifdef lint
52 #define __packed
53 #define __aligned(x)
54 #define __section(x)
55 #else
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)))
60 #endif
61 #endif
62
63 /* XXX: should use `#if __STDC_VERSION__ < 199901'. */
64 #if !(__GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3)
65 #define __func__ NULL
66 #endif
67
68 #if __GNUC__ >= 2 && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901
69 #define __LONG_LONG_SUPPORTED
70 #endif
71
72 /*
73 * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
74 * require it.
75 */
76 #define __offsetof(type, field) ((size_t)(&((type *)0)->field))
77
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)))
82 #else
83 #define __printf0like(fmtarg, firstvararg)
84 #endif
85
86 #ifdef __GNUC__
87 #define __strong_reference(sym,aliassym) \
88 extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)));
89 #ifdef __APPLE__
90 #define __weak_reference(sym,alias)
91 #define __warn_references(sym,msg)
92 #else // ! __APPLE__
93 #ifdef __STDC__
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 "\""); \
100 __asm__(".previous")
101 #else
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\""); \
108 __asm__(".previous")
109 #endif /* __STDC__ */
110 #endif // __APPLE__
111 #endif /* __GNUC__ */
112
113 /*
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.
116 * Usage:
117 * __FBSDID("$FreeBSD: /repoman/r/ncvs/src/sys/sys/cdefs.h,v 1.68 2002/10/21 20:50:30 mike Exp $");
118 */
119 #ifndef __FBSDID
120 #if !defined(lint) && !defined(STRIP_FBSDID)
121 #define __FBSDID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
122 #else
123 #define __FBSDID(s) struct __hack
124 #endif
125 #endif
126
127 #ifndef __RCSID
128 #ifndef NO__RCSID
129 #define __RCSID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
130 #else
131 #define __RCSID(s)
132 #endif
133 #endif
134
135 #ifndef __RCSID_SOURCE
136 #ifndef NO__RCSID_SOURCE
137 #define __RCSID_SOURCE(s) __IDSTRING(__CONCAT(__rcsid_source_,__LINE__),s)
138 #else
139 #define __RCSID_SOURCE(s)
140 #endif
141 #endif
142
143 #ifndef __SCCSID
144 #ifndef NO__SCCSID
145 #define __SCCSID(s) __IDSTRING(__CONCAT(__sccsid_,__LINE__),s)
146 #else
147 #define __SCCSID(s)
148 #endif
149 #endif
150
151 #ifndef __COPYRIGHT
152 #ifndef NO__COPYRIGHT
153 #define __COPYRIGHT(s) __IDSTRING(__CONCAT(__copyright_,__LINE__),s)
154 #else
155 #define __COPYRIGHT(s)
156 #endif
157 #endif
158
159 #ifndef __DECONST
160 #define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var))
161 #endif
162
163 #ifndef __DEVOLATILE
164 #define __DEVOLATILE(type, var) ((type)(uintptr_t)(volatile void *)(var))
165 #endif
166
167 #ifndef __DEQUALIFY
168 #define __DEQUALIFY(type, var) ((type)(uintptr_t)(const volatile void *)(var))
169 #endif
170
171 /*
172 * Now include the Apple version of sys/cdefs.h
173 */
174
175 #include_next <sys/cdefs.h>
176
177 /*
178 * Use FreeBSD version of __CONCAT
179 */
180 #if defined(__STDC__) || defined(__cplusplus)
181 #undef __CONCAT1
182 #undef __CONCAT
183 #define __CONCAT1(x,y) x ## y
184 #define __CONCAT(x,y) __CONCAT1(x,y)
185 #endif
186
187 /*
188 * Deal with all versions of POSIX. The ordering relative to the tests above is
189 * important.
190 */
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
207 #else
208 #define __POSIX_VISIBLE 198808
209 #define __ISO_C_VISIBLE 0
210 #endif /* _POSIX_C_SOURCE */
211 #else
212 /*-
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.
219 *
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).
223 */
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
239 #endif
240 #endif
241
242 #endif /* !_SYS_CDEFS_H_ */