|
65 | 65 | #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
|
66 | 66 | #endif
|
67 | 67 |
|
| 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 | + |
68 | 80 | /*
|
69 | 81 | * Force always-inline if the user requests it so via the .config,
|
70 | 82 | * or if gcc is too old.
|
71 | 83 | * GCC does not warn about unused static inline functions for
|
72 | 84 | * -Wunused-function. This turns out to avoid the need for complex #ifdef
|
73 | 85 | * directives. Suppress the warning in clang as well by using "unused"
|
74 | 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 | 93 | #if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \
|
77 | 94 | !defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4)
|
78 |
| -#define inline inline __attribute__((always_inline,unused)) notrace |
79 |
| -#define __inline__ __inline__ __attribute__((always_inline,unused)) notrace |
80 |
| -#define __inline __inline __attribute__((always_inline,unused)) notrace |
| 95 | +#define inline \ |
| 96 | + inline __attribute__((always_inline, unused)) notrace __gnu_inline |
81 | 97 | #else
|
82 |
| -/* A lot of inline functions can cause havoc with function tracing */ |
83 |
| -#define inline inline __attribute__((unused)) notrace |
84 |
| -#define __inline__ __inline__ __attribute__((unused)) notrace |
85 |
| -#define __inline __inline __attribute__((unused)) notrace |
| 98 | +#define inline inline __attribute__((unused)) notrace __gnu_inline |
86 | 99 | #endif
|
87 | 100 |
|
| 101 | +#define __inline__ inline |
| 102 | +#define __inline inline |
88 | 103 | #define __always_inline inline __attribute__((always_inline))
|
89 | 104 | #define noinline __attribute__((noinline))
|
90 | 105 |
|
|
0 commit comments