diff options
Diffstat (limited to 'cbits')
-rw-r--r-- | cbits/hook.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/cbits/hook.c b/cbits/hook.c index b13576f..22aa259 100644 --- a/cbits/hook.c +++ b/cbits/hook.c @@ -9,7 +9,7 @@ static size_t min_sz(size_t a, size_t b) { return a < b ? a : b; } -extern RtsConfig rtsConfig; +extern RtsConfig __attribute__((weak)) rtsConfig; // A copy of GCDetails_ with known structure that can be depended on by the Haskell code. struct ShadowDetails { @@ -226,6 +226,11 @@ bool set_gchook(void) { goto unlock_return_retval; } + if (&rtsConfig == NULL) { + fprintf(stderr, "ghc-gc-hook: ERROR: rtsConfig not defined; the GC hook cannot be used from within a TemplateHaskell splice\n"); + goto unlock_return_retval; + } + old_hook = rtsConfig.gcDoneHook; rtsConfig.gcDoneHook = hook_callback; |