diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-04-22 08:22:04 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-04-22 08:22:04 +0300 |
commit | 2470c7047baef8446bd167835dcf656ffffeaeb2 (patch) | |
tree | 1660ae844d86913658597110e3a363822abb6473 /cord | |
parent | e2fb45fc98276b856e03faf2c3016cd2921b2e2c (diff) | |
download | bdwgc-2470c7047baef8446bd167835dcf656ffffeaeb2.tar.gz |
Fix linking of tests in case of finalization is off
(fix of commit c14335e44)
* cord/cordxtra.c (CORD_lf_close_proc): Do not define if
GC_NO_FINALIZATION.
* cord/cordxtra.c (CORD_from_file_lazy_inner): Do not call
GC_REGISTER_FINALIZER(CORD_lf_close_proc) if GC_NO_FINALIZATION.
* cord/tests/cordtest.c (test_extras): Do not call GC_invoke_finalizers
if GC_NO_FINALIZATION.
* include/gc/gc_cpp.h (gc_cleanup::~gc_cleanup,
gc_cleanup::gc_cleanup): Do not call GC_base() and
GC_register_finalizer_ignore_self() if GC_NO_FINALIZATION.
* include/gc/gc_cpp.h (operator new): Do not call
GC_REGISTER_FINALIZER_IGNORE_SELF() if GC_NO_FINALIZATION.
* tests/cpp.cc [FINALIZE_ON_DEMAND] (main): Do not call
GC_invoke_finalizers() if GC_NO_FINALIZATION.
* tests/disclaim_bench.c (testobj_new): Do not call GC_NEW() followed
by GC_REGISTER_FINALIZER_NO_ORDER() if GC_NO_FINALIZATION.
* tests/disclaim_bench.c [GC_NO_FINALIZATION] (main): Set model_min
variable to 1 (instead of 0).
* tests/gctest.c [GC_NO_FINALIZATION && !NO_TYPED_TEST]
(NO_TYPED_TEST): Define macro.
Diffstat (limited to 'cord')
-rw-r--r-- | cord/cordxtra.c | 12 | ||||
-rw-r--r-- | cord/tests/cordtest.c | 4 |
2 files changed, 11 insertions, 5 deletions
diff --git a/cord/cordxtra.c b/cord/cordxtra.c index 3771997e..f7bb1ad2 100644 --- a/cord/cordxtra.c +++ b/cord/cordxtra.c @@ -573,12 +573,14 @@ char CORD_lf_func(size_t i, void * client_data) return(cl -> data[MOD_LINE_SZ(i)]); } -void CORD_lf_close_proc(void * obj, void * client_data CORD_ATTR_UNUSED) -{ +#ifndef GC_NO_FINALIZATION + void CORD_lf_close_proc(void * obj, void * client_data CORD_ATTR_UNUSED) + { if (fclose(((lf_state *)obj) -> lf_file) != 0) { ABORT("CORD_lf_close_proc: fclose failed"); } -} + } +#endif CORD CORD_from_file_lazy_inner(FILE * f, size_t len) { @@ -604,7 +606,9 @@ CORD CORD_from_file_lazy_inner(FILE * f, size_t len) state -> lf_cache[i] = 0; } state -> lf_current = 0; - GC_REGISTER_FINALIZER(state, CORD_lf_close_proc, 0, 0, 0); +# ifndef GC_NO_FINALIZATION + GC_REGISTER_FINALIZER(state, CORD_lf_close_proc, 0, 0, 0); +# endif return(CORD_from_fn(CORD_lf_func, state, len)); } diff --git a/cord/tests/cordtest.c b/cord/tests/cordtest.c index 16362973..44e36ba9 100644 --- a/cord/tests/cordtest.c +++ b/cord/tests/cordtest.c @@ -221,8 +221,10 @@ void test_extras(void) *(CORD volatile *)&w = CORD_EMPTY; *(CORD volatile *)&z = CORD_EMPTY; GC_gcollect(); - GC_invoke_finalizers(); +# ifndef GC_NO_FINALIZATION + GC_invoke_finalizers(); /* Of course, this does not guarantee the files are closed. */ +# endif if (remove(FNAME1) != 0) { /* On some systems, e.g. OS2, this may fail if f1 is still open. */ /* But we cannot call fclose as it might lead to double close. */ |