Skip to content

[libc][NFC] Fix delete operator linkage names after switch to LIBC_NAMESPACE. #67475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions libc/src/__support/CPP/new.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,23 @@ LIBC_INLINE void *operator new[](size_t size, std::align_val_t align,
// they will replace operator delete for the entire application. Including this
// header file in all libc source files where operator delete is called ensures
// that only libc call sites use these replacement operator delete functions.
void operator delete(void *) noexcept __asm__("LIBC_NAMESPACE_delete");

#define DELETE_NAME(name) \
__asm__(LIBC_MACRO_TO_STRING(LIBC_NAMESPACE) "_" LIBC_MACRO_TO_STRING(name))

void operator delete(void *) noexcept DELETE_NAME(delete);
void operator delete(void *, std::align_val_t) noexcept
__asm__("LIBC_NAMESPACE_delete_aligned");
void operator delete(void *, size_t) noexcept
__asm__("LIBC_NAMESPACE_delete_sized");
DELETE_NAME(delete_aligned);
void operator delete(void *, size_t) noexcept DELETE_NAME(delete_sized);
void operator delete(void *, size_t, std::align_val_t) noexcept
__asm__("LIBC_NAMESPACE_delete_sized_aligned");
void operator delete[](void *) noexcept __asm__("LIBC_NAMESPACE_delete_array");
DELETE_NAME(delete_sized_aligned);
void operator delete[](void *) noexcept DELETE_NAME(delete_array);
void operator delete[](void *, std::align_val_t) noexcept
__asm__("LIBC_NAMESPACE_delete_array_aligned");
void operator delete[](void *, size_t) noexcept
__asm__("LIBC_NAMESPACE_delete_array_sized");
DELETE_NAME(delete_array_aligned);
void operator delete[](void *, size_t) noexcept DELETE_NAME(delete_array_sized);
void operator delete[](void *, size_t, std::align_val_t) noexcept
__asm__("LIBC_NAMESPACE_delete_array_sized_aligned");
DELETE_NAME(delete_array_sized_aligned);

#undef DELETE_NAME

#endif // LLVM_LIBC_SRC___SUPPORT_CPP_NEW_H
3 changes: 3 additions & 0 deletions libc/src/__support/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ LIBC_INLINE constexpr bool same_string(char const *lhs, char const *rhs) {
} // namespace internal
} // namespace LIBC_NAMESPACE

#define __LIBC_MACRO_TO_STRING(str) #str
#define LIBC_MACRO_TO_STRING(str) __LIBC_MACRO_TO_STRING(str)

// LLVM_LIBC_IS_DEFINED checks whether a particular macro is defined.
// Usage: constexpr bool kUseAvx = LLVM_LIBC_IS_DEFINED(__AVX__);
//
Expand Down