Commit c49a6ca9 authored by sof's avatar sof
Browse files

[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.
parent 999f8cf9
/* -----------------------------------------------------------------------------
* $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
......
/* -----------------------------------------------------------------------------
* $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. */
......
/* ---------------------------------------------------------------------------
* $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
......
/* -----------------------------------------------------------------------------
* $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.
*/
......
/* -----------------------------------------------------------------------------
* $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 <stdlib.h>
#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 */
/* -----------------------------------------------------------------------------
* $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 */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment