Hi all,

I'm almost done with a FFI-based GMP binding (an attempt to remove
GHC's dependence on GMP primops). Currently I'm just using the default
GMP allocation functions (malloc/realloc/free), but it's tempting to
do as the current setup does and tell GMP to use the GHC allocator. I
have some questions about this:

1) stgAllocForGMP from rts/sm/Storage.c seems relatively general.
Maybe it, along with realloc and free (a dummy function?), could be
renamed externalAlloc and be "exported" (made non-static) to allow for
FFI bindings to call back into GHC's allocator (several libs allow
callers to override the default allocation functions)?
2) stgReallocForGMP currently appears to contain a manual memcpy (with
a for loop copying individual bytes). Is this for a specific reason?
3) If I do point my GMP binding to use the GHC allocator, would that
count as "calling back into haskell"? I really don't want to have to
mark any GMP function that may allocate as "safe" in my foreign import
declarations, but if it needs it there's not much I can do about it.
My integer benchmark suite should tell if it's necessary, anyway.

Thanks,
Dan

_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to