Message "GHC/PrimopWrappers.hs:133:29: Not in scope: `GHC.Prim.quotInteger2Exp#'" building GHC with additional primitive operation

Simon Marlow simonmarhaskell at gmail.com
Fri Mar 31 05:50:32 EST 2006


Bulat Ziganshin wrote:
> Hello Thorkil,
> 
> Wednesday, March 29, 2006, 2:15:05 AM, you wrote:
> 
> 
>>>Thorkil, i can't understand why you can't just use FFI to import
>>>functions you required? why you need to patch the PrimOps list?
>>
>>As I wrote earlier, using FFI is also a candidate for getting access to
>>additional GMP functions. However, presently, I am not aware of a method of
>>doing this that does not involve some potentially significant additional
>>overhead. After all, Haskell Integers are not directly supported in C, so
>>some sort of marshalling and/or intricate access to internal GHC Haskell
>>structures would seem to be required.
> 
> 
> primitives work with just the same internal structures. i thinl that
> only real advantage of adding primop instead of adding FFI import is
> that PrimOps.cmm contains already implemented wrappers for calling GMP
> functions while for FFI you should implement them from scratch

And primops can be constant folded (probably not important in this case, 
though).

Also, because GMP operations need to allocate on the heap, special 
considerations apply in a multithreaded setting.  You can't call 
allocation routines from a foreign call in general without either having 
a Capability (allocateLocal()), or taking the storage manager lock 
(allocate()).  The primops have direct access to the current Capability, 
so they can just call allocateLocal() and don't need any locking operations.

Cheers,
	Simon


More information about the Glasgow-haskell-users mailing list