From: Andy Wingo Date: Mon, 20 Feb 2012 17:51:21 +0000 (+0400) Subject: Fix gcconfig to turn on POSIX fork() support by default X-Git-Tag: gc7_2~60 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0ba0d226263968ca7021f55a8c7a6726ff8d586f;p=gc 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. --- diff --git a/doc/README.macros b/doc/README.macros index a6291baf..c745eb35 100644 --- a/doc/README.macros +++ b/doc/README.macros @@ -433,9 +433,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 310afdff..3ab71560 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -2591,6 +2591,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. */