uboot-oxnas: fix build with gcc-5
[openwrt/openwrt.git] / package / boot / uboot-oxnas / patches / 400-gcc-5-compiler.patch
1 From: Hans de Goede <hdegoede@redhat.com>
2 Date: Sat, 7 Feb 2015 21:52:40 +0000 (+0100)
3 Subject: Add linux/compiler-gcc5.h to fix builds with gcc5
4 X-Git-Tag: v2015.04-rc2~31
5 X-Git-Url: http://git.denx.de/?p=u-boot.git;a=commitdiff_plain;h=478b02f1a7043b673565075ea5016376f3293b23
6
7 Add linux/compiler-gcc5.h to fix builds with gcc5
8
9 Add linux/compiler-gcc5/h from the kernel sources at:
10
11 commit 5631b8fba640a4ab2f8a954f63a603fa34eda96b
12 Author: Steven Noonan <steven@uplinklabs.net>
13 Date: Sat Oct 25 15:09:42 2014 -0700
14
15 compiler/gcc4+: Remove inaccurate comment about 'asm goto' miscompiles
16
17 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
18 ---
19
20 --- /dev/null
21 +++ b/include/linux/compiler-gcc5.h
22 @@ -0,0 +1,65 @@
23 +#ifndef __LINUX_COMPILER_H
24 +#error "Please don't include <linux/compiler-gcc5.h> directly, include <linux/compiler.h> instead."
25 +#endif
26 +
27 +#define __used __attribute__((__used__))
28 +#define __must_check __attribute__((warn_unused_result))
29 +#define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
30 +
31 +/* Mark functions as cold. gcc will assume any path leading to a call
32 + to them will be unlikely. This means a lot of manual unlikely()s
33 + are unnecessary now for any paths leading to the usual suspects
34 + like BUG(), printk(), panic() etc. [but let's keep them for now for
35 + older compilers]
36 +
37 + Early snapshots of gcc 4.3 don't support this and we can't detect this
38 + in the preprocessor, but we can live with this because they're unreleased.
39 + Maketime probing would be overkill here.
40 +
41 + gcc also has a __attribute__((__hot__)) to move hot functions into
42 + a special section, but I don't see any sense in this right now in
43 + the kernel context */
44 +#define __cold __attribute__((__cold__))
45 +
46 +#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
47 +
48 +#ifndef __CHECKER__
49 +# define __compiletime_warning(message) __attribute__((warning(message)))
50 +# define __compiletime_error(message) __attribute__((error(message)))
51 +#endif /* __CHECKER__ */
52 +
53 +/*
54 + * Mark a position in code as unreachable. This can be used to
55 + * suppress control flow warnings after asm blocks that transfer
56 + * control elsewhere.
57 + *
58 + * Early snapshots of gcc 4.5 don't support this and we can't detect
59 + * this in the preprocessor, but we can live with this because they're
60 + * unreleased. Really, we need to have autoconf for the kernel.
61 + */
62 +#define unreachable() __builtin_unreachable()
63 +
64 +/* Mark a function definition as prohibited from being cloned. */
65 +#define __noclone __attribute__((__noclone__))
66 +
67 +/*
68 + * Tell the optimizer that something else uses this function or variable.
69 + */
70 +#define __visible __attribute__((externally_visible))
71 +
72 +/*
73 + * GCC 'asm goto' miscompiles certain code sequences:
74 + *
75 + * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
76 + *
77 + * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
78 + *
79 + * (asm goto is automatically volatile - the naming reflects this.)
80 + */
81 +#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
82 +
83 +#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
84 +#define __HAVE_BUILTIN_BSWAP32__
85 +#define __HAVE_BUILTIN_BSWAP64__
86 +#define __HAVE_BUILTIN_BSWAP16__
87 +#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */