]> granicus.if.org Git - gc/commitdiff
enable atomic-uncollectable
authorJohannes Totz <jtotz@ic.ac.uk>
Mon, 24 Jan 2011 17:56:37 +0000 (17:56 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 11 May 2015 15:59:57 +0000 (18:59 +0300)
pretty much the same as system's malloc, but is useful in force-include scenarios

Conflicts:

    include/gc.h
    include/gc_cpp.h
    vc9/libgc.vcproj

include/gc_cpp.h

index 0302439df4984bb04ccbfaf847c7bc2bd2d7bf37..b4fe6daaea856a0bbaf8b132dffa431a5f1caf48 100644 (file)
@@ -179,13 +179,16 @@ namespace boehmgc
 {
 #endif
 
-enum GCPlacement {
+enum GCPlacement
+{
   UseGC,
 # ifndef GC_NAME_CONFLICT
     GC=UseGC,
 # endif
   NoGC,
-  PointerFreeGC
+  PointerFreeGC,
+  PointerFreeNoGC,
+  NoGCPointerFree = PointerFreeNoGC
 };
 
 class gc {
@@ -310,13 +313,20 @@ inline void* gc::operator new( size_t size ) {
     return GC_MALLOC( size );
 }
 
-inline void* gc::operator new( size_t size, GCPlacement gcp ) {
-    if (gcp == UseGC)
-        return GC_MALLOC( size );
-    else if (gcp == PointerFreeGC)
-        return GC_MALLOC_ATOMIC( size );
-    else
-        return GC_MALLOC_UNCOLLECTABLE( size );
+inline void* gc::operator new( size_t size, GCPlacement gcp )
+{
+    switch (gcp)
+    {
+        case UseGC:
+            return GC_MALLOC( size );
+        case PointerFreeGC:
+            return GC_MALLOC_ATOMIC( size );
+        case PointerFreeNoGC:
+            return GC_MALLOC_ATOMIC_UNCOLLECTABLE( size );
+        case NoGC:
+        default:
+            return GC_MALLOC_UNCOLLECTABLE( size );
+    }
 }
 
 inline void* gc::operator new( size_t /* size */, void *p ) {
@@ -394,16 +404,28 @@ inline void* operator new( size_t size, GC_NS_QUALIFY(GCPlacement) gcp,
 {
     void* obj;
 
-    if (gcp == GC_NS_QUALIFY(UseGC)) {
+    if (gcp == GC_NS_QUALIFY(UseGC))
+    {
         obj = GC_MALLOC( size );
         if (cleanup != 0)
-            GC_REGISTER_FINALIZER_IGNORE_SELF( obj, cleanup, clientData,
-                                              0, 0 );
-    } else if (gcp == GC_NS_QUALIFY(PointerFreeGC)) {
+            GC_REGISTER_FINALIZER_IGNORE_SELF(
+                obj, cleanup, clientData, 0, 0 );
+    }
+    else
+    if (gcp == GC_NS_QUALIFY(PointerFreeGC))
+    {
         obj = GC_MALLOC_ATOMIC( size );
-    } else {
+    }
+    else
+    if (gcp == GC_NS_QUALIFY(PointerFreeNoGC))
+    {
+        obj = GC_MALLOC_ATOMIC_UNCOLLECTABLE( size );
+    }
+    else
+    {
         obj = GC_MALLOC_UNCOLLECTABLE( size );
-    };
+    }
+
     return obj;
 }