]> granicus.if.org Git - gc/commitdiff
Add GC_is_disabled new function to GC API
authorIvan Maidanski <ivmai@mail.ru>
Wed, 1 Feb 2012 17:25:44 +0000 (21:25 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 3 Feb 2012 16:38:19 +0000 (20:38 +0400)
* include/gc.h (GC_dont_gc): Improve comment (add note for new client
code).
* include/gc.h (GC_is_disabled): New API function.
* misc.c (GC_is_disabled): Likewise.

include/gc.h
misc.c

index f460a634e37322043dc1af81d126f38a5c5ff146..dfa0ff6ca592403b5e3e343e2be93400f0c1f552 100644 (file)
@@ -181,9 +181,10 @@ GC_API int GC_dont_gc;  /* != 0 ==> Don't collect.  In versions 6.2a1+, */
                         /* Used as a counter, so that nested enabling   */
                         /* and disabling work correctly.  Should        */
                         /* normally be updated with GC_enable() and     */
-                        /* GC_disable() calls.                          */
-                        /* Direct assignment to GC_dont_gc is           */
-                        /* deprecated.                                  */
+                        /* GC_disable() calls.  Direct assignment to    */
+                        /* GC_dont_gc is deprecated.  To check whether  */
+                        /* GC is disabled, GC_is_disabled() is          */
+                        /* preferred for new code.                      */
 
 GC_API int GC_dont_expand;
                         /* Don't expand the heap unless explicitly      */
@@ -570,6 +571,10 @@ GC_API void GC_CALL GC_get_heap_usage_safe(GC_word * /* pheap_size */,
 /* ineffective.                                                         */
 GC_API void GC_CALL GC_disable(void);
 
+/* Return non-zero (TRUE) if and only if garbage collection is disabled */
+/* (i.e., GC_dont_gc value is non-zero).  Does not acquire the lock.    */
+GC_API int GC_CALL GC_is_disabled(void);
+
 /* Re-enable garbage collection.  GC_disable() and GC_enable() calls    */
 /* nest.  Garbage collection is enabled if the number of calls to both  */
 /* both functions is equal.                                             */
diff --git a/misc.c b/misc.c
index 8b24aa0dd7e9d1aff23d1c5c84bad42d58e2f4a7..2fd41664db013e89c43143e823703a22eec4d179 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -1444,6 +1444,11 @@ GC_API void GC_CALL GC_disable(void)
     UNLOCK();
 }
 
+GC_API int GC_CALL GC_is_disabled(void)
+{
+    return GC_dont_gc != 0;
+}
+
 /* Helper procedures for new kind creation.     */
 GC_API void ** GC_CALL GC_new_free_list_inner(void)
 {