From 119403dd981ee59d380c8decfdf4b91da2299d67 Mon Sep 17 00:00:00 2001 From: sof <unknown> Date: Wed, 21 Oct 1998 11:40:36 +0000 Subject: [PATCH] [project @ 1998-10-21 11:40:36 by sof] Oops, previous commit msg was a bit off; foreignObjToAddr added, but to this interface (Foreign.) Addr was augmented with writeForeignObjOffAddr though. --- ghc/lib/exts/Foreign.lhs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ghc/lib/exts/Foreign.lhs b/ghc/lib/exts/Foreign.lhs index 29f5e3be9793..eaf8ef377542 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) @@ -102,6 +105,12 @@ import Int 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#) -- GitLab