How to access hs_free_fun_ptr from a Visual Studio DLL

Brian Hulley brianh at metamilk.com
Mon Mar 27 11:31:21 EST 2006


Sven Panne wrote:
> [snip]
> being executed. The technical reason for this is that after returning
> from Haskell land, the adjustor code might need to do some cleanup:
>
>    C -> adjustor -> stub -> Haskell -> stub -> adjustor -> C
>
> It could be the case that the adjustor tail-jumps to the stub, but
> this is not guaranteed to be the case for all platforms.

Thanks Sven. I had naively thought the wrapper stub was just a way to get a 
StablePtr and pass args to the Haskell function, but had not realised that 
adjustor code was needed also in the transition from Haskell back to C (it's 
obvious in retrospect now that you've pointed it out).

So I'll use your idea of a scavenger function, which I can call from my main 
event loop to be sure that no FunPtr's will directly or indirectly be 
freeing themselves (so that the DLL will be safe regardless of the 
particular Haskell implementation).

Thanks for the explanations,

Brian. 



More information about the Glasgow-haskell-users mailing list