Newer
Older
minerva / Ports / bdwgc / patches / 0005-Make-the-collector-build-with-threads.patch
@minerva minerva on 13 Jul 2 KB Initial commit
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ali Mohammad Pur <ali.mpfard@gmail.com>
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 faca593e426ffb4add1a4eee73ef9ac1cdc23cbe..620662222d447fad399f713a537de58d1daa1432 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 529ca33d8cb19c9a1863609a81cc3fb9eb9847d3..50b715067be252299011f768f3d9f6d6fc05dbd6 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