This is a continuation of my previous question here . I was able to get something working for Reid Barton's answer , but I noticed mostly I see __pkg_ccall_GC :
case {__pkg_ccall_GC hashabler-2.0.0 sipRound_s_x2 Word
What I think about what you expect from a "safe" ffi call. However, adding "unsafe" to the import import string is not allowed (although error messages do not say why):
src/Data/Hashabler/SipHash.hs:60:1: error: β’ The safe/unsafe annotation should not be used with `foreign import prim'. β’ When checking declaration: foreign import prim unsafe "static sipRound_s_x4" sipRound_s_x4# :: Word# -> Word# -> Word# -> Word# -> (# Word#, Word#, Word#, Word# #)
My external procedure is few in number, but a little cool, so I donβt think I want what _GC gives _GC . Some relevant GHC source bits I looked at are FWIW and background:
compiler / prelude / ForeignCall.hs: only "risky" skips "_GC"
data Safety = PlaySafe
I also see some foreign import prim unsafe and ... safe in the GHC tree, although I assume this is dead code. e.g. testsuite/tests/printer/Ppr046.hs .
So my questions are:
- What is the difference between the code created with
__pkg_ccall_GC vs a __pkg_ccall (where do I do foreign import prim not ccall )? Is it the same as described here ? - Why is
foreign import prim unsafe not supported? - Assuming I understand (1): Is there a way around this by getting both the effective return of multiple values ββand avoiding what happens in accounting (1)?
EDIT . Looking at the assembly from -ddump-asm , it clearly shows that nothing is happening (it shouldn't have been scary to look at the assembly), refer to Reid Burton's comment below:
movq %rdi,%rax movq %r8,%rdi xorq %r9,%rdi movq %rsi,%rcx movq %rax,%rsi movq %r14,%rax movq %rcx,%r14 movq %rbx,%rcx movq %rax,%rbx movq %r9,-8(%rbp) movq %rcx,(%rbp) addq $-16,%rbp jmp sipRound_s_x2
xorq at the top corresponds to haskell xor . All of these movq really seem like debris, though ...