linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] compiler*.h: Add '__' prefix and suffix to all __attribute__ #defines
@ 2019-10-27 22:03 Joe Perches
  2019-10-28 16:12 ` Nick Desaulniers
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Joe Perches @ 2019-10-27 22:03 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, clang-built-linux

To avoid macro name collisions and improve portability use a
double underscore prefix and suffix on all __attribute__ #defines.

Before this patch, 33 of 56 #defines used a form like:

	'#define __<type> __attribute__((__<attribute_name>__))'

Now all __attribute__ #defines use that form.

Signed-off-by: Joe Perches <joe@perches.com>
---
 include/linux/compiler-clang.h |  2 +-
 include/linux/compiler-gcc.h   | 10 +++++-----
 include/linux/compiler_types.h | 34 +++++++++++++++++-----------------
 3 files changed, 23 insertions(+), 23 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..b8c2145 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -5,27 +5,27 @@
 #ifndef __ASSEMBLY__
 
 #ifdef __CHECKER__
-# define __user		__attribute__((noderef, address_space(1)))
-# define __kernel	__attribute__((address_space(0)))
-# define __safe		__attribute__((safe))
-# define __force	__attribute__((force))
-# define __nocast	__attribute__((nocast))
-# define __iomem	__attribute__((noderef, address_space(2)))
-# define __must_hold(x)	__attribute__((context(x,1,1)))
-# define __acquires(x)	__attribute__((context(x,0,1)))
-# define __releases(x)	__attribute__((context(x,1,0)))
-# define __acquire(x)	__context__(x,1)
-# define __release(x)	__context__(x,-1)
+# define __user		__attribute__((__noderef__, __address_space__(1)))
+# define __kernel	__attribute__((__address_space__(0)))
+# define __safe		__attribute__((__safe__))
+# define __force	__attribute__((__force__))
+# define __nocast	__attribute__((__nocast__))
+# define __iomem	__attribute__((__noderef__, __address_space__(2)))
+# define __must_hold(x)	__attribute__((__context__(x, 1, 1)))
+# define __acquires(x)	__attribute__((__context__(x, 0, 1)))
+# define __releases(x)	__attribute__((__context__(x, 1, 0)))
+# define __acquire(x)	__context__(x, 1)
+# define __release(x)	__context__(x, -1)
 # define __cond_lock(x,c)	((c) ? ({ __acquire(x); 1; }) : 0)
-# define __percpu	__attribute__((noderef, address_space(3)))
-# define __rcu		__attribute__((noderef, address_space(4)))
-# define __private	__attribute__((noderef))
+# define __percpu	__attribute__((__noderef__, __address_space__(3)))
+# define __rcu		__attribute__((__noderef__, __address_space__(4)))
+# define __private	__attribute__((__noderef__))
 extern void __chk_user_ptr(const volatile void __user *);
 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 +111,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



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

end of thread, other threads:[~2019-10-30 16:30 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-27 22:03 [PATCH] compiler*.h: Add '__' prefix and suffix to all __attribute__ #defines 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     ` [PATCH V2] " Joe Perches
2019-10-28 22:15     ` [PATCH] " 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).