summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2014-06-09 09:18:12 +0100
committerSimon Marlow <marlowsd@gmail.com>2015-04-07 09:57:49 +0100
commita7ab161602aa0b5833d22c66e64eebb1d9275235 (patch)
tree22db09216cbd2165359d8add08b5cf4cdbf5041f /includes
parent72092904e0ac1725c05c0447e1efe7ab541faa95 (diff)
downloadhaskell-a7ab161602aa0b5833d22c66e64eebb1d9275235.tar.gz
Replace hooks by callbacks in RtsConfig (#8785)
Summary: Hooks rely on static linking semantics, and are broken by -Bsymbolic which we need when using dynamic linking. Test Plan: Built it Reviewers: austin, hvr, tibbe Differential Revision: https://phabricator.haskell.org/D8
Diffstat (limited to 'includes')
-rw-r--r--includes/Rts.h1
-rw-r--r--includes/RtsAPI.h33
-rw-r--r--includes/rts/Hooks.h26
3 files changed, 33 insertions, 27 deletions
diff --git a/includes/Rts.h b/includes/Rts.h
index 77eeb31f3a..190200aa34 100644
--- a/includes/Rts.h
+++ b/includes/Rts.h
@@ -220,7 +220,6 @@ INLINE_HEADER Time fsecondsToTime (double t)
/* Other RTS external APIs */
#include "rts/Parallel.h"
-#include "rts/Hooks.h"
#include "rts/Signals.h"
#include "rts/BlockSignals.h"
#include "rts/Hpc.h"
diff --git a/includes/RtsAPI.h b/includes/RtsAPI.h
index 0ba16714e9..853a3a5b30 100644
--- a/includes/RtsAPI.h
+++ b/includes/RtsAPI.h
@@ -60,9 +60,42 @@ typedef enum {
// reason for using a struct is extensibility: we can add more
// fields to this later without breaking existing client code.
typedef struct {
+
+ // Whether to interpret +RTS options on the command line
RtsOptsEnabledEnum rts_opts_enabled;
+
+ // additional RTS options
const char *rts_opts;
+
+ // True if GHC was not passed -no-hs-main
HsBool rts_hs_main;
+
+ // Called before processing command-line flags, so that default
+ // settings for RtsFlags can be provided.
+ void (* defaultsHook) (void);
+
+ // Called just before exiting
+ void (* onExitHook) (void);
+
+ // Called on a stack overflow, before exiting
+ void (* stackOverflowHook) (W_ stack_size);
+
+ // Called on heap overflow, before exiting
+ void (* outOfHeapHook) (W_ request_size, W_ heap_size);
+
+ // Called when malloc() fails, before exiting
+ void (* mallocFailHook) (W_ request_size /* in bytes */, char *msg);
+
+ // Called for every GC
+ void (* gcDoneHook) (unsigned int gen,
+ W_ allocated_bytes, /* since last GC */
+ W_ live_bytes,
+ W_ copied_bytes,
+ W_ max_copied_per_thread_bytes,
+ W_ total_bytes,
+ W_ slop_bytes,
+ W_ sync_elapsed_ns, W_ elapsed_ns, W_ cpu_ns);
+
} RtsConfig;
// Clients should start with defaultRtsConfig and then customise it.
diff --git a/includes/rts/Hooks.h b/includes/rts/Hooks.h
deleted file mode 100644
index bf69673d70..0000000000
--- a/includes/rts/Hooks.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* -----------------------------------------------------------------------------
- *
- * (c) The GHC Team, 1998-2009
- *
- * User-overridable RTS hooks.
- *
- * Do not #include this file directly: #include "Rts.h" instead.
- *
- * To understand the structure of the RTS headers, see the wiki:
- * http://ghc.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
- *
- * ---------------------------------------------------------------------------*/
-
-#ifndef RTS_HOOKS_H
-#define RTS_HOOKS_H
-
-extern char *ghc_rts_opts;
-
-extern void OnExitHook (void);
-extern int NoRunnableThreadsHook (void);
-extern void StackOverflowHook (W_ stack_size);
-extern void OutOfHeapHook (W_ request_size, W_ heap_size);
-extern void MallocFailHook (W_ request_size /* in bytes */, char *msg);
-extern void defaultsHook (void);
-
-#endif /* RTS_HOOKS_H */