X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Flib%2Fstd%2FPrelForeign.lhs;h=ef4f81551b467a46dc01aab09a350ee6f18d06cd;hb=a103a9dc0de992716e62c30d7ac81c0bc0dbcdc5;hp=a61d27aa8cfae181c4b7b055f3e424a3f5b145e5;hpb=438596897ebbe25a07e1c82085cfbc5bdb00f09e;p=ghc-hetmet.git diff --git a/ghc/lib/std/PrelForeign.lhs b/ghc/lib/std/PrelForeign.lhs index a61d27a..ef4f815 100644 --- a/ghc/lib/std/PrelForeign.lhs +++ b/ghc/lib/std/PrelForeign.lhs @@ -5,7 +5,7 @@ \section[Foreign]{Module @Foreign@} \begin{code} -{-# OPTIONS -fno-implicit-prelude #-} +{-# OPTIONS -fcompiling-prelude -fno-implicit-prelude #-} module PrelForeign ( module PrelForeign, @@ -19,7 +19,6 @@ module PrelForeign ( import PrelIOBase import PrelST import PrelBase -import PrelCCall import PrelAddr import PrelGHC \end{code} @@ -41,65 +40,11 @@ makeForeignObj (A# obj) = IO ( \ s# -> case makeForeignObj# obj s# of (# s1#, fo# #) -> (# s1#, ForeignObj fo# #) ) -eqForeignObj :: ForeignObj -> ForeignObj -> Bool --makeForeignObj :: Addr -> Addr -> IO ForeignObj writeForeignObj :: ForeignObj -> Addr -> IO () writeForeignObj (ForeignObj fo#) (A# datum#) = IO ( \ s# -> case writeForeignObj# fo# datum# s# of { s1# -> (# s1#, () #) } ) - -eqForeignObj mp1 mp2 - = unsafePerformIO (_ccall_ eqForeignObj mp1 mp2) /= (0::Int) - -instance Eq ForeignObj where - p == q = eqForeignObj p q - p /= q = not (eqForeignObj p q) -#endif /* !__PARALLEL_HASKELL__ */ -\end{code} - -%********************************************************* -%* * -\subsection{Type @StablePtr@ and its operations} -%* * -%********************************************************* - -\begin{code} -#ifndef __PARALLEL_HASKELL__ -data StablePtr a = StablePtr (StablePtr# a) -instance CCallable (StablePtr a) -instance CCallable (StablePtr# a) -instance CReturnable (StablePtr a) - --- Nota Bene: it is important {\em not\/} to inline calls to --- @makeStablePtr#@ since the corresponding macro is very long and we'll --- get terrible code-bloat. - -makeStablePtr :: a -> IO (StablePtr a) -deRefStablePtr :: StablePtr a -> IO a -freeStablePtr :: StablePtr a -> IO () - -{-# INLINE deRefStablePtr #-} -{-# INLINE freeStablePtr #-} - -makeStablePtr f = IO $ \ rw1# -> - case makeStablePtr# f rw1# of - (# rw2#, sp# #) -> (# rw2#, StablePtr sp# #) - -deRefStablePtr (StablePtr sp#) = IO $ \ rw1# -> - deRefStablePtr# sp# rw1# - -freeStablePtr sp = _ccall_ freeStablePointer sp - -eqStablePtr :: StablePtr a -> StablePtr b -> Bool -eqStablePtr (StablePtr sp1#) (StablePtr sp2#) = - case eqStablePtr# sp1# sp2# of - 0# -> False - _ -> True - -instance Eq (StablePtr a) where - p == q = eqStablePtr p q - p /= q = not (eqStablePtr p q) - #endif /* !__PARALLEL_HASKELL__ */ \end{code}