X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Flib%2Fexts%2FForeign.lhs;h=eaf8ef3775423d023814600fe98150d1c01c6ccc;hb=119403dd981ee59d380c8decfdf4b91da2299d67;hp=29f5e3be9793703e120ea8eac1f783f37d4595f6;hpb=bb3f4825ccd0b18b046a8140f70e854a3068a269;p=ghc-hetmet.git diff --git a/ghc/lib/exts/Foreign.lhs b/ghc/lib/exts/Foreign.lhs index 29f5e3b..eaf8ef3 100644 --- a/ghc/lib/exts/Foreign.lhs +++ b/ghc/lib/exts/Foreign.lhs @@ -7,9 +7,12 @@ \begin{code} module Foreign ( - ForeignObj -- abstract, instance of: Eq - , makeForeignObj -- :: Addr{-obj-} -> Addr{-finaliser-} -> IO ForeignObj - , writeForeignObj -- :: ForeignObj -> Addr{-new obj-} -> IO () + ForeignObj -- abstract, instance of: Eq + , makeForeignObj -- :: Addr{-obj-} -> Addr{-finaliser-} -> IO ForeignObj + , writeForeignObj -- :: ForeignObj -> Addr{-new obj-} -> IO () + , foreignObjToAddr -- :: ForeignObj -> IO Addr + -- the coercion from a foreign obj. to an addr. is unsafe, + -- and should not be used unless absolutely necessary. , StablePtr {-a-} -- abstract. , makeStablePtr -- :: a -> IO (StablePtr a) @@ -103,6 +106,12 @@ import PrelIOBase ( IO(..), IOResult(..) ) \end{code} \begin{code} +foreignObjToAddr :: ForeignObj -> IO Addr +foreignObjToAddr fo = _casm_ `` %r=(StgAddr)%0; '' fo +\end{code} + + +\begin{code} indexCharOffForeignObj :: ForeignObj -> Int -> Char indexCharOffForeignObj (ForeignObj fo#) (I# i#) = C# (indexCharOffForeignObj# fo# i#)