Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/cdefs.h
Show First 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | |||||
#endif | #endif | ||||
/* | /* | ||||
* This code has been put in place to help reduce the addition of | * This code has been put in place to help reduce the addition of | ||||
* compiler specific defines in FreeBSD code. It helps to aid in | * compiler specific defines in FreeBSD code. It helps to aid in | ||||
* having a compiler-agnostic source tree. | * having a compiler-agnostic source tree. | ||||
*/ | */ | ||||
#if __GNUC__ >= 3 | |||||
#define __GNUCLIKE_ASM 3 | #define __GNUCLIKE_ASM 3 | ||||
#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS | #define __GNUCLIKE_MATH_BUILTIN_CONSTANTS | ||||
#else | |||||
#define __GNUCLIKE_ASM 2 | |||||
#endif | |||||
#define __GNUCLIKE___TYPEOF 1 | #define __GNUCLIKE___TYPEOF 1 | ||||
#define __GNUCLIKE___OFFSETOF 1 | #define __GNUCLIKE___OFFSETOF 1 | ||||
#define __GNUCLIKE___SECTION 1 | #define __GNUCLIKE___SECTION 1 | ||||
#define __GNUCLIKE_CTOR_SECTION_HANDLING 1 | #define __GNUCLIKE_CTOR_SECTION_HANDLING 1 | ||||
#define __GNUCLIKE_BUILTIN_CONSTANT_P 1 | #define __GNUCLIKE_BUILTIN_CONSTANT_P 1 | ||||
#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3) | |||||
#define __GNUCLIKE_BUILTIN_VARARGS 1 | #define __GNUCLIKE_BUILTIN_VARARGS 1 | ||||
#define __GNUCLIKE_BUILTIN_STDARG 1 | #define __GNUCLIKE_BUILTIN_STDARG 1 | ||||
#define __GNUCLIKE_BUILTIN_VAALIST 1 | #define __GNUCLIKE_BUILTIN_VAALIST 1 | ||||
#endif | |||||
#define __GNUC_VA_LIST_COMPATIBILITY 1 | #define __GNUC_VA_LIST_COMPATIBILITY 1 | ||||
/* | /* | ||||
* Compiler memory barriers, specific to gcc and clang. | * Compiler memory barriers, specific to gcc and clang. | ||||
*/ | */ | ||||
#define __compiler_membar() __asm __volatile(" " : : : "memory") | #define __compiler_membar() __asm __volatile(" " : : : "memory") | ||||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | |||||
* pure (no side effects) functions, and unused variables. They are | * pure (no side effects) functions, and unused variables. They are | ||||
* null except for versions of gcc that are known to support the features | * null except for versions of gcc that are known to support the features | ||||
* properly (old versions of gcc-2 supported the dead and pure features | * properly (old versions of gcc-2 supported the dead and pure features | ||||
* in a different (wrong) way). If we do not provide an implementation | * in a different (wrong) way). If we do not provide an implementation | ||||
* for a given compiler, let the compile fail if it is told to use | * for a given compiler, let the compile fail if it is told to use | ||||
* a feature that we cannot live without. | * a feature that we cannot live without. | ||||
*/ | */ | ||||
#define __weak_symbol __attribute__((__weak__)) | #define __weak_symbol __attribute__((__weak__)) | ||||
#if !__GNUC_PREREQ__(2, 5) | |||||
#define __dead2 | |||||
#define __pure2 | |||||
#define __unused | |||||
#endif | |||||
#if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7 | |||||
#define __dead2 __attribute__((__noreturn__)) | #define __dead2 __attribute__((__noreturn__)) | ||||
#define __pure2 __attribute__((__const__)) | #define __pure2 __attribute__((__const__)) | ||||
#define __unused | |||||
/* XXX Find out what to do for __packed, __aligned and __section */ | |||||
#endif | |||||
#if __GNUC_PREREQ__(2, 7) | |||||
#define __dead2 __attribute__((__noreturn__)) | |||||
#define __pure2 __attribute__((__const__)) | |||||
#define __unused __attribute__((__unused__)) | #define __unused __attribute__((__unused__)) | ||||
#define __used __attribute__((__used__)) | #define __used __attribute__((__used__)) | ||||
#define __packed __attribute__((__packed__)) | #define __packed __attribute__((__packed__)) | ||||
#define __aligned(x) __attribute__((__aligned__(x))) | #define __aligned(x) __attribute__((__aligned__(x))) | ||||
#define __section(x) __attribute__((__section__(x))) | #define __section(x) __attribute__((__section__(x))) | ||||
#endif | |||||
#if __GNUC_PREREQ__(4, 3) || __has_attribute(__alloc_size__) | #if __GNUC_PREREQ__(4, 3) || __has_attribute(__alloc_size__) | ||||
#define __alloc_size(x) __attribute__((__alloc_size__(x))) | #define __alloc_size(x) __attribute__((__alloc_size__(x))) | ||||
#define __alloc_size2(n, x) __attribute__((__alloc_size__(n, x))) | #define __alloc_size2(n, x) __attribute__((__alloc_size__(n, x))) | ||||
#else | #else | ||||
#define __alloc_size(x) | #define __alloc_size(x) | ||||
#define __alloc_size2(n, x) | #define __alloc_size2(n, x) | ||||
#endif | #endif | ||||
#if __GNUC_PREREQ__(4, 9) || __has_attribute(__alloc_align__) | #if __GNUC_PREREQ__(4, 9) || __has_attribute(__alloc_align__) | ||||
#define __alloc_align(x) __attribute__((__alloc_align__(x))) | #define __alloc_align(x) __attribute__((__alloc_align__(x))) | ||||
#else | #else | ||||
#define __alloc_align(x) | #define __alloc_align(x) | ||||
#endif | #endif | ||||
#if !__GNUC_PREREQ__(2, 95) | |||||
#define __alignof(x) __offsetof(struct { char __a; x __b; }, __b) | |||||
#endif | |||||
/* | /* | ||||
* Keywords added in C11. | * Keywords added in C11. | ||||
*/ | */ | ||||
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L | #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L | ||||
#if !__has_extension(c_alignas) | #if !__has_extension(c_alignas) | ||||
#if (defined(__cplusplus) && __cplusplus >= 201103L) || \ | #if (defined(__cplusplus) && __cplusplus >= 201103L) || \ | ||||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | |||||
* between a single type, so it requires nested invocations to | * between a single type, so it requires nested invocations to | ||||
* distinguish multiple cases. | * distinguish multiple cases. | ||||
*/ | */ | ||||
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ | #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ | ||||
__has_extension(c_generic_selections) | __has_extension(c_generic_selections) | ||||
#define __generic(expr, t, yes, no) \ | #define __generic(expr, t, yes, no) \ | ||||
_Generic(expr, t: yes, default: no) | _Generic(expr, t: yes, default: no) | ||||
#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus) | #elif !defined(__cplusplus) | ||||
#define __generic(expr, t, yes, no) \ | #define __generic(expr, t, yes, no) \ | ||||
__builtin_choose_expr( \ | __builtin_choose_expr( \ | ||||
__builtin_types_compatible_p(__typeof(expr), t), yes, no) | __builtin_types_compatible_p(__typeof(expr), t), yes, no) | ||||
#endif | #endif | ||||
/* | /* | ||||
* C99 Static array indices in function parameter declarations. Syntax such as: | * C99 Static array indices in function parameter declarations. Syntax such as: | ||||
* void bar(int myArray[static 10]); | * void bar(int myArray[static 10]); | ||||
* is allowed in C99 but not in C++. Define __min_size appropriately so | * is allowed in C99 but not in C++. Define __min_size appropriately so | ||||
* headers using it can be compiled in either language. Use like this: | * headers using it can be compiled in either language. Use like this: | ||||
* void bar(int myArray[__min_size(10)]); | * void bar(int myArray[__min_size(10)]); | ||||
*/ | */ | ||||
#if !defined(__cplusplus) && \ | #if !defined(__cplusplus) && \ | ||||
(defined(__clang__) || __GNUC_PREREQ__(4, 6)) && \ | (defined(__clang__) || __GNUC_PREREQ__(4, 6)) && \ | ||||
(!defined(__STDC_VERSION__) || (__STDC_VERSION__ >= 199901)) | (!defined(__STDC_VERSION__) || (__STDC_VERSION__ >= 199901)) | ||||
#define __min_size(x) static (x) | #define __min_size(x) static (x) | ||||
#else | #else | ||||
#define __min_size(x) (x) | #define __min_size(x) (x) | ||||
#endif | #endif | ||||
#if __GNUC_PREREQ__(2, 96) | |||||
#define __malloc_like __attribute__((__malloc__)) | #define __malloc_like __attribute__((__malloc__)) | ||||
#define __pure __attribute__((__pure__)) | #define __pure __attribute__((__pure__)) | ||||
#else | |||||
#define __malloc_like | |||||
#define __pure | |||||
#endif | |||||
#if __GNUC_PREREQ__(3, 1) | |||||
#define __always_inline __attribute__((__always_inline__)) | #define __always_inline __attribute__((__always_inline__)) | ||||
#else | |||||
#define __always_inline | |||||
#endif | |||||
#if __GNUC_PREREQ__(3, 1) | |||||
#define __noinline __attribute__ ((__noinline__)) | #define __noinline __attribute__ ((__noinline__)) | ||||
#else | |||||
#define __noinline | |||||
#endif | |||||
#if __GNUC_PREREQ__(3, 4) | |||||
#define __fastcall __attribute__((__fastcall__)) | #define __fastcall __attribute__((__fastcall__)) | ||||
cem: This one is almost killable too. Outside of ce(4), we use this in one location: i386… | |||||
impAuthorUnsubmitted Done Inline Actions
ce(4) doesn't matter: it will define it if it isn't already defined. So we can safely ignore it. :) I'm not sure what resumectx() does on i386,... I may investigate though... But in any event, I was going to do an audit of all these defines to see what's still used as a followup. imp: > This one is almost killable too. Outside of ce(4), we use this in one location: i386… | |||||
#define __result_use_check __attribute__((__warn_unused_result__)) | #define __result_use_check __attribute__((__warn_unused_result__)) | ||||
#else | |||||
#define __fastcall | |||||
#define __result_use_check | |||||
#endif | |||||
#if __GNUC_PREREQ__(4, 1) | |||||
#define __returns_twice __attribute__((__returns_twice__)) | #define __returns_twice __attribute__((__returns_twice__)) | ||||
#else | |||||
#define __returns_twice | |||||
#endif | |||||
#if __GNUC_PREREQ__(4, 6) || __has_builtin(__builtin_unreachable) | #if __GNUC_PREREQ__(4, 6) || __has_builtin(__builtin_unreachable) | ||||
#define __unreachable() __builtin_unreachable() | #define __unreachable() __builtin_unreachable() | ||||
#else | #else | ||||
#define __unreachable() ((void)0) | #define __unreachable() ((void)0) | ||||
#endif | #endif | ||||
/* XXX: should use `#if __STDC_VERSION__ < 199901'. */ | #if !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901 | ||||
#if !__GNUC_PREREQ__(2, 7) | |||||
#define __func__ NULL | |||||
#endif | |||||
#if __GNUC__ >= 2 && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901 | |||||
#define __LONG_LONG_SUPPORTED | #define __LONG_LONG_SUPPORTED | ||||
#endif | #endif | ||||
/* C++11 exposes a load of C99 stuff */ | /* C++11 exposes a load of C99 stuff */ | ||||
#if defined(__cplusplus) && __cplusplus >= 201103L | #if defined(__cplusplus) && __cplusplus >= 201103L | ||||
#define __LONG_LONG_SUPPORTED | #define __LONG_LONG_SUPPORTED | ||||
#ifndef __STDC_LIMIT_MACROS | #ifndef __STDC_LIMIT_MACROS | ||||
#define __STDC_LIMIT_MACROS | #define __STDC_LIMIT_MACROS | ||||
#endif | #endif | ||||
#ifndef __STDC_CONSTANT_MACROS | #ifndef __STDC_CONSTANT_MACROS | ||||
#define __STDC_CONSTANT_MACROS | #define __STDC_CONSTANT_MACROS | ||||
#endif | #endif | ||||
#endif | #endif | ||||
/* | |||||
* GCC 2.95 provides `__restrict' as an extension to C90 to support the | |||||
* C99-specific `restrict' type qualifier. We happen to use `__restrict' as | |||||
* a way to define the `restrict' type qualifier without disturbing older | |||||
* software that is unaware of C99 keywords. | |||||
*/ | |||||
#if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95) | |||||
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 | #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 | ||||
#define __restrict | #define __restrict | ||||
#else | #else | ||||
#define __restrict restrict | #define __restrict restrict | ||||
#endif | #endif | ||||
#endif | |||||
/* | /* | ||||
* GNU C version 2.96 adds explicit branch prediction so that | * GNU C version 2.96 adds explicit branch prediction so that | ||||
* the CPU back-end can hint the processor and also so that | * the CPU back-end can hint the processor and also so that | ||||
* code blocks can be reordered such that the predicted path | * code blocks can be reordered such that the predicted path | ||||
* sees a more linear flow, thus improving cache behavior, etc. | * sees a more linear flow, thus improving cache behavior, etc. | ||||
* | * | ||||
* The following two macros provide us with a way to utilize this | * The following two macros provide us with a way to utilize this | ||||
Show All 13 Lines | |||||
* make predictions. | * make predictions. | ||||
* | * | ||||
* * These are meant to be used in places that are run `a lot'. | * * These are meant to be used in places that are run `a lot'. | ||||
* It is wasteful to make predictions in code that is run | * It is wasteful to make predictions in code that is run | ||||
* seldomly (e.g. at subsystem initialization time) as the | * seldomly (e.g. at subsystem initialization time) as the | ||||
* basic block reordering that this affects can often generate | * basic block reordering that this affects can often generate | ||||
* larger code. | * larger code. | ||||
*/ | */ | ||||
#if __GNUC_PREREQ__(2, 96) | |||||
#define __predict_true(exp) __builtin_expect((exp), 1) | #define __predict_true(exp) __builtin_expect((exp), 1) | ||||
#define __predict_false(exp) __builtin_expect((exp), 0) | #define __predict_false(exp) __builtin_expect((exp), 0) | ||||
#else | |||||
#define __predict_true(exp) (exp) | |||||
#define __predict_false(exp) (exp) | |||||
#endif | |||||
#if __GNUC_PREREQ__(4, 0) | |||||
#define __null_sentinel __attribute__((__sentinel__)) | #define __null_sentinel __attribute__((__sentinel__)) | ||||
#define __exported __attribute__((__visibility__("default"))) | #define __exported __attribute__((__visibility__("default"))) | ||||
#define __hidden __attribute__((__visibility__("hidden"))) | #define __hidden __attribute__((__visibility__("hidden"))) | ||||
#else | |||||
#define __null_sentinel | |||||
#define __exported | |||||
#define __hidden | |||||
#endif | |||||
/* | /* | ||||
* We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h> | * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h> | ||||
* require it. | * require it. | ||||
*/ | */ | ||||
#if __GNUC_PREREQ__(4, 1) | |||||
#define __offsetof(type, field) __builtin_offsetof(type, field) | #define __offsetof(type, field) __builtin_offsetof(type, field) | ||||
#else | |||||
#ifndef __cplusplus | |||||
#define __offsetof(type, field) \ | |||||
((__size_t)(__uintptr_t)((const volatile void *)&((type *)0)->field)) | |||||
#else | |||||
#define __offsetof(type, field) \ | |||||
(__offsetof__ (reinterpret_cast <__size_t> \ | |||||
(&reinterpret_cast <const volatile char &> \ | |||||
(static_cast<type *> (0)->field)))) | |||||
#endif | |||||
#endif | |||||
#define __rangeof(type, start, end) \ | #define __rangeof(type, start, end) \ | ||||
(__offsetof(type, end) - __offsetof(type, start)) | (__offsetof(type, end) - __offsetof(type, start)) | ||||
/* | /* | ||||
* Given the pointer x to the member m of the struct s, return | * Given the pointer x to the member m of the struct s, return | ||||
* a pointer to the containing structure. When using GCC, we first | * a pointer to the containing structure. When using GCC, we first | ||||
* assign pointer x to a local variable, to check that its type is | * assign pointer x to a local variable, to check that its type is | ||||
* compatible with member m. | * compatible with member m. | ||||
*/ | */ | ||||
#if __GNUC_PREREQ__(3, 1) | |||||
#define __containerof(x, s, m) ({ \ | #define __containerof(x, s, m) ({ \ | ||||
const volatile __typeof(((s *)0)->m) *__x = (x); \ | const volatile __typeof(((s *)0)->m) *__x = (x); \ | ||||
__DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\ | __DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\ | ||||
}) | }) | ||||
#else | |||||
#define __containerof(x, s, m) \ | |||||
__DEQUALIFY(s *, (const volatile char *)(x) - __offsetof(s, m)) | |||||
#endif | |||||
/* | /* | ||||
* Compiler-dependent macros to declare that functions take printf-like | * Compiler-dependent macros to declare that functions take printf-like | ||||
* or scanf-like arguments. They are null except for versions of gcc | * or scanf-like arguments. They are null except for versions of gcc | ||||
* that are known to support the features properly (old versions of gcc-2 | * that are known to support the features properly (old versions of gcc-2 | ||||
* didn't permit keeping the keywords out of the application namespace). | * didn't permit keeping the keywords out of the application namespace). | ||||
*/ | */ | ||||
#if !__GNUC_PREREQ__(2, 7) | |||||
#define __printflike(fmtarg, firstvararg) | |||||
#define __scanflike(fmtarg, firstvararg) | |||||
#define __format_arg(fmtarg) | |||||
#define __strfmonlike(fmtarg, firstvararg) | |||||
#define __strftimelike(fmtarg, firstvararg) | |||||
#else | |||||
#define __printflike(fmtarg, firstvararg) \ | #define __printflike(fmtarg, firstvararg) \ | ||||
__attribute__((__format__ (__printf__, fmtarg, firstvararg))) | __attribute__((__format__ (__printf__, fmtarg, firstvararg))) | ||||
#define __scanflike(fmtarg, firstvararg) \ | #define __scanflike(fmtarg, firstvararg) \ | ||||
__attribute__((__format__ (__scanf__, fmtarg, firstvararg))) | __attribute__((__format__ (__scanf__, fmtarg, firstvararg))) | ||||
#define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg))) | #define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg))) | ||||
#define __strfmonlike(fmtarg, firstvararg) \ | #define __strfmonlike(fmtarg, firstvararg) \ | ||||
__attribute__((__format__ (__strfmon__, fmtarg, firstvararg))) | __attribute__((__format__ (__strfmon__, fmtarg, firstvararg))) | ||||
#define __strftimelike(fmtarg, firstvararg) \ | #define __strftimelike(fmtarg, firstvararg) \ | ||||
__attribute__((__format__ (__strftime__, fmtarg, firstvararg))) | __attribute__((__format__ (__strftime__, fmtarg, firstvararg))) | ||||
#endif | |||||
/* Compiler-dependent macros that rely on FreeBSD-specific extensions. */ | /* Compiler-dependent macros that rely on FreeBSD-specific extensions. */ | ||||
#define __printf0like(fmtarg, firstvararg) \ | #define __printf0like(fmtarg, firstvararg) \ | ||||
__attribute__((__format__ (__printf0__, fmtarg, firstvararg))) | __attribute__((__format__ (__printf0__, fmtarg, firstvararg))) | ||||
#define __strong_reference(sym,aliassym) \ | #define __strong_reference(sym,aliassym) \ | ||||
extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym))) | extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym))) | ||||
#ifdef __STDC__ | #ifdef __STDC__ | ||||
▲ Show 20 Lines • Show All 337 Lines • Show Last 20 Lines |
This one is almost killable too. Outside of ce(4), we use this in one location: i386 resumectx(). And it isn't clear (to me) that we need the oddball calling convention in that location. Maybe we do.