From e9b11b6655c45ad3ab3326707aa31567a767134b Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Mon, 20 Feb 2012 21:51:21 +0400 Subject: [PATCH] Fix gcconfig to turn on POSIX fork() support by default (define HANDLE_FORK on Unix platforms with pthreads) * doc/README.macros (HANDLE_FORK): Replace with NO_HANDLE_FORK; update the documentation. * include/private/gcconfig.h (HANDLE_FORK): Explicitly define if GC_PTHREADS unless already defined or NO_HANDLE_FORK is defined, or unsupported on the target. --- doc/README.macros | 6 +++--- include/private/gcconfig.h | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/doc/README.macros b/doc/README.macros index 1136f3a..659e958 100644 --- a/doc/README.macros +++ b/doc/README.macros @@ -435,9 +435,9 @@ STUBBORN_ALLOC Allows allocation of "hard to change" objects, and thus makes incremental collection easier. Was enabled by default until 6.0. Rarely used, to my knowledge. -HANDLE_FORK Attempts to make GC_malloc() work in a child process fork()'ed - from a multithreaded parent. Currently only supported by pthread_support.c. - (Similar code should work on Solaris or Irix, but it hasn't been tried.) +NO_HANDLE_FORK (Unix only) Do not attempt to make GC_malloc() work in + a child process fork()'ed from a multi-threaded parent. (Might be required + if pthread_atfork is missing.) TEST_WITH_SYSTEM_MALLOC Causes gctest to allocate (and leak) large chunks of memory with the standard system malloc. This will cause the root diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index d9c1d63..a2ba20d 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -2612,6 +2612,14 @@ # define IF_CANCEL(x) /* empty */ #endif +#if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS) \ + && !defined(HANDLE_FORK) && !defined(NO_HANDLE_FORK) \ + && !defined(HURD) && !defined(NACL) && !defined(PLATFORM_ANDROID) + /* Attempts (where supported) to make GC_malloc work in a child */ + /* process fork'ed from a multi-threaded parent. */ +# define HANDLE_FORK +#endif + #if !defined(USE_MARK_BITS) && !defined(USE_MARK_BYTES) \ && defined(PARALLEL_MARK) /* Minimize compare-and-swap usage. */ -- 2.7.4