summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2012-04-02 18:18:12 +0200
committerIvan Maidanski <ivmai@mail.ru>2012-04-03 06:11:06 +0200
commit1555aa8dd31db657c0ad5eed618757157783c2e5 (patch)
treefb25fe4a88a764a58ade41cf7d0a858cdddc0e3c /tests
parenta0e3b0d8444fcae8dbe6a4927f5dc626df81e0e9 (diff)
Add public GC_set_handle_fork to control forked child handling support
(Apply commit 1e882b9 from 'master' branch) * include/gc.h (GC_set_handle_fork): New API function. * misc.c (GC_set_handle_fork): Likewise. * include/private/gc_priv.h (GC_handle_fork): New internal variable declaration (only if CAN_HANDLE_FORK). * misc.c (GC_handle_fork): New internal variable (defined only if CAN_HANDLE_FORK); initialize to TRUE if HANDLE_FORK. * include/private/gcconfig.h (HANDLE_FORK): Replace with CAN_HANDLE_FORK. * pthread_support.c (HANDLE_FORK): Likewise. * win32_threads.c (HANDLE_FORK): Likewise. * include/private/gcconfig.h (CAN_HANDLE_FORK): Always define macro if HANDLE_FORK. * pthread_support.c (GC_thr_init): Replace HANDLE_FORK with CAN_HANDLE_FORK; call pthread_atfork only if GC_handle_fork; update the comment. * win32_threads.c (GC_thr_init): Likewise. * tests/test.c (NO_TEST_HANDLE_FORK): Define new macro if fork handling is not supported (or is a no-op) on the target. * tests/test.c (INIT_FORK_SUPPORT): New macro (invoke GC_set_handle_fork unless NO_TEST_HANDLE_FORK). * tests/test.c (GC_OPT_INIT): New macro (defined to GC_INIT or empty). * tests/test.c (GC_COND_INIT): Use INIT_FORK_SUPPORT and GC_OPT_INIT. * tests/test.c (run_one_test): Test NO_TEST_HANDLE_FORK (instead of target-specific macros). * win32_threads.c (GC_remove_all_threads_but_me, GC_fork_prepare_proc, GC_fork_parent_proc, GC_fork_child_proc): Do not test GC_PTHREADS. * configure.ac (HANDLE_FORK, NO_HANDLE_FORK): Update message.
Diffstat (limited to 'tests')
-rw-r--r--tests/test.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/tests/test.c b/tests/test.c
index 4366369..7912b06 100644
--- a/tests/test.c
+++ b/tests/test.c
@@ -86,8 +86,18 @@
# include <pthread.h>
# endif
-# if defined(THREADS) && defined(HANDLE_FORK)
+# if (!defined(THREADS) || !defined(HANDLE_FORK) \
+ || (defined(DARWIN) && defined(MPROTECT_VDB) \
+ && !defined(NO_INCREMENTAL) && !defined(MAKE_BACK_GRAPH))) \
+ && !defined(NO_TEST_HANDLE_FORK)
+# define NO_TEST_HANDLE_FORK
+# endif
+
+# ifndef NO_TEST_HANDLE_FORK
# include <unistd.h>
+# define INIT_FORK_SUPPORT GC_set_handle_fork(1)
+# else
+# define INIT_FORK_SUPPORT /* empty */
# endif
# if defined(GC_WIN32_THREADS) && !defined(GC_PTHREADS)
@@ -113,11 +123,14 @@
#if defined(CYGWIN32) || defined (AIX) || defined(DARWIN) \
|| defined(THREAD_LOCAL_ALLOC) \
|| (defined(MSWINCE) && !defined(GC_WINMAIN_REDIRECT))
-# define GC_COND_INIT() GC_INIT(); CHECH_GCLIB_VERSION; INIT_PRINT_STATS
+# define GC_OPT_INIT GC_INIT()
#else
-# define GC_COND_INIT() CHECH_GCLIB_VERSION; INIT_PRINT_STATS
+# define GC_OPT_INIT /* empty */
#endif
+#define GC_COND_INIT() \
+ INIT_FORK_SUPPORT; GC_OPT_INIT; CHECH_GCLIB_VERSION; INIT_PRINT_STATS
+
#define CHECK_OUT_OF_MEMORY(p) \
if ((p) == NULL) { \
GC_printf("Out of memory\n"); \
@@ -1253,11 +1266,7 @@ void run_one_test(void)
/* GC_allocate_ml and GC_need_to_lock are no longer exported, and */
/* AO_fetch_and_add1() may be unavailable to update a counter. */
(void)GC_call_with_alloc_lock(inc_int_counter, &n_tests);
-# if defined(THREADS) && defined(HANDLE_FORK) \
- && (!defined(DARWIN) || !defined(MPROTECT_VDB) \
- || defined(NO_INCREMENTAL) || defined(MAKE_BACK_GRAPH))
- /* FIXME: fork() is not tested on Darwin if incremental mode */
- /* is on for now (till it would be handled properly). */
+# ifndef NO_TEST_HANDLE_FORK
if (fork() == 0) {
GC_gcollect();
tiny_reverse_test(0);