1 From 0a5051ce6ebd5f6fad58fd50d6922493d8447f14 Mon Sep 17 00:00:00 2001
2 From: Jeroen Hofstee <jeroen@myspectrum.nl>
3 Date: Thu, 18 Sep 2014 20:10:27 +0200
4 Subject: compiler_gcc: prevent redefining attributes
6 The libc headers on FreeBSD and likely related projects as well contain an
7 header file, cdefs.h which provides similiar functionality as linux/compiler.h.
8 It provides compiler independent defines like __weak __packed, to allow
9 compiling with multiple compilers which might have a different syntax for such
12 Since that header file is included in multiple standard headers, like stddef.h
13 and stdarg.h, multiple definitions of those defines will be present if both are
14 included. When compiling u-boot the compiler will warn about it hundreds of
15 times since e.g. common.h will include both files indirectly.
17 commit 7ea50d52849fe8ffa5b5b74c979b60b1045d6fc9 "compiler_gcc: do not redefine
18 __gnu_attributes" prevented such redefinitions, but this was undone by commit
19 fb8ffd7cfc68b3dc44e182356a207d784cb30b34 "compiler*.h: sync
20 include/linux/compiler*.h with Linux 3.16".
22 Add the checks back where necessary to prevent such warnings.
24 As the original patch this checkpatch warning is ignored:
25 "WARNING: Adding new packed members is to be done with care"
27 Cc: Masahiro Yamada <yamada.m@jp.panasonic.com>
28 Cc: Tom Rini <trini@ti.com>
29 Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
30 Acked-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
32 include/linux/compiler-gcc.h | 10 ++++++++++
33 1 file changed, 10 insertions(+)
35 --- a/include/linux/compiler-gcc.h
36 +++ b/include/linux/compiler-gcc.h
40 #define __deprecated __attribute__((deprecated))
42 #define __packed __attribute__((packed))
45 #define __weak __attribute__((weak))
49 * it doesn't make sense on ARM (currently the only user of __naked) to trace
55 #define __pure __attribute__((pure))
58 #define __aligned(x) __attribute__((aligned(x)))
60 #define __printf(a, b) __attribute__((format(printf, a, b)))
61 #define __scanf(a, b) __attribute__((format(scanf, a, b)))
62 #define noinline __attribute__((noinline))
65 #define uninitialized_var(x) x = x
67 +#ifndef __always_inline
68 #define __always_inline inline __attribute__((always_inline))