Make new.cc definitions weak (#1233)

The STL says that these should be replaceable by user code.

new.cc now defines only a few direct functions (including a free wrapper
that perplexingly is needed since g++ didn’t want to alias "free".) Now,
all of the operators are weak references to those functions.
This commit is contained in:
Steven Dee (Jōshin) 2024-06-20 12:20:54 -07:00 committed by GitHub
parent 7e780e57d4
commit f86e6f8eb0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 64 additions and 78 deletions

View file

@ -3,12 +3,11 @@
#ifndef COSMOPOLITAN_CTL_NEW_H_
#define COSMOPOLITAN_CTL_NEW_H_
// XXX clang-format currently mutilates these for some reason.
// clang-format off
namespace ctl {
enum class align_val_t : size_t {};
enum class align_val_t : size_t
{
};
} // namespace ctl
@ -16,6 +15,10 @@ void* operator new(size_t);
void* operator new[](size_t);
void* operator new(size_t, ctl::align_val_t);
void* operator new[](size_t, ctl::align_val_t);
// XXX clang-format currently mutilates these for some reason.
// clang-format off
void* operator new(size_t, void*);
void* operator new[](size_t, void*);