]> granicus.if.org Git - gc/commitdiff
Allow to omit libc atexit() call
authorIvan Maidanski <ivmai@mail.ru>
Wed, 13 Feb 2013 20:29:44 +0000 (00:29 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 13 Feb 2013 20:29:44 +0000 (00:29 +0400)
* misc.c (GC_exit_check): Do not define if DONT_USE_ATEXIT (since
unused in this case).
* misc.c (GC_init): Do not call atexit if DONT_USE_ATEXIT (useful if
atexit is missing in libc, e.g., to workaround linkage problems in
Android NDK).

misc.c

diff --git a/misc.c b/misc.c
index bc0f4fed177b3d182100dfa4f515cb7c9da4c11f..e6d3197318a7f767fcb44ac946ad7656ef325573 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -738,12 +738,14 @@ GC_INNER GC_bool GC_is_initialized = FALSE;
     GC_INNER CRITICAL_SECTION GC_write_cs;
 #endif
 
-STATIC void GC_exit_check(void)
-{
-   if (GC_find_leak) {
-     GC_gcollect();
-   }
-}
+#ifndef DONT_USE_ATEXIT
+  STATIC void GC_exit_check(void)
+  {
+    if (GC_find_leak) {
+      GC_gcollect();
+    }
+  }
+#endif
 
 #if defined(UNIX_LIKE) && !defined(NO_DEBUGGING)
   static void looping_handler(int sig)
@@ -1196,11 +1198,13 @@ GC_API void GC_CALL GC_init(void)
 #   ifdef STUBBORN_ALLOC
         GC_stubborn_init();
 #   endif
-    if (GC_find_leak) {
-      /* This is to give us at least one chance to detect leaks.        */
-      /* This may report some very benign leaks, but ...                */
-      atexit(GC_exit_check);
-    }
+#   ifndef DONT_USE_ATEXIT
+      if (GC_find_leak) {
+        /* This is to give us at least one chance to detect leaks.        */
+        /* This may report some very benign leaks, but ...                */
+        atexit(GC_exit_check);
+      }
+#   endif
 
     /* The rest of this again assumes we don't really hold      */
     /* the allocation lock.                                     */