packages feed

ghc-gc-hook 0.2.0.0 → 0.2.1.0

raw patch · 4 files changed

+18/−2 lines, 4 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -1,6 +1,13 @@ # Revision history for ghc-gc-hook  +## 0.2.1.0 -- 2022-06-03++* Now allows the host program to use TemplateHaskell, but the GC hook cannot be+  used inside a splice. The issue is that the `rtsConfig` symbol is not+  available inside a TH splice, so we need to use weak symbols to make it work.++ ## 0.2.0.0 -- 2022-04-25  * First version. Released on an unsuspecting world.
cbits/hook.c view
@@ -9,7 +9,7 @@ 	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 @@ 		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; @@ -286,3 +291,5 @@ 	mtx_unlock(&state_mutex); 	return retval; }++// vim: set noet sw=4 ts=4:
ghc-gc-hook.cabal view
@@ -7,7 +7,7 @@   information from Haskell in a bare-bones form; furthermore, it gives a small   usability improvement for running your own function from C using the hook   from this library.-version:             0.2.0.0+version:             0.2.1.0 category:            GHC license:             BSD3 license-file:        LICENSE
test/Main.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE ForeignFunctionInterface #-}+{-# LANGUAGE TemplateHaskell #-} module Main where  import Control.Monad (forM_, when)@@ -10,6 +11,7 @@  foreign import ccall "get_my_delegate_ptr" c_get_my_delegate_ptr :: IO (Ptr ()) +$(return [])  {-# NOINLINE invokeGCsometimes #-} invokeGCsometimes :: IO ()