From 0d465ef3937b8680fe3bf4dd2149f3ab14ac8e9e Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 20 May 2022 21:41:52 +0300 Subject: Define GC_get_parallel and GC_set_markers_count in single-threaded GC These are no-op definitions in case of the collector is built as a single-threaded one. This is useful for single threaded clients to be able to call these functions regardless of the collector is multi-threaded or not. * include/gc/gc.h [GC_THREADS] (GC_parallel): Reformat comment. * include/gc/gc.h (GC_get_parallel, GC_set_markers_count): Declare unconditionally. * misc.c [!PARALLEL_MARK] (GC_set_markers_count): Define (as no-op). * misc.c [!THREADS] (GC_get_parallel): Define (return 0). * pthread_support.c (GC_set_markers_count): Define only if PARALLEL_MARK; remove GC_ATTR_UNUSED. * win32_threads.c (GC_set_markers_count): Likewise. * tests/initfromthread.c (main): Call GC_get_suspend_signal() instead of GC_get_parallel(). --- win32_threads.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'win32_threads.c') diff --git a/win32_threads.c b/win32_threads.c index 2a415ac7..96f82068 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -2505,6 +2505,12 @@ GC_INNER void GC_get_next_stack(char *start, char *limit, static unsigned required_markers_cnt = 0; /* The default value (0) means the number of */ /* markers should be selected automatically. */ + + GC_API void GC_CALL GC_set_markers_count(unsigned markers) + { + /* The same implementation as in pthread_support.c. */ + required_markers_cnt = markers < MAX_MARKERS ? markers : MAX_MARKERS; + } #endif /* PARALLEL_MARK */ /* We have no DllMain to take care of new threads. Thus we */ @@ -2742,14 +2748,6 @@ GC_INNER void GC_get_next_stack(char *start, char *limit, #endif /* GC_WINMAIN_REDIRECT */ -GC_API void GC_CALL GC_set_markers_count(unsigned markers GC_ATTR_UNUSED) -{ - /* The same implementation as in pthread_support.c. */ -# ifdef PARALLEL_MARK - required_markers_cnt = markers < MAX_MARKERS ? markers : MAX_MARKERS; -# endif -} - GC_INNER void GC_thr_init(void) { struct GC_stack_base sb; -- cgit v1.2.1