From c49a6ca90100722cd6942322d32b64b4142a08a7 Mon Sep 17 00:00:00 2001 From: sof Date: Tue, 1 Apr 2003 15:05:22 +0000 Subject: [PATCH] [project @ 2003-04-01 15:05:13 by sof] Tidy up code that supports user/Haskell signal handlers. Signals.h now defines RTS_USER_SIGNALS when this is supported, which is then used elsewhere. --- ghc/rts/GC.c | 6 +++--- ghc/rts/RtsStartup.c | 4 ++-- ghc/rts/Schedule.c | 8 ++++---- ghc/rts/Select.c | 4 +++- ghc/rts/Signals.c | 34 ++++++++++++++++++++-------------- ghc/rts/Signals.h | 12 +++++------- 6 files changed, 37 insertions(+), 31 deletions(-) diff --git a/ghc/rts/GC.c b/ghc/rts/GC.c index 429746a..8cd4a2c 100644 --- a/ghc/rts/GC.c +++ b/ghc/rts/GC.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: GC.c,v 1.152 2003/03/26 15:56:25 simonmar Exp $ + * $Id: GC.c,v 1.153 2003/04/01 15:05:13 sof Exp $ * * (c) The GHC Team 1998-2003 * @@ -310,7 +310,7 @@ GarbageCollect ( void (*get_roots)(evac_fn), rtsBool force_major_gc ) Now, Now)); #endif -#ifndef mingw32_TARGET_OS +#if defined(RTS_USER_SIGNALS) // block signals blockUserSignals(); #endif @@ -1087,7 +1087,7 @@ GarbageCollect ( void (*get_roots)(evac_fn), rtsBool force_major_gc ) // ok, GC over: tell the stats department what happened. stat_endGC(allocated, collected, live, copied, N); -#ifndef mingw32_TARGET_OS +#if defined(RTS_USER_SIGNALS) // unblock signals again unblockUserSignals(); #endif diff --git a/ghc/rts/RtsStartup.c b/ghc/rts/RtsStartup.c index 4971bed..1c6ab40 100644 --- a/ghc/rts/RtsStartup.c +++ b/ghc/rts/RtsStartup.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: RtsStartup.c,v 1.72 2003/02/22 04:51:53 sof Exp $ + * $Id: RtsStartup.c,v 1.73 2003/04/01 15:05:15 sof Exp $ * * (c) The GHC Team, 1998-2002 * @@ -150,7 +150,7 @@ hs_init(int *argc, char **argv[]) /* Initialise the stats department */ initStats(); -#if !defined(mingw32_TARGET_OS) && !defined(PAR) +#if defined(RTS_USER_SIGNALS) /* Initialise the user signal handler set */ initUserSignals(); /* Set up handler to run on SIGINT, etc. */ diff --git a/ghc/rts/Schedule.c b/ghc/rts/Schedule.c index ed6c155..d572b15 100644 --- a/ghc/rts/Schedule.c +++ b/ghc/rts/Schedule.c @@ -1,5 +1,5 @@ /* --------------------------------------------------------------------------- - * $Id: Schedule.c,v 1.165 2003/03/25 17:58:50 sof Exp $ + * $Id: Schedule.c,v 1.166 2003/04/01 15:05:15 sof Exp $ * * (c) The GHC Team, 1998-2000 * @@ -589,7 +589,7 @@ schedule( void ) #endif // SMP /* check for signals each time around the scheduler */ -#ifndef mingw32_TARGET_OS +#if defined(RTS_USER_SIGNALS) if (signals_pending()) { RELEASE_LOCK(&sched_mutex); /* ToDo: kill */ startSignalHandlers(); @@ -656,7 +656,7 @@ schedule( void ) if ( !EMPTY_RUN_QUEUE() ) { goto not_deadlocked; } -#ifndef mingw32_TARGET_OS +#if defined(RTS_USER_SIGNALS) /* If we have user-installed signal handlers, then wait * for signals to arrive rather then bombing out with a * deadlock. @@ -2534,7 +2534,7 @@ GetRoots(evac_fn evac) markSparkQueue(evac); #endif -#ifndef mingw32_TARGET_OS +#if defined(RTS_USER_SIGNALS) // mark the signal handlers (signals should be already blocked) markSignalHandlers(evac); #endif diff --git a/ghc/rts/Select.c b/ghc/rts/Select.c index da0e124..70e0a03 100644 --- a/ghc/rts/Select.c +++ b/ghc/rts/Select.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Select.c,v 1.27 2003/03/29 00:00:41 sof Exp $ + * $Id: Select.c,v 1.28 2003/04/01 15:05:22 sof Exp $ * * (c) The GHC Team 1995-2002 * @@ -232,12 +232,14 @@ awaitEvent(rtsBool wait) * we could block for a long time before the signal is * serviced. */ +#if defined(RTS_USER_SIGNALS) if (signals_pending()) { RELEASE_LOCK(&sched_mutex); /* ToDo: kill */ startSignalHandlers(); ACQUIRE_LOCK(&sched_mutex); return; /* still hold the lock */ } +#endif /* we were interrupted, return to the scheduler immediately. */ diff --git a/ghc/rts/Signals.c b/ghc/rts/Signals.c index 9c767d4..4773006 100644 --- a/ghc/rts/Signals.c +++ b/ghc/rts/Signals.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Signals.c,v 1.36 2003/03/29 00:00:41 sof Exp $ + * $Id: Signals.c,v 1.37 2003/04/01 15:05:22 sof Exp $ * * (c) The GHC Team, 1998-1999 * @@ -32,7 +32,14 @@ #include -#ifndef PAR +/* This curious flag is provided for the benefit of the Haskell binding + * to POSIX.1 to control whether or not to include SA_NOCLDSTOP when + * installing a SIGCHLD handler. + * + */ +StgInt nocldstop = 0; + +#if defined(RTS_USER_SIGNALS) /* SUP: The type of handlers is a little bit, well, doubtful... */ static StgInt *handlers = NULL; /* Dynamically grown array of signal handlers */ @@ -45,9 +52,6 @@ static nat n_haskell_handlers = 0; StgPtr pending_handler_buf[N_PENDING_HANDLERS]; StgPtr *next_pending_handler = pending_handler_buf; -StgInt nocldstop = 0; - - #ifdef RTS_SUPPORTS_THREADS pthread_t signalHandlingThread; #endif @@ -338,20 +342,20 @@ markSignalHandlers (evac_fn evac) } } -#else // PAR +#else /* !RTS_USER_SIGNALS */ StgInt -stg_sig_install(StgInt sig, StgInt spi, StgStablePtr handler, sigset_t *mask) +stg_sig_install(StgInt sig STG_UNUSED, + StgInt spi STG_UNUSED, + StgStablePtr* handler STG_UNUSED, + void* mask STG_UNUSED) { - // don't fflush(stdout); WORKAROUND bug in Linux glibc - barf("no signal handling support in a parallel implementation"); + //barf("User signals not supported"); + return STG_SIG_DFL; } -void -startSignalHandlers(void) -{ -} #endif +#if defined(RTS_USER_SIGNALS) /* ----------------------------------------------------------------------------- * SIGINT handler. * @@ -421,7 +425,7 @@ initDefaultHandlers() startup_guy = pthread_self(); #endif #ifdef RTS_SUPPORTS_THREADS - handleSignalsInThisThread(); + handleSignalsInThisThread(); #endif // install the SIGINT handler @@ -467,3 +471,5 @@ initDefaultHandlers() ieee_set_fp_control(0); #endif } + +#endif /* RTS_USER_SIGNALS */ diff --git a/ghc/rts/Signals.h b/ghc/rts/Signals.h index cddb4ba..3318101 100644 --- a/ghc/rts/Signals.h +++ b/ghc/rts/Signals.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Signals.h,v 1.10 2003/03/29 00:00:43 sof Exp $ + * $Id: Signals.h,v 1.11 2003/04/01 15:05:22 sof Exp $ * * (c) The GHC Team, 1998-1999 * @@ -7,7 +7,8 @@ * * ---------------------------------------------------------------------------*/ -#ifndef PAR +#if !defined(PAR) && !defined(mingw32_TARGET_OS) +#define RTS_USER_SIGNALS 1 extern StgPtr pending_handler_buf[]; extern StgPtr *next_pending_handler; @@ -27,14 +28,11 @@ extern void startSignalHandlers(void); extern void markSignalHandlers (evac_fn evac); extern void initDefaultHandlers(void); -#if !defined(mingw32_TARGET_OS) extern void handleSignalsInThisThread(void); -#else -#define handleSignalsInThisThread() /* nothing */ -#endif #else #define signals_pending() (rtsFalse) +#define handleSignalsInThisThread() /* nothing */ -#endif /* PAR */ +#endif /* !PAR && !mingw32_TARGET_OS */ -- 1.7.10.4