Just as a follow-up for readers of this list about Daniel's issue with
binding GMP. I talked to Simon M about it yesterday and I've started
looking at implementing a "foreign import prim" that would allow us to
import the existing cmm code in the integer-gmp library with return
types like (# Int#, ByteArray# #).

I posted more details here:
http://blog.well-typed.com/2009/06/ghc-primops-and-exorcising-gmp/

Hopefully I'll post patches for review later today.

Duncan

On Sun, 2009-06-07 at 18:55 -0400, Daniel Peebles wrote:
> Hi again,
> 
> I've been working on the GMP "disengagement" recently, and have a
> fully functional GHC without a trace (no GMP primops, nothing related
> to them) of GMP in it now (using integer-simple as a replacement). I
> also, as part of a separate endeavor, have an FFI-based GMP library
> with bindings and wrappers for all the functions we need. Today I've
> been working towards getting another clean GHC tree based on my other
> clean one, using my integer-gmpffi package instead of integer-simple.
> I however ran into a fairly large obstacle: I can't use base. I took
> out all of my use of Control.Monad and the like from the wrapper
> functions, but the FFI bindings themselves are all along the lines of:
> 
> foreign import ccall "__gmpz_gcd" mpz_gcd :: MPZ -> MPZ -> MPZ -> IO ()
> 
> where MPZ is a synonym for a Ptr to a void type. Using
> -XUnliftedFFITypes, I can use Addr# instead of MPZ, but I have no idea
> what to do about IO (). I've tried "expanding" IO into State#
> RealWorld -> (# State# RealWorld, () #) but then the FFI complains
> that it's an inappropriate type for an FFI binding, which makes sense.
> 
> foreign import ccall "__gmpz_gcd" mpz_gcd :: Addr# -> Addr# -> Addr# -> ()
> 
> Seems like another possibility, but I'm not sure if it will get
> optimized incorrectly because of the lack of a state thread. I also
> need to (at least until we decide what to do about allocators) bind to
> malloc, which would I guess have a type of Word# -> Addr# ?
> 
> 
> Does anyone have any suggestions on what to do here? If someone can
> tell me of a safe way to approximate IO that satisfies the FFI spec, I
> can fix up my library and actually run some tests comparing the
> primop-based GMP And the ffi one (along with integer-simple, and the
> S#/J# stuff for each of them).
> 
> Thanks,
> Daniel
> 
> _______________________________________________
> Cvs-ghc mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/cvs-ghc

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

Reply via email to