102-compiler_gcc-prevent-redefining-attributes.patch 2.4 KB

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