Added support for GHC >= 7.4 (via conditional compilation)

This commit is contained in:
Ben Gamari 2012-03-19 18:22:53 +00:00
parent c0b4642cbc
commit 2893cdd167

View File

@ -88,7 +88,12 @@ import Foreign.C.String ( CString, withCString, peekCString )
import GHC ( defaultCallbacks ) import GHC ( defaultCallbacks )
#endif #endif
import GHC.Ptr ( Ptr(..), nullPtr ) import GHC.Ptr ( Ptr(..), nullPtr )
#if !MIN_VERSION_ghc(7,4,1)
import GHC.Exts ( addrToHValue# ) import GHC.Exts ( addrToHValue# )
#else
import GHC.Exts ( addrToAny# )
#endif
import GHC.Prim ( unsafeCoerce# ) import GHC.Prim ( unsafeCoerce# )
#if DEBUG #if DEBUG
@ -451,7 +456,11 @@ loadFunction__ pkg m valsym
ptr@(Ptr addr) <- withCString symbol c_lookupSymbol ptr@(Ptr addr) <- withCString symbol c_lookupSymbol
if (ptr == nullPtr) if (ptr == nullPtr)
then return Nothing then return Nothing
#if !MIN_VERSION_ghc(7,4,1)
else case addrToHValue# addr of else case addrToHValue# addr of
#else
else case addrToAny# addr of
#endif
(# hval #) -> return ( Just hval ) (# hval #) -> return ( Just hval )