aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/compiler-gcc.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/compiler-gcc.h')
-rw-r--r--include/linux/compiler-gcc.h29
1 files changed, 22 insertions, 7 deletions
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index fd282c7d3e5e..573f5a7d42d4 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -66,25 +66,40 @@
66#endif 66#endif
67 67
68/* 68/*
69 * Feature detection for gnu_inline (gnu89 extern inline semantics). Either
70 * __GNUC_STDC_INLINE__ is defined (not using gnu89 extern inline semantics,
71 * and we opt in to the gnu89 semantics), or __GNUC_STDC_INLINE__ is not
72 * defined so the gnu89 semantics are the default.
73 */
74#ifdef __GNUC_STDC_INLINE__
75# define __gnu_inline __attribute__((gnu_inline))
76#else
77# define __gnu_inline
78#endif
79
80/*
69 * Force always-inline if the user requests it so via the .config, 81 * Force always-inline if the user requests it so via the .config,
70 * or if gcc is too old. 82 * or if gcc is too old.
71 * GCC does not warn about unused static inline functions for 83 * GCC does not warn about unused static inline functions for
72 * -Wunused-function. This turns out to avoid the need for complex #ifdef 84 * -Wunused-function. This turns out to avoid the need for complex #ifdef
73 * directives. Suppress the warning in clang as well by using "unused" 85 * directives. Suppress the warning in clang as well by using "unused"
74 * function attribute, which is redundant but not harmful for gcc. 86 * function attribute, which is redundant but not harmful for gcc.
87 * Prefer gnu_inline, so that extern inline functions do not emit an
88 * externally visible function. This makes extern inline behave as per gnu89
89 * semantics rather than c99. This prevents multiple symbol definition errors
90 * of extern inline functions at link time.
91 * A lot of inline functions can cause havoc with function tracing.
75 */ 92 */
76#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \ 93#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \
77 !defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4) 94 !defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4)
78#define inline inline __attribute__((always_inline,unused)) notrace 95#define inline \
79#define __inline__ __inline__ __attribute__((always_inline,unused)) notrace 96 inline __attribute__((always_inline, unused)) notrace __gnu_inline
80#define __inline __inline __attribute__((always_inline,unused)) notrace
81#else 97#else
82/* A lot of inline functions can cause havoc with function tracing */ 98#define inline inline __attribute__((unused)) notrace __gnu_inline
83#define inline inline __attribute__((unused)) notrace
84#define __inline__ __inline__ __attribute__((unused)) notrace
85#define __inline __inline __attribute__((unused)) notrace
86#endif 99#endif
87 100
101#define __inline__ inline
102#define __inline inline
88#define __always_inline inline __attribute__((always_inline)) 103#define __always_inline inline __attribute__((always_inline))
89#define noinline __attribute__((noinline)) 104#define noinline __attribute__((noinline))
90 105