From 5d0db8cb1fb58d5e5520699372a69f8580a07f23 Mon Sep 17 00:00:00 2001 From: hboehm Date: Tue, 14 Aug 2007 20:33:52 +0000 Subject: [PATCH] 2007-08-14 Hans Boehm (really mostly Samuel Thibault) * dbg_mlc.c: Use random() on all glibc systems. * mach_dep.c (GC_with_callee_saves_pushed): Don't use getcontext() on HURD. Add comment. * pthread_stop_world.c (GC_suspend_handler, GC_stop_init): Accomodate systems without SA_SIGINFO. --- ChangeLog | 8 ++++++++ dbg_mlc.c | 2 +- mach_dep.c | 5 ++++- pthread_stop_world.c | 23 ++++++++++++++++++++++- 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 40c37b2..0ec91a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-08-14 Hans Boehm (really mostly Samuel Thibault) + + * dbg_mlc.c: Use random() on all glibc systems. + * mach_dep.c (GC_with_callee_saves_pushed): Don't use getcontext() on + HURD. Add comment. + * pthread_stop_world.c (GC_suspend_handler, GC_stop_init): Accomodate + systems without SA_SIGINFO. + 2007-08-14 Hans Boehm (partly really Henrik Theiling) * include/gc.h (GC_PTR_STORE): Fix non-DEBUG parentheses. diff --git a/dbg_mlc.c b/dbg_mlc.c index 70a23ab..4bb0e13 100644 --- a/dbg_mlc.c +++ b/dbg_mlc.c @@ -61,7 +61,7 @@ GC_bool GC_has_other_debug_info(ptr_t p) # include -# if defined(LINUX) || defined(SOLARIS) \ +# if defined(__GLIBC__) || defined(SOLARIS) \ || defined(HPUX) || defined(IRIX5) || defined(OSF1) # define RANDOM() random() # else diff --git a/mach_dep.c b/mach_dep.c index 4f05843..0491a52 100644 --- a/mach_dep.c +++ b/mach_dep.c @@ -174,7 +174,8 @@ void GC_with_callee_saves_pushed(void (*fn)(ptr_t, void *), # if defined(HAVE_PUSH_REGS) GC_push_regs(); -# elif defined(UNIX_LIKE) && !defined(DARWIN) && !defined(ARM32) +# elif defined(UNIX_LIKE) && !defined(DARWIN) && !defined(ARM32) && \ + !defined(HURD) /* Older versions of Darwin seem to lack getcontext(). */ /* ARM Linux often doesn't support a real getcontext(). */ ucontext_t ctxt; @@ -219,6 +220,8 @@ void GC_with_callee_saves_pushed(void (*fn)(ptr_t, void *), /* _setjmp won't, but is less portable. */ # endif # endif /* !HAVE_PUSH_REGS ... */ + /* FIXME: context here is sometimes just zero. At the moment the callees */ + /* don't really need it. */ fn(arg, context); /* Strongly discourage the compiler from treating the above */ /* as a tail-call, since that would pop the register */ diff --git a/pthread_stop_world.c b/pthread_stop_world.c index 3a1524b..003edde 100644 --- a/pthread_stop_world.c +++ b/pthread_stop_world.c @@ -116,7 +116,11 @@ sem_t GC_suspend_ack_sem; void GC_suspend_handler_inner(ptr_t sig_arg, void *context); #if defined(IA64) || defined(HP_PA) || defined(M68K) +#ifdef SA_SIGINFO void GC_suspend_handler(int sig, siginfo_t *info, void *context) +#else +void GC_suspend_handler(int sig) +#endif { int old_errno = errno; GC_with_callee_saves_pushed(GC_suspend_handler_inner, (ptr_t)(word)sig); @@ -125,9 +129,16 @@ void GC_suspend_handler(int sig, siginfo_t *info, void *context) #else /* We believe that in all other cases the full context is already */ /* in the signal handler frame. */ +#ifdef SA_SIGINFO void GC_suspend_handler(int sig, siginfo_t *info, void *context) +#else +void GC_suspend_handler(int sig) +#endif { int old_errno = errno; +# ifndef SA_SIGINFO + void *context = 0; +# endif GC_suspend_handler_inner((ptr_t)(word)sig, context); errno = old_errno; } @@ -498,19 +509,29 @@ void GC_stop_init() { ABORT("sem_init failed"); # endif - act.sa_flags = SA_RESTART | SA_SIGINFO; + act.sa_flags = SA_RESTART +# ifdef SA_SIGINFO + | SA_SIGINFO +# endif + ; if (sigfillset(&act.sa_mask) != 0) { ABORT("sigfillset() failed"); } GC_remove_allowed_signals(&act.sa_mask); /* SIG_THR_RESTART is set in the resulting mask. */ /* It is unmasked by the handler when necessary. */ +# ifdef SA_SIGINFO act.sa_sigaction = GC_suspend_handler; +# else + act.sa_handler = GC_suspend_handler; +# endif if (sigaction(SIG_SUSPEND, &act, NULL) != 0) { ABORT("Cannot set SIG_SUSPEND handler"); } +# ifdef SA_SIGINFO act.sa_flags &= ~ SA_SIGINFO; +# endif act.sa_handler = GC_restart_handler; if (sigaction(SIG_THR_RESTART, &act, NULL) != 0) { ABORT("Cannot set SIG_THR_RESTART handler"); -- 2.7.4