From 9b5e49f33cb84d555e94f85e42563d48177b797d Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Mon, 18 May 2020 09:39:39 +0300 Subject: New API function to clear GC exclusion table (part of commit 8b95edbd6 from Unity-Technologies/bdwgc) * include/gc.h (GC_clear_exclusion_table): Declare new API function. * mark_rts.c (GC_clear_exclusion_table): Implement. * tests/test.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS] (main): Call GC_clear_exclusion_table. --- include/gc.h | 3 +++ mark_rts.c | 5 +++++ tests/test.c | 1 + 3 files changed, 9 insertions(+) diff --git a/include/gc.h b/include/gc.h index 54d76962..fc04d90d 100644 --- a/include/gc.h +++ b/include/gc.h @@ -618,6 +618,9 @@ GC_API void GC_CALL GC_set_max_heap_size(GC_word /* n */); GC_API void GC_CALL GC_exclude_static_roots(void * /* low_address */, void * /* high_address_plus_1 */); +/* Clear the number of entries in the exclusion table. Wizards only. */ +GC_API void GC_CALL GC_clear_exclusion_table(void); + /* Clear the set of root segments. Wizards only. */ GC_API void GC_CALL GC_clear_roots(void); diff --git a/mark_rts.c b/mark_rts.c index a3fd4181..edc806a0 100644 --- a/mark_rts.c +++ b/mark_rts.c @@ -534,6 +534,11 @@ struct exclusion GC_excl_table[MAX_EXCLUSIONS]; STATIC size_t GC_excl_table_entries = 0;/* Number of entries in use. */ +GC_API void GC_CALL GC_clear_exclusion_table(void) +{ + GC_excl_table_entries = 0; +} + /* Return the first exclusion range that includes an address >= start_addr */ /* Assumes the exclusion table contains at least one entry (namely the */ /* GC data structures). */ diff --git a/tests/test.c b/tests/test.c index d939961f..a348c06f 100644 --- a/tests/test.c +++ b/tests/test.c @@ -1923,6 +1923,7 @@ void GC_CALLBACK warn_proc(char *msg, GC_word p) GC_noop1((GC_word)&Init); # endif n_tests = 0; + GC_clear_exclusion_table(); /* no-op as called before GC init */ # if defined(MACOS) /* Make sure we have lots and lots of stack space. */ SetMinimumStack(cMinStackSpace); -- cgit v1.2.1