summaryrefslogtreecommitdiff
path: root/gc_cpp.cc
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2023-04-19 08:12:13 +0300
committerIvan Maidanski <ivmai@mail.ru>2023-04-20 11:24:16 +0300
commit906c14ec7907c28b5652ed253f7a48b259ee84e5 (patch)
tree95fa2b73297c2b1892a493dc087c953bcac40f80 /gc_cpp.cc
parentd25fee545bcf270231bfe5a683fa61d5ae795338 (diff)
downloadbdwgc-906c14ec7907c28b5652ed253f7a48b259ee84e5.tar.gz
Define sized delete operator in 'gc' class
* gc_cpp.cc [!_MSC_VER && !__DMC__ || GC_NO_INLINE_STD_NEW] (operator delete): Replace __cplusplus>=201703L||_MSVC_LANG>=201703L to defined(GC_OPERATOR_SIZED_DELETE). * include/gc/gc_cpp.h [GC_INLINE_STD_NEW]: Likewise. * gc_cpp.cc [!_MSC_VER && !__DMC__ || GC_NO_INLINE_STD_NEW] (GC_ALLOCATOR_THROW_OR_ABORT, operator new, operator delete, operator new[], operator delete[]): Do not define if GC_INLINE_STD_NEW. * gc_cpp.cc (operator new, operator delete): Reformat code. * include/gc/gc_cpp.h [!GC_NO_INLINE_STD_NEW && !GC_INLINE_STD_NEW && (_MSC_VER || __DMC__ || (__BORLANDC__ || __CYGWIN__ || __CYGWIN32__ || __MINGW32__ || __WATCOMC__) && !GC_BUILD && !GC_NOT_DLL)] (GC_INLINE_STD_NEW): Define macro. * include/gc/gc_cpp.h [!GC_NO_OPERATOR_SIZED_DELETE && !GC_OPERATOR_SIZED_DELETE && (__cplusplus>=201402L || _MSVC_LANG>=201402L)] (GC_OPERATOR_SIZED_DELETE): Likewise. * include/gc/gc_cpp.h [!GC_NO_INLINE_STD_NEW && (_MSC_VER || __DMC__ || (__BORLANDC__ || __CYGWIN__ || __CYGWIN32__ || __MINGW32__ || __WATCOMC__) && !GC_BUILD && !GC_NOT_DLL)]: Check GC_INLINE_STD_NEW instead. * include/gc/gc_cpp.h [GC_OPERATOR_SIZED_DELETE] (gc::operator delete(void*,GC_SIZE_T)): Declare. * include/gc/gc_cpp.h [GC_OPERATOR_NEW_ARRAY && GC_OPERATOR_SIZED_DELETE] (gc::operator delete[](void*,GC_SIZE_T)): Likewise. * include/gc/gc_cpp.h [GC_NO_INLINE_STD_NEW && _MSC_VER && GC_OPERATOR_NEW_ARRAY && GC_OPERATOR_SIZED_DELETE] (operator delete[](void*,GC_SIZE_T)): Likewise. * include/gc/gc_cpp.h [GC_NO_INLINE_STD_NEW && _MSC_VER && GC_OPERATOR_SIZED_DELETE] (operator delete(void*,GC_SIZE_T)): Likewise. * include/gc/gc_cpp.h [GC_OPERATOR_SIZED_DELETE] (gc::operator delete(void*,GC_SIZE_T)): Define inline function. * include/gc/gc_cpp.h [GC_OPERATOR_NEW_ARRAY && GC_OPERATOR_SIZED_DELETE] (gc::operator delete[](void*,GC_SIZE_T)): Likewise.
Diffstat (limited to 'gc_cpp.cc')
-rw-r--r--gc_cpp.cc25
1 files changed, 16 insertions, 9 deletions
diff --git a/gc_cpp.cc b/gc_cpp.cc
index 1f25ce4e..bcc049f5 100644
--- a/gc_cpp.cc
+++ b/gc_cpp.cc
@@ -38,7 +38,8 @@ built-in "new" and "delete".
#endif
#include "gc/gc_cpp.h"
-#if !(defined(_MSC_VER) || defined(__DMC__)) || defined(GC_NO_INLINE_STD_NEW)
+#if (!defined(_MSC_VER) && !defined(__DMC__) \
+ || defined(GC_NO_INLINE_STD_NEW)) && !defined(GC_INLINE_STD_NEW)
# if defined(GC_NEW_ABORTS_ON_OOM) || defined(_LIBCPP_NO_EXCEPTIONS)
# define GC_ALLOCATOR_THROW_OR_ABORT() GC_abort_on_oom()
@@ -47,7 +48,8 @@ built-in "new" and "delete".
# define GC_ALLOCATOR_THROW_OR_ABORT() throw std::bad_alloc()
# endif
- void* operator new(GC_SIZE_T size) GC_DECL_NEW_THROW {
+ void* operator new(GC_SIZE_T size) GC_DECL_NEW_THROW
+ {
void* obj = GC_MALLOC_UNCOLLECTABLE(size);
if (0 == obj)
GC_ALLOCATOR_THROW_OR_ABORT();
@@ -71,12 +73,14 @@ built-in "new" and "delete".
}
# endif // _MSC_VER
- void operator delete(void* obj) GC_NOEXCEPT {
+ void operator delete(void* obj) GC_NOEXCEPT
+ {
GC_FREE(obj);
}
# if defined(GC_OPERATOR_NEW_ARRAY) && !defined(CPPCHECK)
- void* operator new[](GC_SIZE_T size) GC_DECL_NEW_THROW {
+ void* operator new[](GC_SIZE_T size) GC_DECL_NEW_THROW
+ {
void* obj = GC_MALLOC_UNCOLLECTABLE(size);
if (0 == obj)
GC_ALLOCATOR_THROW_OR_ABORT();
@@ -92,21 +96,24 @@ built-in "new" and "delete".
}
# endif // _MSC_VER
- void operator delete[](void* obj) GC_NOEXCEPT {
+ void operator delete[](void* obj) GC_NOEXCEPT
+ {
GC_FREE(obj);
}
# endif // GC_OPERATOR_NEW_ARRAY
-# if __cplusplus >= 201402L || _MSVC_LANG >= 201402L // C++14
- void operator delete(void* obj, GC_SIZE_T) GC_NOEXCEPT {
+# ifdef GC_OPERATOR_SIZED_DELETE
+ void operator delete(void* obj, GC_SIZE_T) GC_NOEXCEPT
+ {
GC_FREE(obj);
}
# if defined(GC_OPERATOR_NEW_ARRAY) && !defined(CPPCHECK)
- void operator delete[](void* obj, GC_SIZE_T) GC_NOEXCEPT {
+ void operator delete[](void* obj, GC_SIZE_T) GC_NOEXCEPT
+ {
GC_FREE(obj);
}
# endif
-# endif // C++14
+# endif // GC_OPERATOR_SIZED_DELETE
#endif // !_MSC_VER && !__DMC__ || GC_NO_INLINE_STD_NEW