#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
#if USE_PAPI
#include "Papi.h"
return;
}
-#if defined(DEBUG)
- /* Start off by initialising the allocator debugging so we can
- * use it anywhere */
- initAllocator();
-#endif
+ /* Initialise the stats department, phase 0 */
+ initStats0();
/* Next we do is grab the start time...just in case we're
* collecting timing statistics.
*/
stat_startInit();
+#if defined(DEBUG)
+ /* Start off by initialising the allocator debugging so we can
+ * use it anywhere */
+ initAllocator();
+#endif
+
#ifdef PAR
/*
* The parallel system needs to be initialised and synchronised before
argv++; argc--;
#endif
- /* Initialise the performance tracking library */
-#ifdef USE_PAPI
- {
- int ver;
- if ((ver = PAPI_library_init(PAPI_VER_CURRENT)) != PAPI_VER_CURRENT) {
- if (ver > 0) {
- errorBelch("PAPI_library_init: wrong version: %x", ver);
- stg_exit(EXIT_FAILURE);
- } else {
- sysErrorBelch("PAPI_library_init");
- stg_exit(EXIT_FAILURE);
- }
- }
- }
-#ifdef THREADED_RTS
- {
- int err;
- if ((err = PAPI_thread_init(osThreadId)) < 0) {
- barf("PAPI_thread_init: %d",err);
- }
- }
-#endif
-#endif
-
/* Set the RTS flags to default values. */
initRtsFlagsDefaults();
setProgArgv(*argc,*argv);
}
+ /* Initialise the stats department, phase 1 */
+ initStats1();
+
+#ifdef USE_PAPI
+ papi_init();
+#endif
+
/* initTracing must be after setupRtsFlags() */
initTracing();
initTimer();
startTimer();
- /* Initialise the stats department */
- initStats();
-
#if defined(RTS_USER_SIGNALS)
if (RtsFlags.MiscFlags.install_signal_handlers) {
/* Initialise the user signal handler set */
/* start timing the shutdown */
stat_startExit();
+ OnExitHook();
+
#if defined(RTS_USER_SIGNALS)
if (RtsFlags.MiscFlags.install_signal_handlers) {
freeSignalHandlers();
PAR_TICKY_PAR_END();
#endif
+ // uninstall signal handlers
+ resetDefaultHandlers();
+
/* stop timing the shutdown, we're about to print stats */
stat_endExit();
void
shutdownHaskellAndExit(int n)
{
- if (hs_init_count == 1) {
- OnExitHook();
- hs_exit_(rtsFalse);
- // we're about to exit(), no need to wait for foreign calls to return.
+ // we're about to exit(), no need to wait for foreign calls to return.
+ hs_exit_(rtsFalse);
+
+ if (hs_init_count == 0) {
#if defined(PAR)
/* really exit (stg_exit() would call shutdownParallelSystem() again) */
exit(n);
}
}
+#ifndef mingw32_HOST_OS
+void
+shutdownHaskellAndSignal(int sig)
+{
+ hs_exit_(rtsFalse);
+ kill(getpid(),sig);
+}
+#endif
+
/*
* called from STG-land to exit the program
*/