From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Mon, 27 Mar 2023 20:14:33 +1100 Subject: [PATCH] Make the collector build with threads In an extremely limited way for now: - No extra threads More threads always lead to exactly one borked thread that's stuck in no man's land, doing who-knows-what, and definitely not responding to signals. However, the APIs are there and they work, so they *can* be used to make threads. - No fork handling Seems borked for unknown reasons. Co-Authored-By: EWouters <6179932+EWouters@users.noreply.github.com> --- CMakeLists.txt | 6 +++++- tests/test.c | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ddb04eece816e6c0440376210b514f964b66e3b1..c9e776d87d550f10505d89027a153d1cad575608 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,7 +86,11 @@ option(enable_register_main_static_data "Perform the initial guess of data root option(enable_checksums "Report erroneously cleared dirty bits" OFF) option(enable_werror "Pass -Werror to the C compiler (treat warnings as errors)" OFF) option(enable_single_obj_compilation "Compile all libgc source files into single .o" OFF) -option(enable_handle_fork "Attempt to ensure a usable collector after fork()" ON) +IF(DEBUG_THREADS) + ADD_DEFINITIONS("-DDEBUG_THREADS") +ENDIF() + +OPTION(enable_handle_fork "Attempt to ensure a usable collector after fork()" OFF) option(disable_handle_fork "Prohibit installation of pthread_atfork() handlers" OFF) option(enable_emscripten_asyncify "Use Emscripten asyncify feature" OFF) option(install_headers "Install header and pkg-config metadata files" ON) diff --git a/tests/test.c b/tests/test.c index 8afc0fe7a1d2fdba644b9f762c6c34ee19bac4db..5d7d59e2e734da4fee44144edf9f33838a8ed0ed 100644 --- a/tests/test.c +++ b/tests/test.c @@ -43,7 +43,7 @@ #include "gc.h" #ifndef NTHREADS /* Number of additional threads to fork. */ -# define NTHREADS 5 /* Excludes main thread, which also runs a test. */ +# define NTHREADS 0 /* Excludes main thread, which also runs a test. */ /* In the single-threaded case, the number of times to rerun it. */ /* Not respected by PCR test. */ #endif