diff --git a/gc.c b/gc.c index a8b1fdbd..593d45ed 100644 --- a/gc.c +++ b/gc.c @@ -322,6 +322,7 @@ void sexp_reset_weak_references(sexp ctx) { #define sexp_reset_weak_references(ctx) #endif +#if SEXP_USE_FINALIZERS sexp sexp_finalize (sexp ctx) { size_t size; sexp p, t, end; @@ -368,6 +369,7 @@ sexp sexp_finalize (sexp ctx) { #endif return sexp_make_fixnum(finalize_count); } +#endif sexp sexp_sweep (sexp ctx, size_t *sum_freed_ptr) { size_t freed, max_freed=0, sum_freed=0, size; diff --git a/include/chibi/features.h b/include/chibi/features.h index d0a0efdf..35d658d7 100644 --- a/include/chibi/features.h +++ b/include/chibi/features.h @@ -84,6 +84,11 @@ /* go away and you're not working on your own C extension. */ /* #define SEXP_USE_CONSERVATIVE_GC 1 */ +/* uncomment this to disable automatic running of finalizers */ +/* You will need to close ports and file descriptors manually */ +/* (as you should anyway) and some C extensions may break. */ +/* #define SEXP_USE_FINALIZERS 0 */ + /* uncomment this to add additional native checks to only mark objects in the heap */ /* #define SEXP_USE_SAFE_GC_MARK 1 */ @@ -387,6 +392,10 @@ #define SEXP_USE_CONSERVATIVE_GC 0 #endif +#ifndef SEXP_USE_FINALIZERS +#define SEXP_USE_FINALIZERS 1 +#endif + #ifndef SEXP_USE_TRACK_ALLOC_SOURCE #define SEXP_USE_TRACK_ALLOC_SOURCE SEXP_USE_DEBUG_GC > 2 #endif diff --git a/include/chibi/sexp.h b/include/chibi/sexp.h index 88e4c13d..fa7bbc90 100755 --- a/include/chibi/sexp.h +++ b/include/chibi/sexp.h @@ -1522,7 +1522,11 @@ SEXP_API int sexp_grow_heap (sexp ctx, size_t size, size_t chunk_size); SEXP_API sexp_heap sexp_make_heap (size_t size, size_t max_size, size_t chunk_size); SEXP_API void sexp_mark (sexp ctx, sexp x); SEXP_API sexp sexp_sweep (sexp ctx, size_t *sum_freed_ptr); +#if SEXP_USE_FINALIZERS SEXP_API sexp sexp_finalize (sexp ctx); +#else +#define sexp_finalize(ctx) SEXP_ZERO +#endif #endif #if SEXP_USE_GLOBAL_HEAP diff --git a/tests/build/build-opts.txt b/tests/build/build-opts.txt index a22b3c57..4dfc2197 100644 --- a/tests/build/build-opts.txt +++ b/tests/build/build-opts.txt @@ -5,6 +5,7 @@ CPPFLAGS=-DSEXP_USE_SIMPLIFY=0 CPPFLAGS=-DSEXP_USE_TYPE_DEFS=0 SEXP_USE_BOEHM=1;CPPFLAGS=-I/opt/local/include;LDFLAGS=-L/opt/local/lib CPPFLAGS=-DSEXP_USE_DEBUG_GC=1 +CPPFLAGS=-DSEXP_USE_FINALIZERS=0 CPPFLAGS=-DSEXP_USE_CONSERVATIVE_GC=1 CPPFLAGS=-DSEXP_USE_GLOBAL_HEAP=1 CPPFLAGS=-DSEXP_USE_GLOBAL_SYMBOLS=1