diff options
author | Dave Korn <dave.korn.cygwin@gmail.com> | 2009-07-07 20:12:44 +0000 |
---|---|---|
committer | Dave Korn <dave.korn.cygwin@gmail.com> | 2009-07-07 20:12:44 +0000 |
commit | b602bb90e21d5259ce85e11bf968aa624bdb592b (patch) | |
tree | 8c7c57bdcb700df8cb617cc24876e437c1c1a6fa /winsup/cygwin/cxx.cc | |
parent | 6499c6e07b217eb22274c090f7a9f3d0d3de2be4 (diff) | |
download | cygnal-b602bb90e21d5259ce85e11bf968aa624bdb592b.tar.gz cygnal-b602bb90e21d5259ce85e11bf968aa624bdb592b.tar.bz2 cygnal-b602bb90e21d5259ce85e11bf968aa624bdb592b.zip |
winsup/ChangeLog:
* Makefile.common (COMPILE_CXX): Add support for per-file overrides
to exclude $(nostdinc) and $(nostdincxx) from compiler flags.
(COMPILE_CC): Likewise for $(nostdinc).
winsup/cygwin/ChangeLog:
* Makefile.in (DLL_OFILES): Add libstdcxx_wrapper.o
(libstdcxx_wrapper_CFLAGS): Add flags for new module.
(_cygwin_crt0_common_STDINCFLAGS): Define per-file override.
(libstdcxx_wrapper_STDINCFLAGS, cxx_STDINCFLAGS): Likewise.
* cxx.cc: Include "cygwin-cxx.h".
(operator new): Tweak prototype for full standards compliance.
(operator new[]): Likewise.
(operator new (nothrow)): New fallback function.
(operator new[] (nothrow), operator delete (nothrow),
operator delete[] (nothrow)): Likewise.
(default_cygwin_cxx_malloc): New struct of pointers to the above,
for final last-resort fallback default.
* cygwin-cxx.h: New file.
(struct per_process_cxx_malloc): Define.
(default_cygwin_cxx_malloc): Declare extern.
* cygwin.din (__wrap__ZdaPv): Export new wrapper.
(__wrap__ZdaPvRKSt9nothrow_t, __wrap__ZdlPv,
__wrap__ZdlPvRKSt9nothrow_t, __wrap__Znaj,
__wrap__ZnajRKSt9nothrow_t, __wrap__Znwj,
__wrap__ZnwjRKSt9nothrow_t): Likewise.
* globals.cc (__cygwin_user_data): Init newly-repurposed 'forkee'
field (now 'cxx_malloc') to point to default_cygwin_cxx_malloc.
* libstdcxx_wrapper.cc: New file.
(__wrap__ZdaPv, __wrap__ZdaPvRKSt9nothrow_t, __wrap__ZdlPv,
__wrap__ZdlPvRKSt9nothrow_t, __wrap__Znaj,
__wrap__ZnajRKSt9nothrow_t, __wrap__Znwj,
__wrap__ZnwjRKSt9nothrow_t): Define wrapper functions for libstdc++
malloc operators and their overrides.
* winsup.h (default_cygwin_cxx_malloc): Declare extern.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
* include/sys/cygwin.h (struct per_process_cxx_malloc): Forward
declare here.
(struct per_process::forkee): Rename and repurpose from this ...
(struct per_process::cxx_malloc): ... to this.
* lib/_cygwin_crt0_common.cc: Include cygwin-cxx.h.
(WEAK): Define shorthand helper macro.
(__cygwin_cxx_malloc): Define and populate with weak references
to whatever libstdc++ malloc operators will be visible at final
link time for Cygwin apps and dlls.
(_cygwin_crt0_common): Always look up cygwin DLL's internal
per_process data, and don't test for (impossible) failure. Inherit
any members of __cygwin_cxx_malloc that we don't have overrides
for from the DLL's default and store the resulting overall set of
overrides back into the DLL's global per_process data.
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 |