Merge tag 'compiler-attributes-for-linus-4.20-rc1' of https://github.com/ojeda/linux
[muen/linux.git] / include / linux / compiler.h
index 2e0b632..18c80cf 100644 (file)
@@ -99,22 +99,13 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
  * unique, to convince GCC not to merge duplicate inline asm statements.
  */
 #define annotate_reachable() ({                                                \
-       asm volatile("%c0:\n\t"                                         \
-                    ".pushsection .discard.reachable\n\t"              \
-                    ".long %c0b - .\n\t"                               \
-                    ".popsection\n\t" : : "i" (__COUNTER__));          \
+       asm volatile("ANNOTATE_REACHABLE counter=%c0"                   \
+                    : : "i" (__COUNTER__));                            \
 })
 #define annotate_unreachable() ({                                      \
-       asm volatile("%c0:\n\t"                                         \
-                    ".pushsection .discard.unreachable\n\t"            \
-                    ".long %c0b - .\n\t"                               \
-                    ".popsection\n\t" : : "i" (__COUNTER__));          \
+       asm volatile("ANNOTATE_UNREACHABLE counter=%c0"                 \
+                    : : "i" (__COUNTER__));                            \
 })
-#define ASM_UNREACHABLE                                                        \
-       "999:\n\t"                                                      \
-       ".pushsection .discard.unreachable\n\t"                         \
-       ".long 999b - .\n\t"                                            \
-       ".popsection\n\t"
 #else
 #define annotate_reachable()
 #define annotate_unreachable()
@@ -302,6 +293,45 @@ static inline void *offset_to_ptr(const int *off)
        return (void *)((unsigned long)off + *off);
 }
 
+#else /* __ASSEMBLY__ */
+
+#ifdef __KERNEL__
+#ifndef LINKER_SCRIPT
+
+#ifdef CONFIG_STACK_VALIDATION
+.macro ANNOTATE_UNREACHABLE counter:req
+\counter:
+       .pushsection .discard.unreachable
+       .long \counter\()b -.
+       .popsection
+.endm
+
+.macro ANNOTATE_REACHABLE counter:req
+\counter:
+       .pushsection .discard.reachable
+       .long \counter\()b -.
+       .popsection
+.endm
+
+.macro ASM_UNREACHABLE
+999:
+       .pushsection .discard.unreachable
+       .long 999b - .
+       .popsection
+.endm
+#else /* CONFIG_STACK_VALIDATION */
+.macro ANNOTATE_UNREACHABLE counter:req
+.endm
+
+.macro ANNOTATE_REACHABLE counter:req
+.endm
+
+.macro ASM_UNREACHABLE
+.endm
+#endif /* CONFIG_STACK_VALIDATION */
+
+#endif /* LINKER_SCRIPT */
+#endif /* __KERNEL__ */
 #endif /* __ASSEMBLY__ */
 
 /* Compile time object size, -1 for unknown */
@@ -313,29 +343,14 @@ static inline void *offset_to_ptr(const int *off)
 #endif
 #ifndef __compiletime_error
 # define __compiletime_error(message)
-/*
- * Sparse complains of variable sized arrays due to the temporary variable in
- * __compiletime_assert. Unfortunately we can't just expand it out to make
- * sparse see a constant array size without breaking compiletime_assert on old
- * versions of GCC (e.g. 4.2.4), so hide the array from sparse altogether.
- */
-# ifndef __CHECKER__
-#  define __compiletime_error_fallback(condition) \
-       do { ((void)sizeof(char[1 - 2 * condition])); } while (0)
-# endif
-#endif
-#ifndef __compiletime_error_fallback
-# define __compiletime_error_fallback(condition) do { } while (0)
 #endif
 
 #ifdef __OPTIMIZE__
 # define __compiletime_assert(condition, msg, prefix, suffix)          \
        do {                                                            \
-               int __cond = !(condition);                              \
                extern void prefix ## suffix(void) __compiletime_error(msg); \
-               if (__cond)                                             \
+               if (!(condition))                                       \
                        prefix ## suffix();                             \
-               __compiletime_error_fallback(__cond);                   \
        } while (0)
 #else
 # define __compiletime_assert(condition, msg, prefix, suffix) do { } while (0)