[libc-commits] [libc] [llvm] [libc] Allow each function can have extra attributes by defining LLVM_LIBC_FUNCTION_ATTR_func macro. (PR #116160)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Wed Nov 20 09:40:19 PST 2024
================
@@ -21,9 +21,25 @@
#define LLVM_LIBC_FUNCTION_ATTR
#endif
+// Allow each function `func` to have extra attributes specified by defining:
+// `LLVM_LIBC_FUNCTION_ATTR_func` macro, which should always start with
+// "LLVM_LIBC_EMPTY, "
+//
+// For examples:
+// #define LLVM_LIBC_FUNCTION_ATTR_memcpy LLVM_LIBC_EMPTY, [[gnu::weak]]
+// #define LLVM_LIBC_FUNCTION_ATTR_memchr LLVM_LIBC_EMPTY, [[gnu::weak]] \
+// [[gnu::visibility("default")]]
+#define LLVM_LIBC_EMPTY
+
+#define GET_SECOND(first, second, ...) second
+#define EXPAND_THEN_SECOND(name) GET_SECOND(name, LLVM_LIBC_EMPTY, )
----------------
nickdesaulniers wrote:
I think this still works: https://godbolt.org/z/dT4xTYqoY
```suggestion
#define EXPAND_THEN_SECOND(name) GET_SECOND(name, LLVM_LIBC_EMPTY)
```
https://github.com/llvm/llvm-project/pull/116160
More information about the libc-commits
mailing list