summaryrefslogtreecommitdiff
path: root/compiler/ghci/LibFFI.hsc
diff options
context:
space:
mode:
authorIan Lynagh <ian@well-typed.com>2012-09-16 17:45:03 +0100
committerIan Lynagh <ian@well-typed.com>2012-09-16 17:45:03 +0100
commit17910899dacc892fd652d9206340d2bc2b2c5fc1 (patch)
treec39b870bea8c77390c19e6d9694d38aa931fc2ed /compiler/ghci/LibFFI.hsc
parenta62b56ef0b9d1750289ffd3f77b578dc73452374 (diff)
downloadhaskell-17910899dacc892fd652d9206340d2bc2b2c5fc1.tar.gz
Move wORD_SIZE into platformConstants
Diffstat (limited to 'compiler/ghci/LibFFI.hsc')
-rw-r--r--compiler/ghci/LibFFI.hsc21
1 files changed, 11 insertions, 10 deletions
diff --git a/compiler/ghci/LibFFI.hsc b/compiler/ghci/LibFFI.hsc
index 9bdabda0c2..128197109b 100644
--- a/compiler/ghci/LibFFI.hsc
+++ b/compiler/ghci/LibFFI.hsc
@@ -24,7 +24,7 @@ import TyCon
import ForeignCall
import Panic
-- import Outputable
-import Constants
+import DynFlags
import Foreign
import Foreign.C
@@ -35,20 +35,21 @@ import Text.Printf
type ForeignCallToken = C_ffi_cif
prepForeignCall
- :: CCallConv
+ :: DynFlags
+ -> CCallConv
-> [PrimRep] -- arg types
-> PrimRep -- result type
-> IO (Ptr ForeignCallToken) -- token for making calls
-- (must be freed by caller)
-prepForeignCall cconv arg_types result_type
+prepForeignCall dflags cconv arg_types result_type
= do
let n_args = length arg_types
arg_arr <- mallocArray n_args
- let init_arg (ty,n) = pokeElemOff arg_arr n (primRepToFFIType ty)
+ let init_arg (ty,n) = pokeElemOff arg_arr n (primRepToFFIType dflags ty)
mapM_ init_arg (zip arg_types [0..])
cif <- mallocBytes (#const sizeof(ffi_cif))
let abi = convToABI cconv
- let res_ty = primRepToFFIType result_type
+ let res_ty = primRepToFFIType dflags result_type
r <- ffi_prep_cif cif abi (fromIntegral n_args) res_ty arg_arr
if (r /= fFI_OK)
then ghcError (InstallationError
@@ -64,8 +65,8 @@ convToABI StdCallConv = fFI_STDCALL
convToABI _ = fFI_DEFAULT_ABI
-- c.f. DsForeign.primTyDescChar
-primRepToFFIType :: PrimRep -> Ptr C_ffi_type
-primRepToFFIType r
+primRepToFFIType :: DynFlags -> PrimRep -> Ptr C_ffi_type
+primRepToFFIType dflags r
= case r of
VoidRep -> ffi_type_void
IntRep -> signed_word
@@ -78,9 +79,9 @@ primRepToFFIType r
_ -> panic "primRepToFFIType"
where
(signed_word, unsigned_word)
- | wORD_SIZE == 4 = (ffi_type_sint32, ffi_type_uint32)
- | wORD_SIZE == 8 = (ffi_type_sint64, ffi_type_uint64)
- | otherwise = panic "primTyDescChar"
+ | wORD_SIZE dflags == 4 = (ffi_type_sint32, ffi_type_uint32)
+ | wORD_SIZE dflags == 8 = (ffi_type_sint64, ffi_type_uint64)
+ | otherwise = panic "primTyDescChar"
data C_ffi_type