[PATCH v1 04/14] compiler: add unique LABEL_NAME()

Yuan Tan tanyuan at tinylab.org
Fri Nov 3 08:59:11 PDT 2023


From: Zhangjin Wu <falcon at tinylab.org>

unique LABEL is required by SHF_LINK_ORDER support.

Signed-off-by: Zhangjin Wu <falcon at tinylab.org>
---
 include/linux/compiler.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 5a9cc3209b12..b178f5d51ad6 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -246,6 +246,12 @@ static inline void *offset_to_ptr(const int *off)
 #endif
 #endif
 
+/* Unique Label NAME. */
+/* Label is file scope, __LINE__ is enough, and not change in the same macro call */
+#ifndef __LABEL_NAME
+# define __LABEL_NAME(prefix) __stringify(__PASTE(__PASTE(prefix, _), __LINE__))
+#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]))
 
-- 
2.34.1




More information about the linux-riscv mailing list