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