diff mbox series

[v1,02/14] compiler: add a global __QUITE_UNIQUE_ID()

Message ID 152d812cb6fa2c6018794ea7f05f487631542d6e.1699025537.git.tanyuan@tinylab.org (mailing list archive)
State Changes Requested, archived
Headers show
Series DCE/DSE: Add Dead Syscalls Elimination support, part2 | expand

Checks

Context Check Description
conchuod/vmtest-fixes-PR fail merge-conflict

Commit Message

Yuan Tan Nov. 3, 2023, 3:58 p.m. UTC
From: Zhangjin Wu <falcon@tinylab.org>

Differs from __UNIQUE_ID(), __QUITE_UNIQUE_ID() also appends the
__COUNTER__ info to make it more unique.

Besides, seems assembly code also require such a unique id, let's make
it global, the same to the required __PASTE macro.

Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
---
I am not sure whether it is proper to put the __QUITE_UNIQUE_ID and
other stuff later in compiler.h. Welcome discussion as this is just
a preliminary approach.

 include/linux/compiler.h       | 5 +++++
 include/linux/compiler_types.h | 8 ++++----
 2 files changed, 9 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index d7779a18b24f..405b19cf6cf3 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -227,6 +227,11 @@  static inline void *offset_to_ptr(const int *off)
 
 #endif /* __ASSEMBLY__ */
 
+/* Quite-unique ID. */
+#ifndef __QUITE_UNIQUE_ID
+# define __QUITE_UNIQUE_ID(prefix) __PASTE(__PASTE(prefix, __LINE__), __COUNTER__)
+#endif
+
 /* &a[0] degrades to a pointer: a different type from an array */
 #define __must_be_array(a)	BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
 
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index c523c6683789..0b79e19d1017 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -70,10 +70,6 @@  static inline void __chk_io_ptr(const volatile void __iomem *ptr) { }
 # define __builtin_warning(x, y...) (1)
 #endif /* __CHECKER__ */
 
-/* Indirect macros required for expanded argument pasting, eg. __LINE__. */
-#define ___PASTE(a,b) a##b
-#define __PASTE(a,b) ___PASTE(a,b)
-
 #ifdef __KERNEL__
 
 /* Attributes */
@@ -308,6 +304,10 @@  struct ftrace_likely_data {
 
 #endif /* __ASSEMBLY__ */
 
+/* Indirect macros required for expanded argument pasting, eg. __LINE__. */
+#define ___PASTE(a, b) a##b
+#define __PASTE(a, b) ___PASTE(a, b)
+
 /*
  * The below symbols may be defined for one or more, but not ALL, of the above
  * compilers. We don't consider that to be an error, so set them to nothing.