From 6b73b6e90bd0ed96b40fac85580cb0b6caf65083 Mon Sep 17 00:00:00 2001 From: Kristian Larsson Date: Thu, 17 Nov 2022 10:11:28 +0300 Subject: [PATCH] Do not prohibit threaded builds with malloc redirection on non-Linux Issue #478 (bdwgc). The malloc (and friends) redirection in a multi-threaded client may work even on platforms other than Linux (as confirmed on MacOS) provided the client ensures all the client threads are registered with the collector, e.g. by using the preprocessor-based interception of the thread primitives (i.e., define GC_THREADS and include gc.h from all the client files those are using pthread_create and friends). * include/private/gcconfig.h [!CPPCHECK && REDIRECT_MALLOC && THREADS && !LINUX && !REDIRECT_MALLOC_IN_HEADER]: Remove error preprocessor directive; add comment. --- include/private/gcconfig.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index 7ba9064bb..d279ba23e 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -3243,7 +3243,11 @@ EXTERN_C_BEGIN # endif # if defined(REDIRECT_MALLOC) && defined(THREADS) && !defined(LINUX) \ && !defined(REDIRECT_MALLOC_IN_HEADER) -# error REDIRECT_MALLOC with THREADS works at most on Linux + /* May work on other platforms (e.g. Darwin) provided the client */ + /* ensures all the client threads are registered with the GC, */ + /* e.g. by using the preprocessor-based interception of the thread */ + /* primitives (i.e., define GC_THREADS and include gc.h from all */ + /* the client files those are using pthread_create and friends). */ # endif #endif /* !CPPCHECK */