diff options
Diffstat (limited to 'winsup/cygwin/cxx.cc')
-rw-r--r-- | winsup/cygwin/cxx.cc | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/winsup/cygwin/cxx.cc b/winsup/cygwin/cxx.cc index 6021b4fa8..63262f59e 100644 --- a/winsup/cygwin/cxx.cc +++ b/winsup/cygwin/cxx.cc @@ -11,9 +11,14 @@ details. */ #if (__GNUC__ >= 3) #include "winsup.h" +#include "cygwin-cxx.h" + +/* These implementations of operators new and delete are used internally by + the DLL, and are kept separate from the user's/libstdc++'s versions by + use of LD's --wrap option. */ void * -operator new (size_t s) +operator new (std::size_t s) { void *p = calloc (1, s); return p; @@ -26,7 +31,7 @@ operator delete (void *p) } void * -operator new[] (size_t s) +operator new[] (std::size_t s) { return ::operator new (s); } @@ -37,6 +42,34 @@ operator delete[] (void *p) ::operator delete (p); } +/* Nothrow versions, provided only for completeness in the fallback array. */ + +void * +operator new (std::size_t s, const std::nothrow_t &) +{ + void *p = calloc (1, s); + return p; +} + +void +operator delete (void *p, const std::nothrow_t &) +{ + free (p); +} + +void * +operator new[] (std::size_t s, const std::nothrow_t &nt) +{ + return ::operator new (s, nt); +} + +void +operator delete[] (void *p, const std::nothrow_t &nt) +{ + ::operator delete (p, nt); +} + + extern "C" void __cxa_pure_virtual (void) { @@ -52,4 +85,21 @@ extern "C" void __cxa_guard_release () { } + +/* These routines are made available as last-resort fallbacks + for the application. Should not be used in practice. */ + +struct per_process_cxx_malloc default_cygwin_cxx_malloc = +{ + &(operator new), + &(operator new[]), + &(operator delete), + &(operator delete[]), + &(operator new), + &(operator new[]), + &(operator delete), + &(operator delete[]), +}; + + #endif |