summaryrefslogtreecommitdiff
path: root/os_dep.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2012-04-02 20:31:22 +0200
committerIvan Maidanski <ivmai@mail.ru>2012-04-03 06:15:54 +0200
commitcad34343056a5f9b4598b5ddc36ed8ce0e264399 (patch)
treeb0e0408635970f85a7584372ad6557449c1122f4 /os_dep.c
parent1555aa8dd31db657c0ad5eed618757157783c2e5 (diff)
FIX: Disable incremental mode on Darwin if fork handling requested
* doc/README.macros (NO_HANDLE_FORK): Replace back with HANDLE_FORK and update. * include/private/gcconfig.h (CAN_HANDLE_FORK): Define also for Darwin in case of MPROTECT_VDB. * misc.c (GC_set_handle_fork): Handle Darwin properly; add comment. * os_dep.c (GC_dirty_init): Do not turn on GC_dirty_maintained for Darwin if GC_handle_fork is on; add comment; remove FIXME. * pthread_support.c (GC_fork_prepare_proc): Remove WARN for Darwin (since GC_dirty_maintained is off in that case). * pthread_support.c (GC_fork_child_proc): Remove comment (for Darwin).
Diffstat (limited to 'os_dep.c')
-rw-r--r--os_dep.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/os_dep.c b/os_dep.c
index 070756a..17dabcd 100644
--- a/os_dep.c
+++ b/os_dep.c
@@ -4094,6 +4094,21 @@ GC_INNER void GC_dirty_init(void)
pthread_attr_t attr;
exception_mask_t mask;
+# ifdef CAN_HANDLE_FORK
+ if (GC_handle_fork) {
+ /* To both support GC incremental mode and GC functions usage in */
+ /* the forked child, pthread_atfork should be used to install */
+ /* handlers that switch off GC_dirty_maintained in the child */
+ /* gracefully (unprotecting all pages and clearing */
+ /* GC_mach_handler_thread). For now, we just disable incremental */
+ /* mode if fork() handling is requested by the client. */
+ if (GC_print_stats)
+ GC_log_printf(
+ "GC incremental mode disabled since fork() handling requested\n");
+ return;
+ }
+# endif
+
if (GC_print_stats == VERBOSE)
GC_log_printf(
"Initializing mach/darwin mprotect virtual dirty bit implementation\n");
@@ -4142,10 +4157,6 @@ GC_INNER void GC_dirty_init(void)
if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) != 0)
ABORT("pthread_attr_setdetachedstate failed");
-# if defined(HANDLE_FORK) && !defined(THREADS)
- /* FIXME: See comment in GC_fork_prepare_proc. */
-# endif
-
# undef pthread_create
/* This will call the real pthread function, not our wrapper */
if (pthread_create(&thread, &attr, GC_mprotect_thread, NULL) != 0)