linux: update to 6.10.x, 6.9.x is EOL
[openadk.git] / target / linux / patches / e7c8afc1dda7b7c18596d90ad6a17ae886650b72 / new-gcc.patch
blobfbee590f54acdb09ce6e5df7d3252e15917b8a24
1 diff -Nur linux-e7c8afc1dda7b7c18596d90ad6a17ae886650b72.orig/include/linux/compiler-gcc.h linux-e7c8afc1dda7b7c18596d90ad6a17ae886650b72/include/linux/compiler-gcc.h
2 --- linux-e7c8afc1dda7b7c18596d90ad6a17ae886650b72.orig/include/linux/compiler-gcc.h 2017-09-27 03:56:44.000000000 +0200
3 +++ linux-e7c8afc1dda7b7c18596d90ad6a17ae886650b72/include/linux/compiler-gcc.h 2017-09-27 04:18:30.590990967 +0200
4 @@ -6,6 +6,10 @@
5 * Common definitions for all gcc versions go here.
6 */
8 +#define GCC_VERSION (__GNUC__ * 10000 \
9 + + __GNUC_MINOR__ * 100 \
10 + + __GNUC_PATCHLEVEL__)
13 /* Optimization barrier */
14 /* The "volatile" is due to gcc bugs */
15 @@ -81,7 +85,164 @@
16 #define __maybe_unused __attribute__((unused))
17 #define __always_unused __attribute__((unused))
19 -#define __gcc_header(x) #x
20 -#define _gcc_header(x) __gcc_header(linux/compiler-gcc##x.h)
21 -#define gcc_header(x) _gcc_header(x)
22 -#include gcc_header(__GNUC__)
23 +/* gcc version specific checks */
25 +#if GCC_VERSION < 30200
26 +# error Sorry, your compiler is too old - please upgrade it.
27 +#endif
29 +#if GCC_VERSION < 30300
30 +# define __used __attribute__((__unused__))
31 +#else
32 +# define __used __attribute__((__used__))
33 +#endif
35 +#ifdef CONFIG_GCOV_KERNEL
36 +# if GCC_VERSION < 30400
37 +# error "GCOV profiling support for gcc versions below 3.4 not included"
38 +# endif /* __GNUC_MINOR__ */
39 +#endif /* CONFIG_GCOV_KERNEL */
41 +#if GCC_VERSION >= 30400
42 +#define __must_check __attribute__((warn_unused_result))
43 +#endif
45 +#if GCC_VERSION >= 40000
47 +/* GCC 4.1.[01] miscompiles __weak */
48 +#ifdef __KERNEL__
49 +# if GCC_VERSION >= 40100 && GCC_VERSION <= 40101
50 +# error Your version of gcc miscompiles the __weak directive
51 +# endif
52 +#endif
54 +#define __used __attribute__((__used__))
55 +#define __compiler_offsetof(a, b) \
56 + __builtin_offsetof(a, b)
58 +#if GCC_VERSION >= 40100 && GCC_VERSION < 40600
59 +# define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
60 +#endif
62 +#if GCC_VERSION >= 40300
63 +/* Mark functions as cold. gcc will assume any path leading to a call
64 + * to them will be unlikely. This means a lot of manual unlikely()s
65 + * are unnecessary now for any paths leading to the usual suspects
66 + * like BUG(), printk(), panic() etc. [but let's keep them for now for
67 + * older compilers]
68 + *
69 + * Early snapshots of gcc 4.3 don't support this and we can't detect this
70 + * in the preprocessor, but we can live with this because they're unreleased.
71 + * Maketime probing would be overkill here.
72 + *
73 + * gcc also has a __attribute__((__hot__)) to move hot functions into
74 + * a special section, but I don't see any sense in this right now in
75 + * the kernel context
76 + */
77 +#define __cold __attribute__((__cold__))
79 +#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
81 +#ifndef __CHECKER__
82 +# define __compiletime_warning(message) __attribute__((warning(message)))
83 +# define __compiletime_error(message) __attribute__((error(message)))
84 +#endif /* __CHECKER__ */
85 +#endif /* GCC_VERSION >= 40300 */
87 +#if GCC_VERSION >= 40500
88 +/*
89 + * Mark a position in code as unreachable. This can be used to
90 + * suppress control flow warnings after asm blocks that transfer
91 + * control elsewhere.
92 + *
93 + * Early snapshots of gcc 4.5 don't support this and we can't detect
94 + * this in the preprocessor, but we can live with this because they're
95 + * unreleased. Really, we need to have autoconf for the kernel.
96 + */
97 +#define unreachable() __builtin_unreachable()
99 +/* Mark a function definition as prohibited from being cloned. */
100 +#define __noclone __attribute__((__noclone__, __optimize__("no-tracer")))
102 +#endif /* GCC_VERSION >= 40500 */
104 +#if GCC_VERSION >= 40600
106 + * When used with Link Time Optimization, gcc can optimize away C functions or
107 + * variables which are referenced only from assembly code. __visible tells the
108 + * optimizer that something else uses this function or variable, thus preventing
109 + * this.
110 + */
111 +#define __visible __attribute__((externally_visible))
112 +#endif
115 +#if GCC_VERSION >= 40900 && !defined(__CHECKER__)
117 + * __assume_aligned(n, k): Tell the optimizer that the returned
118 + * pointer can be assumed to be k modulo n. The second argument is
119 + * optional (default 0), so we use a variadic macro to make the
120 + * shorthand.
122 + * Beware: Do not apply this to functions which may return
123 + * ERR_PTRs. Also, it is probably unwise to apply it to functions
124 + * returning extra information in the low bits (but in that case the
125 + * compiler should see some alignment anyway, when the return value is
126 + * massaged by 'flags = ptr & 3; ptr &= ~3;').
127 + */
128 +#define __assume_aligned(a, ...) __attribute__((__assume_aligned__(a, ## __VA_ARGS__)))
129 +#endif
132 + * GCC 'asm goto' miscompiles certain code sequences:
134 + * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
136 + * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
138 + * (asm goto is automatically volatile - the naming reflects this.)
139 + */
140 +#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
142 +#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
143 +#if GCC_VERSION >= 40400
144 +#define __HAVE_BUILTIN_BSWAP32__
145 +#define __HAVE_BUILTIN_BSWAP64__
146 +#endif
147 +#if GCC_VERSION >= 40800 || (defined(__powerpc__) && GCC_VERSION >= 40600)
148 +#define __HAVE_BUILTIN_BSWAP16__
149 +#endif
150 +#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
152 +#if GCC_VERSION >= 70000
153 +#define KASAN_ABI_VERSION 5
154 +#elif GCC_VERSION >= 50000
155 +#define KASAN_ABI_VERSION 4
156 +#elif GCC_VERSION >= 40902
157 +#define KASAN_ABI_VERSION 3
158 +#endif
160 +#if GCC_VERSION >= 40902
162 + * Tell the compiler that address safety instrumentation (KASAN)
163 + * should not be applied to that function.
164 + * Conflicts with inlining: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368
165 + */
166 +#define __no_sanitize_address __attribute__((no_sanitize_address))
167 +#endif
169 +#endif /* gcc version >= 40000 specific checks */
171 +#if !defined(__noclone)
172 +#define __noclone /* not needed */
173 +#endif
175 +#if !defined(__no_sanitize_address)
176 +#define __no_sanitize_address
177 +#endif
180 + * A trick to suppress uninitialized variable warning without generating any
181 + * code
182 + */
183 +#define uninitialized_var(x) x = x