diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2019-10-15 09:59:19 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2019-10-15 09:59:19 +0300 |
commit | eb571cb86d7a3c0fc08ce769dbcee8fe63132878 (patch) | |
tree | bd059d6ae42c79c34972073de84f92f468910303 /gc_cpp.cc | |
parent | e1eec522eb58c0aa13ca7901d7a179e11e1ee763 (diff) | |
download | bdwgc-eb571cb86d7a3c0fc08ce769dbcee8fe63132878.tar.gz |
New macro to avoid system-wide new/delete inlining in gc_cpp.h (Win32)
(fix of commit 3d784ed)
* doc/README.macros (GC_NO_INLINE_STD_NEW): Document.
* gc_cpp.cc [(_MSC_VER || __DMC__) && GC_NO_INLINE_STD_NEW
&& GC_NEW_DELETE_NEED_THROW] (GC_DECL_NEW_THROW): Define.
* gc_cpp.cc [(_MSC_VER || __DMC__) && GC_NO_INLINE_STD_NEW]
(operator new, operator delete): Likewise.
* include/gc_cpp.h [_MSC_VER || __DMC__ || (__BORLANDC__ || __CYGWIN__
|| __MINGW32__ || __WATCOMC__) && !GC_BUILD && !GC_NOT_DLL]
(operator new, operator delete): Do not define inline function if
GC_NO_INLINE_STD_NEW.
* gc_cpp.cc [GC_NO_INLINE_STD_NEW && _MSC_VER] (operator new,
operator delete): Declare; move comment.
Diffstat (limited to 'gc_cpp.cc')
-rw-r--r-- | gc_cpp.cc | 30 |
1 files changed, 28 insertions, 2 deletions
@@ -44,7 +44,7 @@ GC_API void GC_CALL GC_throw_bad_alloc() { GC_ALLOCATOR_THROW_OR_ABORT(); } -#if !defined(_MSC_VER) && !defined(__DMC__) +#if !(defined(_MSC_VER) || defined(__DMC__)) || defined(GC_NO_INLINE_STD_NEW) # if !defined(GC_NEW_DELETE_THROW_NOT_NEEDED) \ && !defined(GC_NEW_DELETE_NEED_THROW) && GC_GNUC_PREREQ(4, 2) \ @@ -71,6 +71,23 @@ GC_API void GC_CALL GC_throw_bad_alloc() { return obj; } +# ifdef _MSC_VER + // This new operator is used by VC++ in case of Debug builds. + void* operator new(size_t size, int /* nBlockUse */, + const char* szFileName, int nLine) + { +# ifdef GC_DEBUG + void* obj = GC_debug_malloc_uncollectable(size, szFileName, nLine); +# else + void* obj = GC_MALLOC_UNCOLLECTABLE(size); + (void)szFileName; (void)nLine; +# endif + if (0 == obj) + GC_ALLOCATOR_THROW_OR_ABORT(); + return obj; + } +# endif // _MSC_VER + void operator delete(void* obj) GC_NOEXCEPT { GC_FREE(obj); } @@ -83,6 +100,15 @@ GC_API void GC_CALL GC_throw_bad_alloc() { return obj; } +# ifdef _MSC_VER + // This new operator is used by VC++ 7+ in Debug builds. + void* operator new[](size_t size, int nBlockUse, + const char* szFileName, int nLine) + { + return operator new(size, nBlockUse, szFileName, nLine); + } +# endif // _MSC_VER + void operator delete[](void* obj) GC_NOEXCEPT { GC_FREE(obj); } @@ -102,4 +128,4 @@ GC_API void GC_CALL GC_throw_bad_alloc() { # endif # endif // C++14 -#endif // !_MSC_VER +#endif // !_MSC_VER && !__DMC__ || GC_NO_INLINE_STD_NEW |