[libc-commits] [libc] [libc] Allow each function can have extra attributes by defining LLVM_LIBC_FUNCTION_ATTR_func macro. (PR #116160)

Alexey Samsonov via libc-commits libc-commits at lists.llvm.org
Tue Nov 19 11:53:28 PST 2024


================
@@ -21,9 +21,24 @@
 #define LLVM_LIBC_FUNCTION_ATTR
 #endif
 
+// Allow each function `func` can have extra attributes specified by defining:
+// `LLVM_LIBC_FUNCTION_ATTR_func` macro, which should always start with
+// "LLVM_LIBC_EMPTY,"
+//
+// For example:
+// #define LLVM_LIBC_FUNCTION_ATTR_memcpy LLVM_LIBC_EMPTY, __attribute__((weak))
+#define LLVM_LIBC_EMPTY
+
+#define GET_SECOND(first, second, ...) second
+#define EXPAND_THEN_SECOND(name) GET_SECOND(name, LLVM_LIBC_EMPTY, )
+
+#define LLVM_LIBC_ATTR(name) EXPAND_THEN_SECOND(LLVM_LIBC_FUNCTION_ATTR_##name)
+#define EXPAND_ATTR(name) LLVM_LIBC_ATTR(name)
----------------
vonosmas wrote:

I don't think you need `EXPAND_ATTR` and can just use `LLVM_LIBC_ATTR` below?

https://github.com/llvm/llvm-project/pull/116160


More information about the libc-commits mailing list