From: Joe Perches <joe@perches.com>
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>,
Luc Van Oostenryck <luc.vanoostenryck@gmail.com>,
linux-sparse@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
clang-built-linux <clang-built-linux@googlegroups.com>
Subject: [PATCH V2] compiler*.h: Add '__' prefix and suffix to all __attribute__ #defines
Date: Mon, 28 Oct 2019 11:17:43 -0700 [thread overview]
Message-ID: <07d3b90307f85267c7467fd329043a8790a2c332.camel@perches.com> (raw)
In-Reply-To: <19fd23e98bab65a1ee624445193bd2ed86108881.camel@perches.com>
To avoid macro name collisions and improve portability use a
double underscore prefix and suffix on all __attribute__ #defines.
There are __CHECKER__ exceptions to these uses of attribute types
because sparse as of version 0.6.1 and earlier do not recognize
a few __<type>__ attributes.
Signed-off-by: Joe Perches <joe@perches.com>
---
v2: Do not modify the __CHECKER__ attribute #defines
Add a comment describing why to the __CHECKER__ block.
include/linux/compiler-clang.h | 2 +-
include/linux/compiler-gcc.h | 10 +++++-----
include/linux/compiler_types.h | 11 ++++++++---
3 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
index 333a66..26d655f 100644
--- a/include/linux/compiler-clang.h
+++ b/include/linux/compiler-clang.h
@@ -19,7 +19,7 @@
/* emulate gcc's __SANITIZE_ADDRESS__ flag */
#define __SANITIZE_ADDRESS__
#define __no_sanitize_address \
- __attribute__((no_sanitize("address", "hwaddress")))
+ __attribute__((__no_sanitize__("address", "hwaddress")))
#else
#define __no_sanitize_address
#endif
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index d7ee4c..7a2dee 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -76,7 +76,7 @@
#define __compiletime_error(message) __attribute__((__error__(message)))
#if defined(LATENT_ENTROPY_PLUGIN) && !defined(__CHECKER__)
-#define __latent_entropy __attribute__((latent_entropy))
+#define __latent_entropy __attribute__((__latent_entropy__))
#endif
/*
@@ -101,8 +101,8 @@
} while (0)
#if defined(RANDSTRUCT_PLUGIN) && !defined(__CHECKER__)
-#define __randomize_layout __attribute__((randomize_layout))
-#define __no_randomize_layout __attribute__((no_randomize_layout))
+#define __randomize_layout __attribute__((__randomize_layout__))
+#define __no_randomize_layout __attribute__((__no_randomize_layout__))
/* This anon struct can add padding, so only enable it under randstruct. */
#define randomized_struct_fields_start struct {
#define randomized_struct_fields_end } __randomize_layout;
@@ -140,7 +140,7 @@
#endif
#if __has_attribute(__no_sanitize_address__)
-#define __no_sanitize_address __attribute__((no_sanitize_address))
+#define __no_sanitize_address __attribute__((__no_sanitize_address__))
#else
#define __no_sanitize_address
#endif
@@ -171,4 +171,4 @@
#define __diag_GCC_8(s)
#endif
-#define __no_fgcse __attribute__((optimize("-fno-gcse")))
+#define __no_fgcse __attribute__((__optimize__("-fno-gcse")))
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index 72393a..506b3a 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -5,6 +5,11 @@
#ifndef __ASSEMBLY__
#ifdef __CHECKER__
+/*
+ * sparse as of v0.6.1 does not understand several double underscore
+ * prefix and suffix forms of attribute types, so do not use them when
+ * sparse checking is enabled
+ */
# define __user __attribute__((noderef, address_space(1)))
# define __kernel __attribute__((address_space(0)))
# define __safe __attribute__((safe))
@@ -25,7 +30,7 @@ extern void __chk_io_ptr(const volatile void __iomem *);
# define ACCESS_PRIVATE(p, member) (*((typeof((p)->member) __force *) &(p)->member))
#else /* __CHECKER__ */
# ifdef STRUCTLEAK_PLUGIN
-# define __user __attribute__((user))
+# define __user __attribute__((__user__))
# else
# define __user
# endif
@@ -111,9 +116,9 @@ struct ftrace_likely_data {
#endif
#if defined(CC_USING_HOTPATCH)
-#define notrace __attribute__((hotpatch(0, 0)))
+#define notrace __attribute__((__hotpatch__(0, 0)))
#elif defined(CC_USING_PATCHABLE_FUNCTION_ENTRY)
-#define notrace __attribute__((patchable_function_entry(0, 0)))
+#define notrace __attribute__((__patchable_function_entry__(0, 0)))
#else
#define notrace __attribute__((__no_instrument_function__))
#endif
next prev parent reply other threads:[~2019-10-28 18:17 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-27 22:03 [PATCH] " Joe Perches
2019-10-28 16:12 ` Nick Desaulniers
2019-10-28 17:37 ` Miguel Ojeda
2019-10-28 17:59 ` Joe Perches
2019-10-28 18:17 ` Joe Perches [this message]
2019-10-28 22:15 ` Luc Van Oostenryck
2019-10-28 22:28 ` Joe Perches
2019-10-28 23:03 ` Luc Van Oostenryck
2019-10-29 2:38 ` Ramsay Jones
2019-10-29 8:07 ` Luc Van Oostenryck
2019-10-29 18:54 ` Ramsay Jones
2019-10-30 9:38 ` kbuild test robot
2019-10-30 13:45 ` kbuild test robot
2019-10-30 16:29 ` kbuild test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=07d3b90307f85267c7467fd329043a8790a2c332.camel@perches.com \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=clang-built-linux@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sparse@vger.kernel.org \
--cc=luc.vanoostenryck@gmail.com \
--cc=miguel.ojeda.sandonis@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®