Merge: doc: fixed some typos and other misc. corrections
[nit.git] / c_src / gc_chooser.c
index 5a8cffe..d3854c8 100644 (file)
@@ -18,6 +18,9 @@
 #ifdef ANDROID
        #include <android/log.h>
        #define PRINT_ERROR(...) ((void)__android_log_print(ANDROID_LOG_WARN, "nit", __VA_ARGS__))
+
+       // FIXME bring back when the GC is fixed in Android
+       #undef WITH_LIBGC
 #else
        #define PRINT_ERROR(...) ((void)fprintf(stderr, __VA_ARGS__))
 #endif
@@ -25,7 +28,6 @@
 enum gc_option { gc_opt_large, gc_opt_malloc, gc_opt_boehm } gc_option;
 
 #ifdef WITH_LIBGC
-#define GC_DEBUG
 #include <gc/gc.h>
 #endif
 
@@ -62,6 +64,7 @@ void nit_gcollect(void) {
 #ifdef WITH_LIBGC
        case gc_opt_boehm: GC_gcollect(); break;
 #endif
+       default: break; /* nothing can be done */
        }
 }
 
@@ -121,3 +124,11 @@ void initialize_gc_option(void) {
                default: break; /* Nothing */
        }
 }
+
+void gc_register_finalizer(void* obj) {
+#ifdef WITH_LIBGC
+       GC_register_finalizer(obj, &gc_finalize, NULL, NULL, NULL);
+#endif
+}
+
+void __attribute__((weak)) gc_finalize(void *obj, void* client_data) {}