Skip to content

Commit f2c9fe4

Browse files
authored
[libc][NFC] Fix delete operator linkage names after switch to LIBC_NAMESPACE. (#67475)
The name __llvm_libc was mass-replaced with LIBC_NAMESPACE which ended up changing the "__llvm_libc" prefix of the delete operator linkage names to "LIBC_NAMESPACE". This change corrects it by changing the namespace prefix to "__llvm_libc_<version info>".
1 parent c50617d commit f2c9fe4

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

libc/src/__support/CPP/new.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,23 @@ LIBC_INLINE void *operator new[](size_t size, std::align_val_t align,
8484
// they will replace operator delete for the entire application. Including this
8585
// header file in all libc source files where operator delete is called ensures
8686
// that only libc call sites use these replacement operator delete functions.
87-
void operator delete(void *) noexcept __asm__("LIBC_NAMESPACE_delete");
87+
88+
#define DELETE_NAME(name) \
89+
__asm__(LIBC_MACRO_TO_STRING(LIBC_NAMESPACE) "_" LIBC_MACRO_TO_STRING(name))
90+
91+
void operator delete(void *) noexcept DELETE_NAME(delete);
8892
void operator delete(void *, std::align_val_t) noexcept
89-
__asm__("LIBC_NAMESPACE_delete_aligned");
90-
void operator delete(void *, size_t) noexcept
91-
__asm__("LIBC_NAMESPACE_delete_sized");
93+
DELETE_NAME(delete_aligned);
94+
void operator delete(void *, size_t) noexcept DELETE_NAME(delete_sized);
9295
void operator delete(void *, size_t, std::align_val_t) noexcept
93-
__asm__("LIBC_NAMESPACE_delete_sized_aligned");
94-
void operator delete[](void *) noexcept __asm__("LIBC_NAMESPACE_delete_array");
96+
DELETE_NAME(delete_sized_aligned);
97+
void operator delete[](void *) noexcept DELETE_NAME(delete_array);
9598
void operator delete[](void *, std::align_val_t) noexcept
96-
__asm__("LIBC_NAMESPACE_delete_array_aligned");
97-
void operator delete[](void *, size_t) noexcept
98-
__asm__("LIBC_NAMESPACE_delete_array_sized");
99+
DELETE_NAME(delete_array_aligned);
100+
void operator delete[](void *, size_t) noexcept DELETE_NAME(delete_array_sized);
99101
void operator delete[](void *, size_t, std::align_val_t) noexcept
100-
__asm__("LIBC_NAMESPACE_delete_array_sized_aligned");
102+
DELETE_NAME(delete_array_sized_aligned);
103+
104+
#undef DELETE_NAME
101105

102106
#endif // LLVM_LIBC_SRC___SUPPORT_CPP_NEW_H

libc/src/__support/common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ LIBC_INLINE constexpr bool same_string(char const *lhs, char const *rhs) {
4646
} // namespace internal
4747
} // namespace LIBC_NAMESPACE
4848

49+
#define __LIBC_MACRO_TO_STRING(str) #str
50+
#define LIBC_MACRO_TO_STRING(str) __LIBC_MACRO_TO_STRING(str)
51+
4952
// LLVM_LIBC_IS_DEFINED checks whether a particular macro is defined.
5053
// Usage: constexpr bool kUseAvx = LLVM_LIBC_IS_DEFINED(__AVX__);
5154
//

0 commit comments

Comments
 (0)