Skip to contentSkip to conversation

Sync compiler*.h with Linux 3.16

PATCH New Masahiro Yamada 2 participants 5 messages Sep 3, 2014 – Sep 17, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Sync compiler*.h with Linux 3.16

Masahiro Yamada (2):
compiler*.h: sync include/linux/compiler*.h with Linux 3.16
standalone: use GCC_VERSION defined in compiler-gcc.h

 examples/standalone/stubs.c    |  7 +---
 include/linux/compiler-clang.h | 12 ++++++
 include/linux/compiler-gcc.h   | 57 ++++++++++++++++++--------
 include/linux/compiler-gcc3.h  | 20 ++++-----
 include/linux/compiler-gcc4.h  | 59 +++++++++++++++++++--------
 include/linux/compiler-intel.h | 40 ++++++++++++++++++
 include/linux/compiler.h       | 92 +++++++++++++++++++++++++++++++++++++++++-
 7 files changed, 238 insertions(+), 49 deletions(-)
 create mode 100644 include/linux/compiler-clang.h
 create mode 100644 include/linux/compiler-intel.h
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/2 compiler*.h: sync include/linux/compiler*.h with Linux 3.16

Copy them from Linux v3.16 tag.
My main motivation of this commit is to add compiler-clang.h.

---

I built all the supported board and compared MD5SUM. I confirmed this patch does not change the produced binaries.

 include/linux/compiler-clang.h | 12 ++++++
 include/linux/compiler-gcc.h   | 57 ++++++++++++++++++--------
 include/linux/compiler-gcc3.h  | 20 ++++-----
 include/linux/compiler-gcc4.h  | 59 +++++++++++++++++++--------
 include/linux/compiler-intel.h | 40 ++++++++++++++++++
 include/linux/compiler.h       | 92 +++++++++++++++++++++++++++++++++++++++++-
 6 files changed, 236 insertions(+), 44 deletions(-)
 create mode 100644 include/linux/compiler-clang.h
 create mode 100644 include/linux/compiler-intel.h
include/linux/compiler-clang.h new file +12 -0
new file mode 100644
index 0000000..d1e49d5
@@ -0,0 +1,12 @@
+#ifndef __LINUX_COMPILER_H
+#error "Please don't include <linux/compiler-clang.h> directly, include <linux/compiler.h> instead."
+#endif
+
+/* Some compiler specific definitions are overwritten here
+ * for Clang compiler
+ */
+
+#ifdef uninitialized_var
+#undef uninitialized_var
+#define uninitialized_var(x) x = *(&(x))
+#endif
include/linux/compiler-gcc.h +41 -16

95 lines not on this page · raw message

include/linux/compiler-gcc3.h +11 -9
index 2befe65..7d89feb 100644
@@ -2,20 +2,22 @@
 #error "Please don't include <linux/compiler-gcc3.h> directly, include <linux/compiler.h> instead."
 #endif
 
-#if __GNUC_MINOR__ >= 3
+#if GCC_VERSION < 30200
+# error Sorry, your compiler is too old - please upgrade it.
+#endif
+
+#if GCC_VERSION >= 30300
 # define __used			__attribute__((__used__))
 #else
 # define __used			__attribute__((__unused__))
 #endif
 
-#if __GNUC_MINOR__ >= 4
+#if GCC_VERSION >= 30400
 #define __must_check		__attribute__((warn_unused_result))
 #endif
 
-/*
- * A trick to suppress uninitialized variable warning without generating any
- * code
- */
-#define uninitialized_var(x) x = x
-
-#define __always_inline		inline __attribute__((always_inline))
+#ifdef CONFIG_GCOV_KERNEL
+# if GCC_VERSION < 30400
+#   error "GCOV profiling support for gcc versions below 3.4 not included"
+# endif /* __GNUC_MINOR__ */
+#endif /* CONFIG_GCOV_KERNEL */
include/linux/compiler-gcc4.h +42 -17

88 lines not on this page · raw message

include/linux/compiler-intel.h new file +40 -0
new file mode 100644
index 0000000..ba147a1
@@ -0,0 +1,40 @@
+#ifndef __LINUX_COMPILER_H
+#error "Please don't include <linux/compiler-intel.h> directly, include <linux/compiler.h> instead."
+#endif
+
+#ifdef __ECC
+
+/* Some compiler specific definitions are overwritten here
+ * for Intel ECC compiler
+ */
+
+#include <asm/intrinsics.h>
+
+/* Intel ECC compiler doesn't support gcc specific asm stmts.
+ * It uses intrinsics to do the equivalent things.
+ */
+#undef RELOC_HIDE
+#undef OPTIMIZER_HIDE_VAR
+
+#define RELOC_HIDE(ptr, off)					\
+  ({ unsigned long __ptr;					\
+     __ptr = (unsigned long) (ptr);				\
+    (typeof(ptr)) (__ptr + (off)); })
+
+/* This should act as an optimization barrier on var.
+ * Given that this compiler does not have inline assembly, a compiler barrier
+ * is the best we can do.
+ */
+#define OPTIMIZER_HIDE_VAR(var) barrier()
+
+/* Intel ECC compiler doesn't support __builtin_types_compatible_p() */
+#define __must_be_array(a) 0
+
+#endif
+
+#ifndef __HAVE_BUILTIN_BSWAP16__
+/* icc has this, but it's called _bswap16 */
+#define __HAVE_BUILTIN_BSWAP16__
+#define __builtin_bswap16 _bswap16
+#endif
+
include/linux/compiler.h +90 -2

161 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

PATCH 1/2 compiler*.h: sync include/linux/compiler*.h with Linux 3.16

Quoted 5 lines · Masahiro Yamada

Copy them from Linux v3.16 tag.
My main motivation of this commit is to add compiler-clang.h.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140916/b67e23a6/attachment.pgp>
#3 lore raw

PATCH 2/2 standalone: use GCC_VERSION defined in compiler-gcc.h

In reply to Masahiro Yamada

Now GCC_VERSION is defined in include/linux/compiler-gcc.h (with a little different definition).
Use it and delete the one in examples/standlone/stub.c.

This should work on Clang too because __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__ are also defined on Clang.

---

 examples/standalone/stubs.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
examples/standalone/stubs.c +2 -5
index c5c025d..0bf690e 100644
@@ -1,9 +1,6 @@
 #include <common.h>
 #include <exports.h>
-
-#ifndef GCC_VERSION
-#define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
-#endif /* GCC_VERSION */
+#include <linux/compiler.h>
 
 #if defined(CONFIG_X86)
 /*
@@ -237,7 +234,7 @@ gd_t *global_data;
  * implementation. On the other hand, asm() statements with
  * arguments can be used only inside the functions (gcc limitation)
  */
-#if GCC_VERSION < 3004
+#if GCC_VERSION < 30400
 static
 #endif /* GCC_VERSION */
 void __attribute__((unused)) dummy(void)
Signature · 1 line
1.9.1
#4 lore raw

PATCH 2/2 standalone: use GCC_VERSION defined in compiler-gcc.h

Quoted 9 lines · Masahiro Yamada

Now GCC_VERSION is defined in include/linux/compiler-gcc.h (with a little different definition).
Use it and delete the one in examples/standlone/stub.c.

This should work on Clang too because __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__ are also defined on Clang.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140916/c88fc4ed/attachment.pgp>