FFI questions

Simon Marlow simonmar at microsoft.com
Mon Jun 6 04:55:25 EDT 2005


On 06 June 2005 09:04, Gary Morris wrote:

> --- begin: AccuTime.hs
> 
> module AccuTime where
> 
> import Foreign.C.Types
> 
> foreign import stdcall unsafe "accutime.h accuticks" c_accuticks ::
> IO CULLong 
> 
> accuticks :: IO Integer
> accuticks = do ull <- c_accuticks
>                return (fromIntegral ull)
> 
> --- end
> 
> And then, after passing the correct -L and -l flags to ghci, attempted
> to load that module.  Unfortunately, I got:
> 
>    ___         ___ _
>   / _ \ /\  /\/ __(_)
>  / /_\// /_/ / /  | |      GHC Interactive, version 6.4, for Haskell
> 98. / /_\\/ __  / /___| |      http://www.haskell.org/ghc/
> \____/\/ /_/\____/|_|      Type :? for help.
> 
> Loading package base-1.0 ... linking ... done.
> Loading object (dynamic) AccuTime ... done
> final link ... done
> Prelude> :l AccuTime.hs
> Compiling AccuTime         ( AccuTime.hs, interpreted )
> ghc.exe: panic! (the `impossible' happened, GHC version 6.4):
>         ByteCodeFFI.mkMarshalCode_wrk(x86) L_
> 
> Please report it as a compiler bug to
> glasgow-haskell-bugs at haskell.org, 
> or http://sourceforge.net/projects/ghc/.

Yes, unfortunately it seems that long-long results from foreign
functions aren't supported by GHCi (on x86) right now.  Workaround is to
compile the module instead of interpreting it.

Cheers,
	Simon


More information about the Glasgow-haskell-users mailing list