blob: 27f73fc6a5951f345b4aed3facf9359e6c7ea28c [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*-
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 * 4. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * @(#)cdefs.h 8.8 (Berkeley) 1/9/95
33 * $FreeBSD$
34 */
35
36#ifndef _SYS_CDEFS_H_
37#define _SYS_CDEFS_H_
38
Antonio Nino Diaz957514d2018-11-15 12:01:15 +000039/* Defined here for compatibility with the Trusted Firmware source code */
40#define __init
41
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020042#if defined(__cplusplus)
43#define __BEGIN_DECLS extern "C" {
44#define __END_DECLS }
45#else
46#define __BEGIN_DECLS
47#define __END_DECLS
48#endif
49
50/*
51 * This code has been put in place to help reduce the addition of
52 * compiler specific defines in FreeBSD code. It helps to aid in
53 * having a compiler-agnostic source tree.
54 */
55
56#if defined(__GNUC__) || defined(__INTEL_COMPILER)
57
58#if __GNUC__ >= 3 || defined(__INTEL_COMPILER)
59#define __GNUCLIKE_ASM 3
60#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS
61#else
62#define __GNUCLIKE_ASM 2
63#endif
64#define __GNUCLIKE___TYPEOF 1
65#define __GNUCLIKE___OFFSETOF 1
66#define __GNUCLIKE___SECTION 1
67
68#ifndef __INTEL_COMPILER
69# define __GNUCLIKE_CTOR_SECTION_HANDLING 1
70#endif
71
72#define __GNUCLIKE_BUILTIN_CONSTANT_P 1
73# if defined(__INTEL_COMPILER) && defined(__cplusplus) \
74 && __INTEL_COMPILER < 800
75# undef __GNUCLIKE_BUILTIN_CONSTANT_P
76# endif
77
78#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3) && !defined(__INTEL_COMPILER)
79# define __GNUCLIKE_BUILTIN_VARARGS 1
80# define __GNUCLIKE_BUILTIN_STDARG 1
81# define __GNUCLIKE_BUILTIN_VAALIST 1
82#endif
83
84#if defined(__GNUC__)
85# define __GNUC_VA_LIST_COMPATIBILITY 1
86#endif
87
88#ifndef __INTEL_COMPILER
89# define __GNUCLIKE_BUILTIN_NEXT_ARG 1
90# define __GNUCLIKE_MATH_BUILTIN_RELOPS
91#endif
92
93#define __GNUCLIKE_BUILTIN_MEMCPY 1
94
95/* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */
96#define __CC_SUPPORTS_INLINE 1
97#define __CC_SUPPORTS___INLINE 1
98#define __CC_SUPPORTS___INLINE__ 1
99
100#define __CC_SUPPORTS___FUNC__ 1
101#define __CC_SUPPORTS_WARNING 1
102
103#define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */
104
105#define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1
106
107#endif /* __GNUC__ || __INTEL_COMPILER */
108
109/*
110 * Macro to test if we're using a specific version of gcc or later.
111 */
112#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
113#define __GNUC_PREREQ__(ma, mi) \
114 (__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
115#else
116#define __GNUC_PREREQ__(ma, mi) 0
117#endif
118
119/*
120 * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
121 * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
122 * The __CONCAT macro is a bit tricky to use if it must work in non-ANSI
123 * mode -- there must be no spaces between its arguments, and for nested
124 * __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also
125 * concatenate double-quoted strings produced by the __STRING macro, but
126 * this only works with ANSI C.
127 *
128 * __XSTRING is like __STRING, but it expands any macros in its argument
129 * first. It is only available with ANSI C.
130 */
131#if defined(__STDC__) || defined(__cplusplus)
132#define __P(protos) protos /* full-blown ANSI C */
133#define __CONCAT1(x,y) x ## y
134#define __CONCAT(x,y) __CONCAT1(x,y)
135#define __STRING(x) #x /* stringify without expanding x */
136#define __XSTRING(x) __STRING(x) /* expand x, then stringify */
137
138#define __const const /* define reserved names to standard */
139#define __signed signed
140#define __volatile volatile
141#if defined(__cplusplus)
142#define __inline inline /* convert to C++ keyword */
143#else
144#if !(defined(__CC_SUPPORTS___INLINE))
145#define __inline /* delete GCC keyword */
146#endif /* ! __CC_SUPPORTS___INLINE */
147#endif /* !__cplusplus */
148
149#else /* !(__STDC__ || __cplusplus) */
150#define __P(protos) () /* traditional C preprocessor */
151#define __CONCAT(x,y) x/**/y
152#define __STRING(x) "x"
153
154#if !defined(__CC_SUPPORTS___INLINE)
155#define __const /* delete pseudo-ANSI C keywords */
156#define __inline
157#define __signed
158#define __volatile
159/*
160 * In non-ANSI C environments, new programs will want ANSI-only C keywords
161 * deleted from the program and old programs will want them left alone.
162 * When using a compiler other than gcc, programs using the ANSI C keywords
163 * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
164 * When using "gcc -traditional", we assume that this is the intent; if
165 * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
166 */
167#ifndef NO_ANSI_KEYWORDS
168#define const /* delete ANSI C keywords */
169#define inline
170#define signed
171#define volatile
172#endif /* !NO_ANSI_KEYWORDS */
173#endif /* !__CC_SUPPORTS___INLINE */
174#endif /* !(__STDC__ || __cplusplus) */
175
176/*
177 * Compiler-dependent macros to help declare dead (non-returning) and
178 * pure (no side effects) functions, and unused variables. They are
179 * null except for versions of gcc that are known to support the features
180 * properly (old versions of gcc-2 supported the dead and pure features
181 * in a different (wrong) way). If we do not provide an implementation
182 * for a given compiler, let the compile fail if it is told to use
183 * a feature that we cannot live without.
184 */
185#ifdef lint
186#define __dead2
187#define __pure2
188#define __unused
189#define __packed
190#define __aligned(x)
191#define __section(x)
192#else
193#if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER)
194#define __dead2
195#define __pure2
196#define __unused
197#endif
198#if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7 && !defined(__INTEL_COMPILER)
199#define __dead2 __attribute__((__noreturn__))
200#define __pure2 __attribute__((__const__))
201#define __unused
202/* XXX Find out what to do for __packed, __aligned and __section */
203#endif
204#if __GNUC_PREREQ__(2, 7)
205#define __dead2 __attribute__((__noreturn__))
206#define __pure2 __attribute__((__const__))
207#define __unused __attribute__((__unused__))
208#define __used __attribute__((__used__))
209#define __packed __attribute__((__packed__))
210#define __aligned(x) __attribute__((__aligned__(x)))
211#define __section(x) __attribute__((__section__(x)))
212#endif
213#if defined(__INTEL_COMPILER)
214#define __dead2 __attribute__((__noreturn__))
215#define __pure2 __attribute__((__const__))
216#define __unused __attribute__((__unused__))
217#define __used __attribute__((__used__))
218#define __packed __attribute__((__packed__))
219#define __aligned(x) __attribute__((__aligned__(x)))
220#define __section(x) __attribute__((__section__(x)))
221#endif
222#endif
223
224#if !__GNUC_PREREQ__(2, 95)
225#define __alignof(x) __offsetof(struct { char __a; x __b; }, __b)
226#endif
227
228/*
229 * Keywords added in C11.
230 */
231#if defined(__cplusplus) && __cplusplus >= 201103L
232#define _Alignas(e) alignas(e)
233#define _Alignof(e) alignof(e)
234#define _Noreturn [[noreturn]]
235#define _Static_assert(e, s) static_assert(e, s)
236/* FIXME: change this to thread_local when clang in base supports it */
237#define _Thread_local __thread
238#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
239/* Do nothing. They are language keywords. */
240#else
241/* Not supported. Implement them using our versions. */
242#define _Alignas(x) __aligned(x)
243#define _Alignof(x) __alignof(x)
244#define _Noreturn __dead2
245#define _Thread_local __thread
246#ifdef __COUNTER__
247#define _Static_assert(x, y) __Static_assert(x, __COUNTER__)
248#define __Static_assert(x, y) ___Static_assert(x, y)
249#define ___Static_assert(x, y) typedef char __assert_ ## y[(x) ? 1 : -1]
250#else
251#define _Static_assert(x, y) struct __hack
252#endif
253#endif
254
255/*
256 * Emulation of C11 _Generic(). Unlike the previously defined C11
257 * keywords, it is not possible to implement this using exactly the same
258 * syntax. Therefore implement something similar under the name
259 * __generic(). Unlike _Generic(), this macro can only distinguish
260 * between a single type, so it requires nested invocations to
261 * distinguish multiple cases.
262 */
263
264#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
265#define __generic(expr, t, yes, no) \
266 _Generic(expr, t: yes, default: no)
267#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
268#define __generic(expr, t, yes, no) \
269 __builtin_choose_expr( \
270 __builtin_types_compatible_p(__typeof(expr), t), yes, no)
271#endif
272
273#if __GNUC_PREREQ__(2, 96)
274#define __malloc_like __attribute__((__malloc__))
275#define __pure __attribute__((__pure__))
276#else
277#define __malloc_like
278#define __pure
279#endif
280
281#if __GNUC_PREREQ__(3, 1) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800)
282#define __always_inline __attribute__((__always_inline__))
283#else
284#define __always_inline
285#endif
286
287#if __GNUC_PREREQ__(3, 1)
288#define __noinline __attribute__ ((__noinline__))
289#else
290#define __noinline
291#endif
292
293#if __GNUC_PREREQ__(3, 3)
294#define __nonnull(x) __attribute__((__nonnull__(x)))
295#else
296#define __nonnull(x)
297#endif
298
299#if __GNUC_PREREQ__(3, 4)
300#define __fastcall __attribute__((__fastcall__))
301#else
302#define __fastcall
303#endif
304
305#if __GNUC_PREREQ__(4, 1)
306#define __returns_twice __attribute__((__returns_twice__))
307#else
308#define __returns_twice
309#endif
310
311/* XXX: should use `#if __STDC_VERSION__ < 199901'. */
312#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
313#define __func__ NULL
314#endif
315
316#if (defined(__INTEL_COMPILER) || (defined(__GNUC__) && __GNUC__ >= 2)) && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901
317#define __LONG_LONG_SUPPORTED
318#endif
319
320/* C++11 exposes a load of C99 stuff */
321#if defined(__cplusplus) && __cplusplus >= 201103L
322#define __LONG_LONG_SUPPORTED
323#ifndef __STDC_LIMIT_MACROS
324#define __STDC_LIMIT_MACROS
325#endif
326#ifndef __STDC_CONSTANT_MACROS
327#define __STDC_CONSTANT_MACROS
328#endif
329#endif
330
331/*
332 * GCC 2.95 provides `__restrict' as an extension to C90 to support the
333 * C99-specific `restrict' type qualifier. We happen to use `__restrict' as
334 * a way to define the `restrict' type qualifier without disturbing older
335 * software that is unaware of C99 keywords.
336 */
337#if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95)
338#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 || defined(lint)
339#define __restrict
340#else
341#define __restrict restrict
342#endif
343#endif
344
345/*
346 * GNU C version 2.96 adds explicit branch prediction so that
347 * the CPU back-end can hint the processor and also so that
348 * code blocks can be reordered such that the predicted path
349 * sees a more linear flow, thus improving cache behavior, etc.
350 *
351 * The following two macros provide us with a way to utilize this
352 * compiler feature. Use __predict_true() if you expect the expression
353 * to evaluate to true, and __predict_false() if you expect the
354 * expression to evaluate to false.
355 *
356 * A few notes about usage:
357 *
358 * * Generally, __predict_false() error condition checks (unless
359 * you have some _strong_ reason to do otherwise, in which case
360 * document it), and/or __predict_true() `no-error' condition
361 * checks, assuming you want to optimize for the no-error case.
362 *
363 * * Other than that, if you don't know the likelihood of a test
364 * succeeding from empirical or other `hard' evidence, don't
365 * make predictions.
366 *
367 * * These are meant to be used in places that are run `a lot'.
368 * It is wasteful to make predictions in code that is run
369 * seldomly (e.g. at subsystem initialization time) as the
370 * basic block reordering that this affects can often generate
371 * larger code.
372 */
373#if __GNUC_PREREQ__(2, 96)
374#define __predict_true(exp) __builtin_expect((exp), 1)
375#define __predict_false(exp) __builtin_expect((exp), 0)
376#else
377#define __predict_true(exp) (exp)
378#define __predict_false(exp) (exp)
379#endif
380
381#if __GNUC_PREREQ__(4, 2)
382#define __hidden __attribute__((__visibility__("hidden")))
383#define __exported __attribute__((__visibility__("default")))
384#else
385#define __hidden
386#define __exported
387#endif
388
389/*
390 * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
391 * require it.
392 */
393#if __GNUC_PREREQ__(4, 1)
394#define __offsetof(type, field) __builtin_offsetof(type, field)
395#else
396#ifndef __cplusplus
397#define __offsetof(type, field) \
398 ((__size_t)(__uintptr_t)((const volatile void *)&((type *)0)->field))
399#else
400#define __offsetof(type, field) \
401 (__offsetof__ (reinterpret_cast <__size_t> \
402 (&reinterpret_cast <const volatile char &> \
403 (static_cast<type *> (0)->field))))
404#endif
405#endif
406#define __rangeof(type, start, end) \
407 (__offsetof(type, end) - __offsetof(type, start))
408
409/*
410 * Given the pointer x to the member m of the struct s, return
411 * a pointer to the containing structure. When using GCC, we first
412 * assign pointer x to a local variable, to check that its type is
413 * compatible with member m.
414 */
415#if __GNUC_PREREQ__(3, 1)
416#define __containerof(x, s, m) ({ \
417 const volatile __typeof(((s *)0)->m) *__x = (x); \
418 __DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\
419})
420#else
421#define __containerof(x, s, m) \
422 __DEQUALIFY(s *, (const volatile char *)(x) - __offsetof(s, m))
423#endif
424
425/*
426 * Compiler-dependent macros to declare that functions take printf-like
427 * or scanf-like arguments. They are null except for versions of gcc
428 * that are known to support the features properly (old versions of gcc-2
429 * didn't permit keeping the keywords out of the application namespace).
430 */
431#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
432#define __printflike(fmtarg, firstvararg)
433#define __scanflike(fmtarg, firstvararg)
434#define __format_arg(fmtarg)
435#define __strfmonlike(fmtarg, firstvararg)
436#define __strftimelike(fmtarg, firstvararg)
437#else
438#define __printflike(fmtarg, firstvararg) \
439 __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
440#define __scanflike(fmtarg, firstvararg) \
441 __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
442#define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg)))
443#define __strfmonlike(fmtarg, firstvararg) \
444 __attribute__((__format__ (__strfmon__, fmtarg, firstvararg)))
445#define __strftimelike(fmtarg, firstvararg) \
446 __attribute__((__format__ (__strftime__, fmtarg, firstvararg)))
447#endif
448
449/* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
450#if __FreeBSD_cc_version >= 300001 && defined(__GNUC__) && !defined(__INTEL_COMPILER)
451#define __printf0like(fmtarg, firstvararg) \
452 __attribute__((__format__ (__printf0__, fmtarg, firstvararg)))
453#else
454#define __printf0like(fmtarg, firstvararg)
455#endif
456
457#if defined(__GNUC__) || defined(__INTEL_COMPILER)
458#ifndef __INTEL_COMPILER
459#define __strong_reference(sym,aliassym) \
460 extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)))
461#endif
462#ifdef __STDC__
463#define __weak_reference(sym,alias) \
464 __asm__(".weak " #alias); \
465 __asm__(".equ " #alias ", " #sym)
466#define __warn_references(sym,msg) \
467 __asm__(".section .gnu.warning." #sym); \
468 __asm__(".asciz \"" msg "\""); \
469 __asm__(".previous")
470#define __sym_compat(sym,impl,verid) \
471 __asm__(".symver " #impl ", " #sym "@" #verid)
472#define __sym_default(sym,impl,verid) \
473 __asm__(".symver " #impl ", " #sym "@@" #verid)
474#else
475#define __weak_reference(sym,alias) \
476 __asm__(".weak alias"); \
477 __asm__(".equ alias, sym")
478#define __warn_references(sym,msg) \
479 __asm__(".section .gnu.warning.sym"); \
480 __asm__(".asciz \"msg\""); \
481 __asm__(".previous")
482#define __sym_compat(sym,impl,verid) \
483 __asm__(".symver impl, sym@verid")
484#define __sym_default(impl,sym,verid) \
485 __asm__(".symver impl, sym@@verid")
486#endif /* __STDC__ */
487#endif /* __GNUC__ || __INTEL_COMPILER */
488
489#define __GLOBL1(sym) __asm__(".globl " #sym)
490#define __GLOBL(sym) __GLOBL1(sym)
491
492#if defined(__GNUC__) || defined(__INTEL_COMPILER)
493#define __IDSTRING(name,string) __asm__(".ident\t\"" string "\"")
494#else
495/*
496 * The following definition might not work well if used in header files,
497 * but it should be better than nothing. If you want a "do nothing"
498 * version, then it should generate some harmless declaration, such as:
499 * #define __IDSTRING(name,string) struct __hack
500 */
501#define __IDSTRING(name,string) static const char name[] __unused = string
502#endif
503
504/*
505 * Embed the rcs id of a source file in the resulting library. Note that in
506 * more recent ELF binutils, we use .ident allowing the ID to be stripped.
507 * Usage:
508 * __FBSDID("$FreeBSD$");
509 */
510#ifndef __FBSDID
511#if !defined(lint) && !defined(STRIP_FBSDID)
512#define __FBSDID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
513#else
514#define __FBSDID(s) struct __hack
515#endif
516#endif
517
518#ifndef __RCSID
519#ifndef NO__RCSID
520#define __RCSID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
521#else
522#define __RCSID(s) struct __hack
523#endif
524#endif
525
526#ifndef __RCSID_SOURCE
527#ifndef NO__RCSID_SOURCE
528#define __RCSID_SOURCE(s) __IDSTRING(__CONCAT(__rcsid_source_,__LINE__),s)
529#else
530#define __RCSID_SOURCE(s) struct __hack
531#endif
532#endif
533
534#ifndef __SCCSID
535#ifndef NO__SCCSID
536#define __SCCSID(s) __IDSTRING(__CONCAT(__sccsid_,__LINE__),s)
537#else
538#define __SCCSID(s) struct __hack
539#endif
540#endif
541
542#ifndef __COPYRIGHT
543#ifndef NO__COPYRIGHT
544#define __COPYRIGHT(s) __IDSTRING(__CONCAT(__copyright_,__LINE__),s)
545#else
546#define __COPYRIGHT(s) struct __hack
547#endif
548#endif
549
550#ifndef __DECONST
551#define __DECONST(type, var) ((type)(__uintptr_t)(const void *)(var))
552#endif
553
554#ifndef __DEVOLATILE
555#define __DEVOLATILE(type, var) ((type)(__uintptr_t)(volatile void *)(var))
556#endif
557
558#ifndef __DEQUALIFY
559#define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var))
560#endif
561
562/*-
563 * The following definitions are an extension of the behavior originally
564 * implemented in <sys/_posix.h>, but with a different level of granularity.
565 * POSIX.1 requires that the macros we test be defined before any standard
566 * header file is included.
567 *
568 * Here's a quick run-down of the versions:
569 * defined(_POSIX_SOURCE) 1003.1-1988
570 * _POSIX_C_SOURCE == 1 1003.1-1990
571 * _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option
572 * _POSIX_C_SOURCE == 199309 1003.1b-1993
573 * _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995,
574 * and the omnibus ISO/IEC 9945-1: 1996
575 * _POSIX_C_SOURCE == 200112 1003.1-2001
576 * _POSIX_C_SOURCE == 200809 1003.1-2008
577 *
578 * In addition, the X/Open Portability Guide, which is now the Single UNIX
579 * Specification, defines a feature-test macro which indicates the version of
580 * that specification, and which subsumes _POSIX_C_SOURCE.
581 *
582 * Our macros begin with two underscores to avoid namespace screwage.
583 */
584
585/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
586#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1
587#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */
588#define _POSIX_C_SOURCE 199009
589#endif
590
591/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */
592#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2
593#undef _POSIX_C_SOURCE
594#define _POSIX_C_SOURCE 199209
595#endif
596
597/* Deal with various X/Open Portability Guides and Single UNIX Spec. */
598#ifdef _XOPEN_SOURCE
599#if _XOPEN_SOURCE - 0 >= 700
600#define __XSI_VISIBLE 700
601#undef _POSIX_C_SOURCE
602#define _POSIX_C_SOURCE 200809
603#elif _XOPEN_SOURCE - 0 >= 600
604#define __XSI_VISIBLE 600
605#undef _POSIX_C_SOURCE
606#define _POSIX_C_SOURCE 200112
607#elif _XOPEN_SOURCE - 0 >= 500
608#define __XSI_VISIBLE 500
609#undef _POSIX_C_SOURCE
610#define _POSIX_C_SOURCE 199506
611#endif
612#endif
613
614/*
615 * Deal with all versions of POSIX. The ordering relative to the tests above is
616 * important.
617 */
618#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
619#define _POSIX_C_SOURCE 198808
620#endif
621#ifdef _POSIX_C_SOURCE
622#if _POSIX_C_SOURCE >= 200809
623#define __POSIX_VISIBLE 200809
624#define __ISO_C_VISIBLE 1999
625#elif _POSIX_C_SOURCE >= 200112
626#define __POSIX_VISIBLE 200112
627#define __ISO_C_VISIBLE 1999
628#elif _POSIX_C_SOURCE >= 199506
629#define __POSIX_VISIBLE 199506
630#define __ISO_C_VISIBLE 1990
631#elif _POSIX_C_SOURCE >= 199309
632#define __POSIX_VISIBLE 199309
633#define __ISO_C_VISIBLE 1990
634#elif _POSIX_C_SOURCE >= 199209
635#define __POSIX_VISIBLE 199209
636#define __ISO_C_VISIBLE 1990
637#elif _POSIX_C_SOURCE >= 199009
638#define __POSIX_VISIBLE 199009
639#define __ISO_C_VISIBLE 1990
640#else
641#define __POSIX_VISIBLE 198808
642#define __ISO_C_VISIBLE 0
643#endif /* _POSIX_C_SOURCE */
644#else
645/*-
646 * Deal with _ANSI_SOURCE:
647 * If it is defined, and no other compilation environment is explicitly
648 * requested, then define our internal feature-test macros to zero. This
649 * makes no difference to the preprocessor (undefined symbols in preprocessing
650 * expressions are defined to have value zero), but makes it more convenient for
651 * a test program to print out the values.
652 *
653 * If a program mistakenly defines _ANSI_SOURCE and some other macro such as
654 * _POSIX_C_SOURCE, we will assume that it wants the broader compilation
655 * environment (and in fact we will never get here).
656 */
657#if defined(_ANSI_SOURCE) /* Hide almost everything. */
658#define __POSIX_VISIBLE 0
659#define __XSI_VISIBLE 0
660#define __BSD_VISIBLE 0
661#define __ISO_C_VISIBLE 1990
662#elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */
663#define __POSIX_VISIBLE 0
664#define __XSI_VISIBLE 0
665#define __BSD_VISIBLE 0
666#define __ISO_C_VISIBLE 1999
667#else /* Default environment: show everything. */
668#define __POSIX_VISIBLE 200809
669#define __XSI_VISIBLE 700
670#define __BSD_VISIBLE 1
671#define __ISO_C_VISIBLE 1999
672#endif
673#endif
674
675#ifndef __has_feature
676#define __has_feature(x) 0
677#endif
678#ifndef __has_include
679#define __has_include(x) 0
680#endif
681#ifndef __has_builtin
682#define __has_builtin(x) 0
683#endif
684
685#if defined(__mips) || defined(__powerpc64__) || defined(__arm__)
686#define __NO_TLS 1
687#endif
688
689#endif /* !_SYS_CDEFS_H_ */