public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Compiler Attributes: move kernel-only attributes into __KERNEL__
@ 2018-11-28 14:08 Xiaozhou Liu
  2018-11-28 17:35 ` Miguel Ojeda
  0 siblings, 1 reply; 10+ messages in thread
From: Xiaozhou Liu @ 2018-11-28 14:08 UTC (permalink / raw)
  To: ndesaulniers@google.com, Miguel Ojeda, Luc Van Oostenryck,
	Paul Burton, Masahiro Yamada, Arnd Bergmann, linux-kernel
  Cc: Xiaozhou Liu

Attributes such as `__gnu_inline' are meant to be used within the
kernel. When userspace somehow includes <linux/compiler.h>
(eg. tools/bpf), compilation errors would be shown:

        "error: unknown type name ‘__gnu_inline’"

So just move these things into __KERNEL__ and the behavior is kept
as before.

Fixes: a3f8a30f3f00 ("Compiler Attributes: use feature checks instead of version checks")
Signed-off-by: Xiaozhou Liu <liuxiaozhou@bytedance.com>
---
 include/linux/compiler_types.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index 4a3f9c09c92d..2fb2c311e5d6 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -161,6 +161,8 @@ struct ftrace_likely_data {
 #define __diag_error(compiler, version, option, comment) \
 	__diag_ ## compiler(version, error, option)
 
+#ifdef __KERNEL__
+
 #ifdef CONFIG_ENABLE_MUST_CHECK
 #define __must_check		__attribute__((__warn_unused_result__))
 #else
@@ -215,4 +217,6 @@ struct ftrace_likely_data {
  */
 #define noinline_for_stack noinline
 
+#endif /* __KERNEL__ */
+
 #endif /* __LINUX_COMPILER_TYPES_H */
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-01-21 10:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-28 14:08 [PATCH] Compiler Attributes: move kernel-only attributes into __KERNEL__ Xiaozhou Liu
2018-11-28 17:35 ` Miguel Ojeda
2018-11-28 17:36   ` Miguel Ojeda
2018-11-29  2:16   ` Xiaozhou Liu
2018-11-29 10:42     ` Miguel Ojeda
2018-12-06 12:39       ` Xiaozhou Liu
2018-12-06 12:49         ` Greg KH
2019-01-19 18:22           ` Miguel Ojeda
2019-01-21 10:43             ` Greg KH
2018-12-04 21:21   ` Nick Desaulniers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox