[libc-commits] [libc] [libc] Move from alias(X) to asm(X) for aliasing (PR #89333)

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Fri Apr 19 14:49:10 PDT 2024


nickdesaulniers wrote:

I think that would look like:
```diff









diff --git a/libc/src/__support/common.h b/libc/src/__support/common.h
index 53951dc131c2..fbc7081bfa2f 100644
--- a/libc/src/__support/common.h
+++ b/libc/src/__support/common.h
@@ -23,10 +23,8 @@
 // MacOS needs to be excluded because it does not support aliasing.
 #if defined(LIBC_COPT_PUBLIC_PACKAGING) && (!defined(__APPLE__))
 #define LLVM_LIBC_FUNCTION_IMPL(type, name, arglist)                           \
-  LLVM_LIBC_FUNCTION_ATTR decltype(LIBC_NAMESPACE::name)                       \
-      __##name##_impl__ __asm__(#name);                                        \
-  decltype(LIBC_NAMESPACE::name) name [[gnu::alias(#name)]];                   \
-  type __##name##_impl__ arglist
+  namespace LIBC_NAMESPACE { decltype(::name) name [[gnu::alias(#name)]]; }    \
+  extern "C" type name arglist
 #else
 #define LLVM_LIBC_FUNCTION_IMPL(type, name, arglist) type name arglist
 #endif
diff --git a/libc/src/ctype/isalnum.cpp b/libc/src/ctype/isalnum.cpp
index 42ed8ea475f1..0691c19b1394 100644
--- a/libc/src/ctype/isalnum.cpp
+++ b/libc/src/ctype/isalnum.cpp
@@ -11,12 +11,8 @@
 
 #include "src/__support/common.h"
 
-namespace LIBC_NAMESPACE {
-
 // TODO: Currently restricted to default locale.
 // These should be extended using locale information.
 LLVM_LIBC_FUNCTION(int, isalnum, (int c)) {
   return static_cast<int>(internal::isalnum(static_cast<unsigned>(c)));
 }
-
-} // namespace LIBC_NAMESPACE
diff --git a/libc/src/ctype/isalnum.h b/libc/src/ctype/isalnum.h
index 71830c95cb2f..3ed5b3ac2a62 100644
--- a/libc/src/ctype/isalnum.h
+++ b/libc/src/ctype/isalnum.h
@@ -9,10 +9,6 @@
 #ifndef LLVM_LIBC_SRC_CTYPE_ISALNUM_H
 #define LLVM_LIBC_SRC_CTYPE_ISALNUM_H
 
-namespace LIBC_NAMESPACE {
-
-int isalnum(int c);
-
-} // namespace LIBC_NAMESPACE
+extern "C" int isalnum(int c);
 
 #endif //  LLVM_LIBC_SRC_CTYPE_ISALNUM_H
```
but applied across the whole tree.

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


More information about the libc-commits mailing list