Rev 4874 | Rev 6099 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4349 | Serge | 1 | /* libc/sys/linux/sys/cdefs.h - Helper macros for K&R vs. ANSI C compat. */ |
2 | |||
3 | /* Written 2000 by Werner Almesberger */ |
||
4 | |||
4921 | Serge | 5 | /*- |
4349 | Serge | 6 | * Copyright (c) 1991, 1993 |
7 | * The Regents of the University of California. All rights reserved. |
||
8 | * |
||
9 | * This code is derived from software contributed to Berkeley by |
||
10 | * Berkeley Software Design, Inc. |
||
11 | * |
||
12 | * Redistribution and use in source and binary forms, with or without |
||
13 | * modification, are permitted provided that the following conditions |
||
14 | * are met: |
||
15 | * 1. Redistributions of source code must retain the above copyright |
||
16 | * notice, this list of conditions and the following disclaimer. |
||
17 | * 2. Redistributions in binary form must reproduce the above copyright |
||
18 | * notice, this list of conditions and the following disclaimer in the |
||
19 | * documentation and/or other materials provided with the distribution. |
||
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 |
||
4921 | Serge | 37 | * $FreeBSD$ |
4349 | Serge | 38 | */ |
39 | |||
4921 | Serge | 40 | #ifndef _SYS_CDEFS_H_ |
41 | #define _SYS_CDEFS_H_ |
||
4349 | Serge | 42 | |
4921 | Serge | 43 | #include |
44 | #include |
||
45 | #include |
||
4349 | Serge | 46 | |
47 | #define __PMT(args) args |
||
48 | #define __DOTS , ... |
||
49 | #define __THROW |
||
50 | |||
4921 | Serge | 51 | #ifdef __GNUC__ |
52 | # define __ASMNAME(cname) __XSTRING (__USER_LABEL_PREFIX__) cname |
||
53 | #endif |
||
54 | |||
55 | #define __ptr_t void * |
||
56 | #define __long_double_t long double |
||
57 | |||
58 | #define __attribute_malloc__ |
||
59 | #define __attribute_pure__ |
||
60 | #define __attribute_format_strfmon__(a,b) |
||
61 | #define __flexarr [0] |
||
62 | |||
63 | #ifndef __BOUNDED_POINTERS__ |
||
64 | # define __bounded /* nothing */ |
||
65 | # define __unbounded /* nothing */ |
||
66 | # define __ptrvalue /* nothing */ |
||
67 | #endif |
||
68 | |||
4349 | Serge | 69 | /* |
4921 | Serge | 70 | * Testing against Clang-specific extensions. |
71 | */ |
||
72 | |||
73 | #ifndef __has_extension |
||
74 | #define __has_extension __has_feature |
||
75 | #endif |
||
76 | #ifndef __has_feature |
||
77 | #define __has_feature(x) 0 |
||
78 | #endif |
||
79 | #ifndef __has_include |
||
80 | #define __has_include(x) 0 |
||
81 | #endif |
||
82 | #ifndef __has_builtin |
||
83 | #define __has_builtin(x) 0 |
||
84 | #endif |
||
85 | |||
86 | #if defined(__cplusplus) |
||
87 | #define __BEGIN_DECLS extern "C" { |
||
88 | #define __END_DECLS } |
||
89 | #else |
||
90 | #define __BEGIN_DECLS |
||
91 | #define __END_DECLS |
||
92 | #endif |
||
93 | |||
94 | /* |
||
95 | * This code has been put in place to help reduce the addition of |
||
96 | * compiler specific defines in FreeBSD code. It helps to aid in |
||
97 | * having a compiler-agnostic source tree. |
||
98 | */ |
||
99 | |||
100 | #if defined(__GNUC__) || defined(__INTEL_COMPILER) |
||
101 | |||
102 | #if __GNUC__ >= 3 || defined(__INTEL_COMPILER) |
||
103 | #define __GNUCLIKE_ASM 3 |
||
104 | #define __GNUCLIKE_MATH_BUILTIN_CONSTANTS |
||
105 | #else |
||
106 | #define __GNUCLIKE_ASM 2 |
||
107 | #endif |
||
108 | #define __GNUCLIKE___TYPEOF 1 |
||
109 | #define __GNUCLIKE___OFFSETOF 1 |
||
110 | #define __GNUCLIKE___SECTION 1 |
||
111 | |||
112 | #ifndef __INTEL_COMPILER |
||
113 | # define __GNUCLIKE_CTOR_SECTION_HANDLING 1 |
||
114 | #endif |
||
115 | |||
116 | #define __GNUCLIKE_BUILTIN_CONSTANT_P 1 |
||
117 | # if defined(__INTEL_COMPILER) && defined(__cplusplus) \ |
||
118 | && __INTEL_COMPILER < 800 |
||
119 | # undef __GNUCLIKE_BUILTIN_CONSTANT_P |
||
120 | # endif |
||
121 | |||
122 | #if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3) && !defined(__INTEL_COMPILER) |
||
123 | # define __GNUCLIKE_BUILTIN_VARARGS 1 |
||
124 | # define __GNUCLIKE_BUILTIN_STDARG 1 |
||
125 | # define __GNUCLIKE_BUILTIN_VAALIST 1 |
||
126 | #endif |
||
127 | |||
128 | #if defined(__GNUC__) |
||
129 | # define __GNUC_VA_LIST_COMPATIBILITY 1 |
||
130 | #endif |
||
131 | |||
132 | /* |
||
133 | * Compiler memory barriers, specific to gcc and clang. |
||
134 | */ |
||
135 | #if defined(__GNUC__) |
||
136 | #define __compiler_membar() __asm __volatile(" " : : : "memory") |
||
137 | #endif |
||
138 | |||
139 | #ifndef __INTEL_COMPILER |
||
140 | # define __GNUCLIKE_BUILTIN_NEXT_ARG 1 |
||
141 | # define __GNUCLIKE_MATH_BUILTIN_RELOPS |
||
142 | #endif |
||
143 | |||
144 | #define __GNUCLIKE_BUILTIN_MEMCPY 1 |
||
145 | |||
146 | /* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */ |
||
147 | #define __CC_SUPPORTS_INLINE 1 |
||
148 | #define __CC_SUPPORTS___INLINE 1 |
||
149 | #define __CC_SUPPORTS___INLINE__ 1 |
||
150 | |||
151 | #define __CC_SUPPORTS___FUNC__ 1 |
||
152 | #define __CC_SUPPORTS_WARNING 1 |
||
153 | |||
154 | #define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */ |
||
155 | |||
156 | #define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1 |
||
157 | |||
158 | #endif /* __GNUC__ || __INTEL_COMPILER */ |
||
159 | |||
160 | /* |
||
4349 | Serge | 161 | * The __CONCAT macro is used to concatenate parts of symbol names, e.g. |
162 | * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. |
||
163 | * The __CONCAT macro is a bit tricky to use if it must work in non-ANSI |
||
164 | * mode -- there must be no spaces between its arguments, and for nested |
||
165 | * __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also |
||
166 | * concatenate double-quoted strings produced by the __STRING macro, but |
||
167 | * this only works with ANSI C. |
||
168 | * |
||
169 | * __XSTRING is like __STRING, but it expands any macros in its argument |
||
170 | * first. It is only available with ANSI C. |
||
171 | */ |
||
4921 | Serge | 172 | #if defined(__STDC__) || defined(__cplusplus) |
173 | #define __P(protos) protos /* full-blown ANSI C */ |
||
4349 | Serge | 174 | #define __CONCAT1(x,y) x ## y |
175 | #define __CONCAT(x,y) __CONCAT1(x,y) |
||
176 | #define __STRING(x) #x /* stringify without expanding x */ |
||
177 | #define __XSTRING(x) __STRING(x) /* expand x, then stringify */ |
||
178 | |||
4921 | Serge | 179 | #define __const const /* define reserved names to standard */ |
180 | #define __signed signed |
||
181 | #define __volatile volatile |
||
182 | #if defined(__cplusplus) |
||
183 | #define __inline inline /* convert to C++ keyword */ |
||
184 | #else |
||
185 | #if !(defined(__CC_SUPPORTS___INLINE)) |
||
186 | #define __inline /* delete GCC keyword */ |
||
187 | #endif /* ! __CC_SUPPORTS___INLINE */ |
||
188 | #endif /* !__cplusplus */ |
||
189 | |||
190 | #else /* !(__STDC__ || __cplusplus) */ |
||
191 | #define __P(protos) () /* traditional C preprocessor */ |
||
192 | #define __CONCAT(x,y) x/**/y |
||
193 | #define __STRING(x) "x" |
||
194 | |||
195 | #if !defined(__CC_SUPPORTS___INLINE) |
||
196 | #define __const /* delete pseudo-ANSI C keywords */ |
||
197 | #define __inline |
||
198 | #define __signed |
||
199 | #define __volatile |
||
200 | /* |
||
201 | * In non-ANSI C environments, new programs will want ANSI-only C keywords |
||
202 | * deleted from the program and old programs will want them left alone. |
||
203 | * When using a compiler other than gcc, programs using the ANSI C keywords |
||
204 | * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS. |
||
205 | * When using "gcc -traditional", we assume that this is the intent; if |
||
206 | * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone. |
||
207 | */ |
||
208 | #ifndef NO_ANSI_KEYWORDS |
||
209 | #define const /* delete ANSI C keywords */ |
||
210 | #define inline |
||
211 | #define signed |
||
212 | #define volatile |
||
213 | #endif /* !NO_ANSI_KEYWORDS */ |
||
214 | #endif /* !__CC_SUPPORTS___INLINE */ |
||
215 | #endif /* !(__STDC__ || __cplusplus) */ |
||
216 | |||
217 | /* |
||
218 | * Compiler-dependent macros to help declare dead (non-returning) and |
||
219 | * pure (no side effects) functions, and unused variables. They are |
||
220 | * null except for versions of gcc that are known to support the features |
||
221 | * properly (old versions of gcc-2 supported the dead and pure features |
||
222 | * in a different (wrong) way). If we do not provide an implementation |
||
223 | * for a given compiler, let the compile fail if it is told to use |
||
224 | * a feature that we cannot live without. |
||
225 | */ |
||
226 | #ifdef lint |
||
227 | #define __dead2 |
||
228 | #define __pure2 |
||
229 | #define __unused |
||
230 | #define __packed |
||
231 | #define __aligned(x) |
||
232 | #define __section(x) |
||
233 | #else |
||
234 | #if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER) |
||
235 | #define __dead2 |
||
236 | #define __pure2 |
||
237 | #define __unused |
||
4349 | Serge | 238 | #endif |
4921 | Serge | 239 | #if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7 && !defined(__INTEL_COMPILER) |
240 | #define __dead2 __attribute__((__noreturn__)) |
||
241 | #define __pure2 __attribute__((__const__)) |
||
242 | #define __unused |
||
243 | /* XXX Find out what to do for __packed, __aligned and __section */ |
||
244 | #endif |
||
245 | #if __GNUC_PREREQ__(2, 7) |
||
246 | #define __dead2 __attribute__((__noreturn__)) |
||
247 | #define __pure2 __attribute__((__const__)) |
||
248 | #define __unused __attribute__((__unused__)) |
||
249 | #define __used __attribute__((__used__)) |
||
250 | #define __packed __attribute__((__packed__)) |
||
251 | #define __aligned(x) __attribute__((__aligned__(x))) |
||
252 | #define __section(x) __attribute__((__section__(x))) |
||
253 | #endif |
||
254 | #if defined(__INTEL_COMPILER) |
||
255 | #define __dead2 __attribute__((__noreturn__)) |
||
256 | #define __pure2 __attribute__((__const__)) |
||
257 | #define __unused __attribute__((__unused__)) |
||
258 | #define __used __attribute__((__used__)) |
||
259 | #define __packed __attribute__((__packed__)) |
||
260 | #define __aligned(x) __attribute__((__aligned__(x))) |
||
261 | #define __section(x) __attribute__((__section__(x))) |
||
262 | #endif |
||
263 | #endif |
||
4349 | Serge | 264 | |
4921 | Serge | 265 | #if !__GNUC_PREREQ__(2, 95) |
266 | #define __alignof(x) __offsetof(struct { char __a; x __b; }, __b) |
||
267 | #endif |
||
4349 | Serge | 268 | |
4921 | Serge | 269 | /* |
270 | * Keywords added in C11. |
||
271 | */ |
||
4349 | Serge | 272 | |
4921 | Serge | 273 | #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L |
274 | |||
275 | #if !__has_extension(c_alignas) |
||
276 | #if (defined(__cplusplus) && __cplusplus >= 201103L) || \ |
||
277 | __has_extension(cxx_alignas) |
||
278 | #define _Alignas(x) alignas(x) |
||
4349 | Serge | 279 | #else |
4921 | Serge | 280 | /* XXX: Only emulates _Alignas(constant-expression); not _Alignas(type-name). */ |
281 | #define _Alignas(x) __aligned(x) |
||
4349 | Serge | 282 | #endif |
4921 | Serge | 283 | #endif |
4349 | Serge | 284 | |
4921 | Serge | 285 | #if defined(__cplusplus) && __cplusplus >= 201103L |
286 | #define _Alignof(x) alignof(x) |
||
287 | #else |
||
288 | #define _Alignof(x) __alignof(x) |
||
4349 | Serge | 289 | #endif |
290 | |||
4921 | Serge | 291 | #if !__has_extension(c_atomic) && !__has_extension(cxx_atomic) |
292 | /* |
||
293 | * No native support for _Atomic(). Place object in structure to prevent |
||
294 | * most forms of direct non-atomic access. |
||
295 | */ |
||
296 | #define _Atomic(T) struct { T volatile __val; } |
||
297 | #endif |
||
298 | |||
299 | #if defined(__cplusplus) && __cplusplus >= 201103L |
||
300 | #define _Noreturn [[noreturn]] |
||
301 | #else |
||
302 | #define _Noreturn __dead2 |
||
303 | #endif |
||
304 | |||
305 | #if __GNUC_PREREQ__(4, 6) && !defined(__cplusplus) |
||
306 | /* Do nothing: _Static_assert() works as per C11 */ |
||
307 | #elif !__has_extension(c_static_assert) |
||
308 | #if (defined(__cplusplus) && __cplusplus >= 201103L) || \ |
||
309 | __has_extension(cxx_static_assert) |
||
310 | #define _Static_assert(x, y) static_assert(x, y) |
||
311 | #elif defined(__COUNTER__) |
||
312 | #define _Static_assert(x, y) __Static_assert(x, __COUNTER__) |
||
313 | #define __Static_assert(x, y) ___Static_assert(x, y) |
||
314 | #define ___Static_assert(x, y) typedef char __assert_ ## y[(x) ? 1 : -1] |
||
315 | #else |
||
316 | #define _Static_assert(x, y) struct __hack |
||
317 | #endif |
||
318 | #endif |
||
319 | |||
320 | #if !__has_extension(c_thread_local) |
||
321 | /* XXX: Change this to test against C++11 when clang in base supports it. */ |
||
322 | #if /* (defined(__cplusplus) && __cplusplus >= 201103L) || */ \ |
||
323 | __has_extension(cxx_thread_local) |
||
324 | #define _Thread_local thread_local |
||
325 | #else |
||
326 | #define _Thread_local __thread |
||
327 | #endif |
||
328 | #endif |
||
329 | |||
330 | #endif /* __STDC_VERSION__ || __STDC_VERSION__ < 201112L */ |
||
331 | |||
332 | /* |
||
333 | * Emulation of C11 _Generic(). Unlike the previously defined C11 |
||
334 | * keywords, it is not possible to implement this using exactly the same |
||
335 | * syntax. Therefore implement something similar under the name |
||
336 | * __generic(). Unlike _Generic(), this macro can only distinguish |
||
337 | * between a single type, so it requires nested invocations to |
||
338 | * distinguish multiple cases. |
||
339 | */ |
||
340 | |||
341 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L |
||
342 | #define __generic(expr, t, yes, no) \ |
||
343 | _Generic(expr, t: yes, default: no) |
||
344 | #elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus) |
||
345 | #define __generic(expr, t, yes, no) \ |
||
346 | __builtin_choose_expr( \ |
||
347 | __builtin_types_compatible_p(__typeof(expr), t), yes, no) |
||
348 | #endif |
||
349 | |||
350 | #if __GNUC_PREREQ__(2, 96) |
||
351 | #define __malloc_like __attribute__((__malloc__)) |
||
352 | #define __pure __attribute__((__pure__)) |
||
353 | #else |
||
354 | #define __malloc_like |
||
355 | #define __pure |
||
356 | #endif |
||
357 | |||
358 | #if __GNUC_PREREQ__(3, 1) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800) |
||
359 | #define __always_inline __attribute__((__always_inline__)) |
||
360 | #else |
||
361 | #define __always_inline |
||
362 | #endif |
||
363 | |||
364 | #if __GNUC_PREREQ__(3, 1) |
||
365 | #define __noinline __attribute__ ((__noinline__)) |
||
366 | #else |
||
367 | #define __noinline |
||
368 | #endif |
||
369 | |||
370 | #if __GNUC_PREREQ__(3, 3) |
||
371 | #define __nonnull(x) __attribute__((__nonnull__(x))) |
||
372 | #else |
||
373 | #define __nonnull(x) |
||
374 | #endif |
||
375 | |||
376 | #if __GNUC_PREREQ__(3, 4) |
||
377 | #define __fastcall __attribute__((__fastcall__)) |
||
378 | #else |
||
379 | #define __fastcall |
||
380 | #endif |
||
381 | |||
382 | #if __GNUC_PREREQ__(4, 1) |
||
383 | #define __returns_twice __attribute__((__returns_twice__)) |
||
384 | #else |
||
385 | #define __returns_twice |
||
386 | #endif |
||
387 | |||
388 | /* XXX: should use `#if __STDC_VERSION__ < 199901'. */ |
||
389 | #if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER) |
||
390 | #define __func__ NULL |
||
391 | #endif |
||
392 | |||
393 | /* |
||
394 | * GCC 2.95 provides `__restrict' as an extension to C90 to support the |
||
395 | * C99-specific `restrict' type qualifier. We happen to use `__restrict' as |
||
396 | * a way to define the `restrict' type qualifier without disturbing older |
||
397 | * software that is unaware of C99 keywords. |
||
398 | */ |
||
399 | #if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95) |
||
400 | #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 || defined(lint) |
||
401 | #define __restrict |
||
402 | #else |
||
403 | #define __restrict restrict |
||
404 | #endif |
||
405 | #endif |
||
406 | |||
407 | /* |
||
408 | * GNU C version 2.96 adds explicit branch prediction so that |
||
409 | * the CPU back-end can hint the processor and also so that |
||
410 | * code blocks can be reordered such that the predicted path |
||
411 | * sees a more linear flow, thus improving cache behavior, etc. |
||
412 | * |
||
413 | * The following two macros provide us with a way to utilize this |
||
414 | * compiler feature. Use __predict_true() if you expect the expression |
||
415 | * to evaluate to true, and __predict_false() if you expect the |
||
416 | * expression to evaluate to false. |
||
417 | * |
||
418 | * A few notes about usage: |
||
419 | * |
||
420 | * * Generally, __predict_false() error condition checks (unless |
||
421 | * you have some _strong_ reason to do otherwise, in which case |
||
422 | * document it), and/or __predict_true() `no-error' condition |
||
423 | * checks, assuming you want to optimize for the no-error case. |
||
424 | * |
||
425 | * * Other than that, if you don't know the likelihood of a test |
||
426 | * succeeding from empirical or other `hard' evidence, don't |
||
427 | * make predictions. |
||
428 | * |
||
429 | * * These are meant to be used in places that are run `a lot'. |
||
430 | * It is wasteful to make predictions in code that is run |
||
431 | * seldomly (e.g. at subsystem initialization time) as the |
||
432 | * basic block reordering that this affects can often generate |
||
433 | * larger code. |
||
434 | */ |
||
435 | #if __GNUC_PREREQ__(2, 96) |
||
436 | #define __predict_true(exp) __builtin_expect((exp), 1) |
||
437 | #define __predict_false(exp) __builtin_expect((exp), 0) |
||
438 | #else |
||
439 | #define __predict_true(exp) (exp) |
||
440 | #define __predict_false(exp) (exp) |
||
441 | #endif |
||
442 | |||
443 | #if __GNUC_PREREQ__(4, 2) |
||
444 | #define __hidden __attribute__((__visibility__("hidden"))) |
||
445 | #define __exported __attribute__((__visibility__("default"))) |
||
446 | #else |
||
447 | #define __hidden |
||
448 | #define __exported |
||
449 | #endif |
||
450 | |||
451 | #define __offsetof(type, field) offsetof(type, field) |
||
452 | #define __rangeof(type, start, end) \ |
||
453 | (__offsetof(type, end) - __offsetof(type, start)) |
||
454 | |||
455 | /* |
||
456 | * Given the pointer x to the member m of the struct s, return |
||
457 | * a pointer to the containing structure. When using GCC, we first |
||
458 | * assign pointer x to a local variable, to check that its type is |
||
459 | * compatible with member m. |
||
460 | */ |
||
461 | #if __GNUC_PREREQ__(3, 1) |
||
462 | #define __containerof(x, s, m) ({ \ |
||
463 | const volatile __typeof__(((s *)0)->m) *__x = (x); \ |
||
464 | __DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\ |
||
465 | }) |
||
466 | #else |
||
467 | #define __containerof(x, s, m) \ |
||
468 | __DEQUALIFY(s *, (const volatile char *)(x) - __offsetof(s, m)) |
||
469 | #endif |
||
470 | |||
471 | /* |
||
472 | * Compiler-dependent macros to declare that functions take printf-like |
||
473 | * or scanf-like arguments. They are null except for versions of gcc |
||
474 | * that are known to support the features properly (old versions of gcc-2 |
||
475 | * didn't permit keeping the keywords out of the application namespace). |
||
476 | */ |
||
477 | #if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER) |
||
478 | #define __printflike(fmtarg, firstvararg) |
||
479 | #define __scanflike(fmtarg, firstvararg) |
||
480 | #define __format_arg(fmtarg) |
||
481 | #define __strfmonlike(fmtarg, firstvararg) |
||
482 | #define __strftimelike(fmtarg, firstvararg) |
||
483 | #else |
||
484 | #define __printflike(fmtarg, firstvararg) \ |
||
485 | __attribute__((__format__ (__printf__, fmtarg, firstvararg))) |
||
486 | #define __scanflike(fmtarg, firstvararg) \ |
||
487 | __attribute__((__format__ (__scanf__, fmtarg, firstvararg))) |
||
488 | #define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg))) |
||
489 | #define __strfmonlike(fmtarg, firstvararg) \ |
||
490 | __attribute__((__format__ (__strfmon__, fmtarg, firstvararg))) |
||
491 | #define __strftimelike(fmtarg, firstvararg) \ |
||
492 | __attribute__((__format__ (__strftime__, fmtarg, firstvararg))) |
||
493 | #endif |
||
494 | |||
495 | /* Compiler-dependent macros that rely on FreeBSD-specific extensions. */ |
||
496 | #if defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 300001 && \ |
||
497 | defined(__GNUC__) && !defined(__INTEL_COMPILER) |
||
498 | #define __printf0like(fmtarg, firstvararg) \ |
||
499 | __attribute__((__format__ (__printf0__, fmtarg, firstvararg))) |
||
500 | #else |
||
501 | #define __printf0like(fmtarg, firstvararg) |
||
502 | #endif |
||
503 | |||
504 | #if defined(__GNUC__) || defined(__INTEL_COMPILER) |
||
505 | #ifndef __INTEL_COMPILER |
||
4349 | Serge | 506 | #define __strong_reference(sym,aliassym) \ |
4921 | Serge | 507 | extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym))) |
508 | #endif |
||
4349 | Serge | 509 | #ifdef __ELF__ |
510 | #ifdef __STDC__ |
||
511 | #define __weak_reference(sym,alias) \ |
||
512 | __asm__(".weak " #alias); \ |
||
513 | __asm__(".equ " #alias ", " #sym) |
||
514 | #define __warn_references(sym,msg) \ |
||
515 | __asm__(".section .gnu.warning." #sym); \ |
||
516 | __asm__(".asciz \"" msg "\""); \ |
||
517 | __asm__(".previous") |
||
4921 | Serge | 518 | #define __sym_compat(sym,impl,verid) \ |
519 | __asm__(".symver " #impl ", " #sym "@" #verid) |
||
520 | #define __sym_default(sym,impl,verid) \ |
||
521 | __asm__(".symver " #impl ", " #sym "@@" #verid) |
||
4349 | Serge | 522 | #else |
523 | #define __weak_reference(sym,alias) \ |
||
524 | __asm__(".weak alias"); \ |
||
525 | __asm__(".equ alias, sym") |
||
526 | #define __warn_references(sym,msg) \ |
||
527 | __asm__(".section .gnu.warning.sym"); \ |
||
528 | __asm__(".asciz \"msg\""); \ |
||
529 | __asm__(".previous") |
||
4921 | Serge | 530 | #define __sym_compat(sym,impl,verid) \ |
531 | __asm__(".symver impl, sym@verid") |
||
532 | #define __sym_default(impl,sym,verid) \ |
||
533 | __asm__(".symver impl, sym@@verid") |
||
4349 | Serge | 534 | #endif /* __STDC__ */ |
535 | #else /* !__ELF__ */ |
||
536 | #ifdef __STDC__ |
||
537 | #define __weak_reference(sym,alias) \ |
||
538 | __asm__(".stabs \"_" #alias "\",11,0,0,0"); \ |
||
539 | __asm__(".stabs \"_" #sym "\",1,0,0,0") |
||
540 | #define __warn_references(sym,msg) \ |
||
541 | __asm__(".stabs \"" msg "\",30,0,0,0"); \ |
||
542 | __asm__(".stabs \"_" #sym "\",1,0,0,0") |
||
543 | #else |
||
544 | #define __weak_reference(sym,alias) \ |
||
545 | __asm__(".stabs \"_/**/alias\",11,0,0,0"); \ |
||
546 | __asm__(".stabs \"_/**/sym\",1,0,0,0") |
||
547 | #define __warn_references(sym,msg) \ |
||
548 | __asm__(".stabs msg,30,0,0,0"); \ |
||
549 | __asm__(".stabs \"_/**/sym\",1,0,0,0") |
||
550 | #endif /* __STDC__ */ |
||
551 | #endif /* __ELF__ */ |
||
4921 | Serge | 552 | #endif /* __GNUC__ || __INTEL_COMPILER */ |
4349 | Serge | 553 | |
4921 | Serge | 554 | #ifndef __FBSDID |
555 | #define __FBSDID(s) struct __hack |
||
556 | #endif |
||
557 | |||
558 | #ifndef __RCSID |
||
559 | #define __RCSID(s) struct __hack |
||
560 | #endif |
||
561 | |||
562 | #ifndef __RCSID_SOURCE |
||
563 | #define __RCSID_SOURCE(s) struct __hack |
||
564 | #endif |
||
565 | |||
566 | #ifndef __SCCSID |
||
567 | #define __SCCSID(s) struct __hack |
||
568 | #endif |
||
569 | |||
570 | #ifndef __COPYRIGHT |
||
571 | #define __COPYRIGHT(s) struct __hack |
||
572 | #endif |
||
573 | |||
574 | #ifndef __DECONST |
||
575 | #define __DECONST(type, var) ((type)(__uintptr_t)(const void *)(var)) |
||
576 | #endif |
||
577 | |||
578 | #ifndef __DEVOLATILE |
||
579 | #define __DEVOLATILE(type, var) ((type)(__uintptr_t)(volatile void *)(var)) |
||
580 | #endif |
||
581 | |||
582 | #ifndef __DEQUALIFY |
||
583 | #define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var)) |
||
584 | #endif |
||
585 | |||
586 | /*- |
||
587 | * The following definitions are an extension of the behavior originally |
||
588 | * implemented in |
||
589 | * POSIX.1 requires that the macros we test be defined before any standard |
||
590 | * header file is included. |
||
591 | * |
||
592 | * Here's a quick run-down of the versions: |
||
593 | * defined(_POSIX_SOURCE) 1003.1-1988 |
||
594 | * _POSIX_C_SOURCE == 1 1003.1-1990 |
||
595 | * _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option |
||
596 | * _POSIX_C_SOURCE == 199309 1003.1b-1993 |
||
597 | * _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995, |
||
598 | * and the omnibus ISO/IEC 9945-1: 1996 |
||
599 | * _POSIX_C_SOURCE == 200112 1003.1-2001 |
||
600 | * _POSIX_C_SOURCE == 200809 1003.1-2008 |
||
601 | * |
||
602 | * In addition, the X/Open Portability Guide, which is now the Single UNIX |
||
603 | * Specification, defines a feature-test macro which indicates the version of |
||
604 | * that specification, and which subsumes _POSIX_C_SOURCE. |
||
605 | * |
||
606 | * Our macros begin with two underscores to avoid namespace screwage. |
||
607 | */ |
||
608 | |||
609 | /* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */ |
||
610 | #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1 |
||
611 | #undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */ |
||
612 | #define _POSIX_C_SOURCE 199009 |
||
613 | #endif |
||
614 | |||
615 | /* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */ |
||
616 | #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2 |
||
617 | #undef _POSIX_C_SOURCE |
||
618 | #define _POSIX_C_SOURCE 199209 |
||
619 | #endif |
||
620 | |||
621 | /* Deal with various X/Open Portability Guides and Single UNIX Spec. */ |
||
622 | #ifdef _XOPEN_SOURCE |
||
623 | #if _XOPEN_SOURCE - 0 >= 700 |
||
624 | #define __XSI_VISIBLE 700 |
||
625 | #undef _POSIX_C_SOURCE |
||
626 | #define _POSIX_C_SOURCE 200809 |
||
627 | #elif _XOPEN_SOURCE - 0 >= 600 |
||
628 | #define __XSI_VISIBLE 600 |
||
629 | #undef _POSIX_C_SOURCE |
||
630 | #define _POSIX_C_SOURCE 200112 |
||
631 | #elif _XOPEN_SOURCE - 0 >= 500 |
||
632 | #define __XSI_VISIBLE 500 |
||
633 | #undef _POSIX_C_SOURCE |
||
634 | #define _POSIX_C_SOURCE 199506 |
||
635 | #endif |
||
636 | #endif |
||
637 | |||
638 | /* |
||
639 | * Deal with all versions of POSIX. The ordering relative to the tests above is |
||
640 | * important. |
||
641 | */ |
||
642 | #if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) |
||
643 | #define _POSIX_C_SOURCE 198808 |
||
644 | #endif |
||
645 | #ifdef _POSIX_C_SOURCE |
||
646 | #if _POSIX_C_SOURCE >= 200809 |
||
647 | #define __POSIX_VISIBLE 200809 |
||
648 | #define __ISO_C_VISIBLE 1999 |
||
649 | #elif _POSIX_C_SOURCE >= 200112 |
||
650 | #define __POSIX_VISIBLE 200112 |
||
651 | #define __ISO_C_VISIBLE 1999 |
||
652 | #elif _POSIX_C_SOURCE >= 199506 |
||
653 | #define __POSIX_VISIBLE 199506 |
||
654 | #define __ISO_C_VISIBLE 1990 |
||
655 | #elif _POSIX_C_SOURCE >= 199309 |
||
656 | #define __POSIX_VISIBLE 199309 |
||
657 | #define __ISO_C_VISIBLE 1990 |
||
658 | #elif _POSIX_C_SOURCE >= 199209 |
||
659 | #define __POSIX_VISIBLE 199209 |
||
660 | #define __ISO_C_VISIBLE 1990 |
||
661 | #elif _POSIX_C_SOURCE >= 199009 |
||
662 | #define __POSIX_VISIBLE 199009 |
||
663 | #define __ISO_C_VISIBLE 1990 |
||
664 | #else |
||
665 | #define __POSIX_VISIBLE 198808 |
||
666 | #define __ISO_C_VISIBLE 0 |
||
667 | #endif /* _POSIX_C_SOURCE */ |
||
668 | #else |
||
669 | /*- |
||
670 | * Deal with _ANSI_SOURCE: |
||
671 | * If it is defined, and no other compilation environment is explicitly |
||
672 | * requested, then define our internal feature-test macros to zero. This |
||
673 | * makes no difference to the preprocessor (undefined symbols in preprocessing |
||
674 | * expressions are defined to have value zero), but makes it more convenient for |
||
675 | * a test program to print out the values. |
||
676 | * |
||
677 | * If a program mistakenly defines _ANSI_SOURCE and some other macro such as |
||
678 | * _POSIX_C_SOURCE, we will assume that it wants the broader compilation |
||
679 | * environment (and in fact we will never get here). |
||
680 | */ |
||
681 | #if defined(_ANSI_SOURCE) /* Hide almost everything. */ |
||
682 | #define __POSIX_VISIBLE 0 |
||
683 | #define __XSI_VISIBLE 0 |
||
684 | #define __BSD_VISIBLE 0 |
||
685 | #define __ISO_C_VISIBLE 1990 |
||
686 | #elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */ |
||
687 | #define __POSIX_VISIBLE 0 |
||
688 | #define __XSI_VISIBLE 0 |
||
689 | #define __BSD_VISIBLE 0 |
||
690 | #define __ISO_C_VISIBLE 1999 |
||
691 | #elif defined(_C11_SOURCE) /* Localism to specify strict C11 env. */ |
||
692 | #define __POSIX_VISIBLE 0 |
||
693 | #define __XSI_VISIBLE 0 |
||
694 | #define __BSD_VISIBLE 0 |
||
695 | #define __ISO_C_VISIBLE 2011 |
||
696 | #elif defined(_GNU_SOURCE) /* Everything and the kitchen sink. */ |
||
697 | #define __POSIX_VISIBLE 200809 |
||
698 | #define __XSI_VISIBLE 700 |
||
699 | #define __BSD_VISIBLE 1 |
||
700 | #define __ISO_C_VISIBLE 2011 |
||
701 | #define __GNU_VISIBLE 1 |
||
702 | #else /* Default: everything except __GNU_VISIBLE. */ |
||
703 | #define __POSIX_VISIBLE 200809 |
||
704 | #define __XSI_VISIBLE 700 |
||
705 | #define __BSD_VISIBLE 1 |
||
706 | #define __ISO_C_VISIBLE 2011 |
||
707 | #endif |
||
708 | #endif |
||
709 | |||
710 | #endif /* !_SYS_CDEFS_H_ */>>>>>> |