`foreign import ccall "dynamic"` syntax is not documented, safety properties unknown
I did some searching in the user manual and haddocks (generated from master
branch) -- as far as I can see the only documentation we have for the foreign import ccall "dynamic"
syntax is this one sentence in Foreign.Ptr
haddocs:
-- To convert 'FunPtr' values to corresponding Haskell functions, one
-- can define a /dynamic/ stub for the specific foreign type, e.g.
--
-- > type IntFunction = CInt -> IO ()
-- > foreign import ccall "dynamic"
-- > mkFun :: FunPtr IntFunction -> IntFunction
Main question I had is whether a function called via a "dynamic" wrapper would have properties of a "safe" call (GC may happen) or an "unsafe" call (no GC during the call).
Looking at the code, I can see that we call dsFImport
with safety == PlaySafe
, but maybe that's the safety of the mkFun
(the wrapper) and not the
actual FFI call, I'm not sure.
In any case this should be documented somewhere.