~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/compiler-gcc.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/linux/compiler-gcc.h (Version linux-6.12-rc7) and /include/linux/compiler-gcc.h (Version linux-5.2.21)


  1 /* SPDX-License-Identifier: GPL-2.0 */              1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef __LINUX_COMPILER_TYPES_H                    2 #ifndef __LINUX_COMPILER_TYPES_H
  3 #error "Please don't include <linux/compiler-g      3 #error "Please don't include <linux/compiler-gcc.h> directly, include <linux/compiler.h> instead."
  4 #endif                                              4 #endif
  5                                                     5 
  6 /*                                                  6 /*
  7  * Common definitions for all gcc versions go       7  * Common definitions for all gcc versions go here.
  8  */                                                 8  */
  9 #define GCC_VERSION (__GNUC__ * 10000               9 #define GCC_VERSION (__GNUC__ * 10000           \
 10                      + __GNUC_MINOR__ * 100        10                      + __GNUC_MINOR__ * 100     \
 11                      + __GNUC_PATCHLEVEL__)        11                      + __GNUC_PATCHLEVEL__)
 12                                                    12 
                                                   >>  13 #if GCC_VERSION < 40600
                                                   >>  14 # error Sorry, your compiler is too old - please upgrade it.
                                                   >>  15 #endif
                                                   >>  16 
                                                   >>  17 /* Optimization barrier */
                                                   >>  18 
                                                   >>  19 /* The "volatile" is due to gcc bugs */
                                                   >>  20 #define barrier() __asm__ __volatile__("": : :"memory")
                                                   >>  21 /*
                                                   >>  22  * This version is i.e. to prevent dead stores elimination on @ptr
                                                   >>  23  * where gcc and llvm may behave differently when otherwise using
                                                   >>  24  * normal barrier(): while gcc behavior gets along with a normal
                                                   >>  25  * barrier(), llvm needs an explicit input variable to be assumed
                                                   >>  26  * clobbered. The issue is as follows: while the inline asm might
                                                   >>  27  * access any memory it wants, the compiler could have fit all of
                                                   >>  28  * @ptr into memory registers instead, and since @ptr never escaped
                                                   >>  29  * from that, it proved that the inline asm wasn't touching any of
                                                   >>  30  * it. This version works well with both compilers, i.e. we're telling
                                                   >>  31  * the compiler that the inline asm absolutely may see the contents
                                                   >>  32  * of @ptr. See also: https://llvm.org/bugs/show_bug.cgi?id=15495
                                                   >>  33  */
                                                   >>  34 #define barrier_data(ptr) __asm__ __volatile__("": :"r"(ptr) :"memory")
                                                   >>  35 
 13 /*                                                 36 /*
 14  * This macro obfuscates arithmetic on a varia     37  * This macro obfuscates arithmetic on a variable address so that gcc
 15  * shouldn't recognize the original var, and m     38  * shouldn't recognize the original var, and make assumptions about it.
 16  *                                                 39  *
 17  * This is needed because the C standard makes     40  * This is needed because the C standard makes it undefined to do
 18  * pointer arithmetic on "objects" outside the     41  * pointer arithmetic on "objects" outside their boundaries and the
 19  * gcc optimizers assume this is the case. In      42  * gcc optimizers assume this is the case. In particular they
 20  * assume such arithmetic does not wrap.           43  * assume such arithmetic does not wrap.
 21  *                                                 44  *
 22  * A miscompilation has been observed because      45  * A miscompilation has been observed because of this on PPC.
 23  * To work around it we hide the relationship      46  * To work around it we hide the relationship of the pointer and the object
 24  * using this macro.                               47  * using this macro.
 25  *                                                 48  *
 26  * Versions of the ppc64 compiler before 4.1 h     49  * Versions of the ppc64 compiler before 4.1 had a bug where use of
 27  * RELOC_HIDE could trash r30. The bug can be      50  * RELOC_HIDE could trash r30. The bug can be worked around by changing
 28  * the inline assembly constraint from =g to =     51  * the inline assembly constraint from =g to =r, in this particular
 29  * case either is valid.                           52  * case either is valid.
 30  */                                                53  */
 31 #define RELOC_HIDE(ptr, off)                       54 #define RELOC_HIDE(ptr, off)                                            \
 32 ({                                                 55 ({                                                                      \
 33         unsigned long __ptr;                       56         unsigned long __ptr;                                            \
 34         __asm__ ("" : "=r"(__ptr) : ""(ptr));      57         __asm__ ("" : "=r"(__ptr) : ""(ptr));                          \
 35         (typeof(ptr)) (__ptr + (off));             58         (typeof(ptr)) (__ptr + (off));                                  \
 36 })                                                 59 })
 37                                                    60 
 38 #ifdef CONFIG_MITIGATION_RETPOLINE             !!  61 /*
                                                   >>  62  * A trick to suppress uninitialized variable warning without generating any
                                                   >>  63  * code
                                                   >>  64  */
                                                   >>  65 #define uninitialized_var(x) x = x
                                                   >>  66 
                                                   >>  67 #ifdef CONFIG_RETPOLINE
 39 #define __noretpoline __attribute__((__indirec     68 #define __noretpoline __attribute__((__indirect_branch__("keep")))
 40 #endif                                             69 #endif
 41                                                    70 
                                                   >>  71 #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
                                                   >>  72 
                                                   >>  73 #define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
                                                   >>  74 
                                                   >>  75 #define __compiletime_warning(message) __attribute__((__warning__(message)))
                                                   >>  76 #define __compiletime_error(message) __attribute__((__error__(message)))
                                                   >>  77 
 42 #if defined(LATENT_ENTROPY_PLUGIN) && !defined     78 #if defined(LATENT_ENTROPY_PLUGIN) && !defined(__CHECKER__)
 43 #define __latent_entropy __attribute__((latent     79 #define __latent_entropy __attribute__((latent_entropy))
 44 #endif                                             80 #endif
 45                                                    81 
 46 /*                                                 82 /*
 47  * calling noreturn functions, __builtin_unrea     83  * calling noreturn functions, __builtin_unreachable() and __builtin_trap()
 48  * confuse the stack allocation in gcc, leadin     84  * confuse the stack allocation in gcc, leading to overly large stack
 49  * frames, see https://gcc.gnu.org/bugzilla/sh     85  * frames, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82365
 50  *                                                 86  *
 51  * Adding an empty inline assembly before it w     87  * Adding an empty inline assembly before it works around the problem
 52  */                                                88  */
 53 #define barrier_before_unreachable() asm volat     89 #define barrier_before_unreachable() asm volatile("")
 54                                                    90 
 55 /*                                                 91 /*
 56  * Mark a position in code as unreachable.  Th     92  * Mark a position in code as unreachable.  This can be used to
 57  * suppress control flow warnings after asm bl     93  * suppress control flow warnings after asm blocks that transfer
 58  * control elsewhere.                              94  * control elsewhere.
 59  */                                                95  */
 60 #define unreachable() \                            96 #define unreachable() \
 61         do {                                       97         do {                                    \
 62                 annotate_unreachable();            98                 annotate_unreachable();         \
 63                 barrier_before_unreachable();      99                 barrier_before_unreachable();   \
 64                 __builtin_unreachable();          100                 __builtin_unreachable();        \
 65         } while (0)                               101         } while (0)
 66                                                   102 
 67 #if defined(CONFIG_ARCH_USE_BUILTIN_BSWAP)     !! 103 #if defined(RANDSTRUCT_PLUGIN) && !defined(__CHECKER__)
                                                   >> 104 #define __randomize_layout __attribute__((randomize_layout))
                                                   >> 105 #define __no_randomize_layout __attribute__((no_randomize_layout))
                                                   >> 106 /* This anon struct can add padding, so only enable it under randstruct. */
                                                   >> 107 #define randomized_struct_fields_start  struct {
                                                   >> 108 #define randomized_struct_fields_end    } __randomize_layout;
                                                   >> 109 #endif
                                                   >> 110 
                                                   >> 111 /*
                                                   >> 112  * GCC 'asm goto' miscompiles certain code sequences:
                                                   >> 113  *
                                                   >> 114  *   http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
                                                   >> 115  *
                                                   >> 116  * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
                                                   >> 117  *
                                                   >> 118  * (asm goto is automatically volatile - the naming reflects this.)
                                                   >> 119  */
                                                   >> 120 #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
                                                   >> 121 
                                                   >> 122 /*
                                                   >> 123  * sparse (__CHECKER__) pretends to be gcc, but can't do constant
                                                   >> 124  * folding in __builtin_bswap*() (yet), so don't set these for it.
                                                   >> 125  */
                                                   >> 126 #if defined(CONFIG_ARCH_USE_BUILTIN_BSWAP) && !defined(__CHECKER__)
 68 #define __HAVE_BUILTIN_BSWAP32__                  127 #define __HAVE_BUILTIN_BSWAP32__
 69 #define __HAVE_BUILTIN_BSWAP64__                  128 #define __HAVE_BUILTIN_BSWAP64__
                                                   >> 129 #if GCC_VERSION >= 40800
 70 #define __HAVE_BUILTIN_BSWAP16__                  130 #define __HAVE_BUILTIN_BSWAP16__
 71 #endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */     !! 131 #endif
                                                   >> 132 #endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP && !__CHECKER__ */
 72                                                   133 
 73 #if GCC_VERSION >= 70000                          134 #if GCC_VERSION >= 70000
 74 #define KASAN_ABI_VERSION 5                       135 #define KASAN_ABI_VERSION 5
 75 #else                                          !! 136 #elif GCC_VERSION >= 50000
 76 #define KASAN_ABI_VERSION 4                       137 #define KASAN_ABI_VERSION 4
                                                   >> 138 #elif GCC_VERSION >= 40902
                                                   >> 139 #define KASAN_ABI_VERSION 3
 77 #endif                                            140 #endif
 78                                                   141 
 79 #ifdef CONFIG_SHADOW_CALL_STACK                !! 142 #if __has_attribute(__no_sanitize_address__)
 80 #define __noscs __attribute__((__no_sanitize__ !! 143 #define __no_sanitize_address __attribute__((no_sanitize_address))
 81 #endif                                         << 
 82                                                << 
 83 #ifdef __SANITIZE_HWADDRESS__                  << 
 84 #define __no_sanitize_address __attribute__((_ << 
 85 #else                                          << 
 86 #define __no_sanitize_address __attribute__((_ << 
 87 #endif                                         << 
 88                                                << 
 89 #if defined(__SANITIZE_THREAD__)               << 
 90 #define __no_sanitize_thread __attribute__((__ << 
 91 #else                                          << 
 92 #define __no_sanitize_thread                   << 
 93 #endif                                         << 
 94                                                << 
 95 #define __no_sanitize_undefined __attribute__( << 
 96                                                << 
 97 /*                                             << 
 98  * Only supported since gcc >= 12              << 
 99  */                                            << 
100 #if defined(CONFIG_KCOV) && __has_attribute(__ << 
101 #define __no_sanitize_coverage __attribute__(( << 
102 #else                                             144 #else
103 #define __no_sanitize_coverage                 !! 145 #define __no_sanitize_address
104 #endif                                            146 #endif
105                                                   147 
106 /*                                             !! 148 #if GCC_VERSION >= 50100
107  * Treat __SANITIZE_HWADDRESS__ the same as __ !! 149 #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
108  * matching the defines used by Clang.         << 
109  */                                            << 
110 #ifdef __SANITIZE_HWADDRESS__                  << 
111 #define __SANITIZE_ADDRESS__                   << 
112 #endif                                            150 #endif
113                                                   151 
114 /*                                                152 /*
115  * GCC does not support KMSAN.                 << 
116  */                                            << 
117 #define __no_sanitize_memory                   << 
118 #define __no_kmsan_checks                      << 
119                                                << 
120 /*                                             << 
121  * Turn individual warnings and errors on and     153  * Turn individual warnings and errors on and off locally, depending
122  * on version.                                    154  * on version.
123  */                                               155  */
124 #define __diag_GCC(version, severity, s) \        156 #define __diag_GCC(version, severity, s) \
125         __diag_GCC_ ## version(__diag_GCC_ ##     157         __diag_GCC_ ## version(__diag_GCC_ ## severity s)
126                                                   158 
127 /* Severity used in pragma directives */          159 /* Severity used in pragma directives */
128 #define __diag_GCC_ignore       ignored           160 #define __diag_GCC_ignore       ignored
129 #define __diag_GCC_warn         warning           161 #define __diag_GCC_warn         warning
130 #define __diag_GCC_error        error             162 #define __diag_GCC_error        error
131                                                   163 
132 #define __diag_str1(s)          #s                164 #define __diag_str1(s)          #s
133 #define __diag_str(s)           __diag_str1(s)    165 #define __diag_str(s)           __diag_str1(s)
134 #define __diag(s)               _Pragma(__diag    166 #define __diag(s)               _Pragma(__diag_str(GCC diagnostic s))
135                                                   167 
136 #if GCC_VERSION >= 80000                          168 #if GCC_VERSION >= 80000
137 #define __diag_GCC_8(s)         __diag(s)         169 #define __diag_GCC_8(s)         __diag(s)
138 #else                                             170 #else
139 #define __diag_GCC_8(s)                           171 #define __diag_GCC_8(s)
140 #endif                                            172 #endif
141                                                   173 
142 #define __diag_ignore_all(option, comment) \   !! 174 #define __no_fgcse __attribute__((optimize("-fno-gcse")))
143         __diag(__diag_GCC_ignore option)       << 
144                                                << 
145 /*                                             << 
146  * Prior to 9.1, -Wno-alloc-size-larger-than ( << 
147  * attribute) do not work, and must be disable << 
148  */                                            << 
149 #if GCC_VERSION < 90100                        << 
150 #undef __alloc_size__                          << 
151 #endif                                         << 
152                                                   175 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php