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.
/* -----------------------------------------------------------------------------
- * $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
*
Now, Now));
#endif
-#ifndef mingw32_TARGET_OS
+#if defined(RTS_USER_SIGNALS)
// block signals
blockUserSignals();
#endif
// 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
*
/* 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
*
#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();
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.
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
*
* 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
*
#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 */
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
}
}
-#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.
*
startup_guy = pthread_self();
#endif
#ifdef RTS_SUPPORTS_THREADS
- handleSignalsInThisThread();
+ handleSignalsInThisThread();
#endif
// install the SIGINT handler
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
*
*
* ---------------------------------------------------------------------------*/
-#ifndef PAR
+#if !defined(PAR) && !defined(mingw32_TARGET_OS)
+#define RTS_USER_SIGNALS 1
extern StgPtr pending_handler_buf[];
extern StgPtr *next_pending_handler;
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 */