% ------------------------------------------------------------------------------
-% $Id: PrelForeign.lhs,v 1.17 2001/01/11 17:25:57 simonmar Exp $
+% $Id: PrelForeign.lhs,v 1.20 2001/07/16 00:39:04 sof Exp $
%
% (c) The University of Glasgow, 1994-2000
%
module PrelForeign where
import PrelIOBase
+import PrelNum -- for fromInteger
import PrelBase
import PrelPtr
\end{code}
%*********************************************************
\begin{code}
-#ifndef __PARALLEL_HASKELL__
+data ForeignPtr a = ForeignPtr ForeignObj#
+instance CCallable (ForeignPtr a)
+
+eqForeignPtr :: ForeignPtr a -> ForeignPtr a -> Bool
+eqForeignPtr (ForeignPtr fo1#) (ForeignPtr fo2#) = eqForeignObj# fo1# fo2#
+
+instance Eq (ForeignPtr a) where
+ p == q = eqForeignPtr p q
+ p /= q = not (eqForeignPtr p q)
+
newForeignPtr :: Ptr a -> IO () -> IO (ForeignPtr a)
newForeignPtr p finalizer
= do fObj <- mkForeignPtr p
foreignPtrToPtr (ForeignPtr fo) = Ptr (foreignObjToAddr# fo)
castForeignPtr (ForeignPtr a) = ForeignPtr a
-#endif
+
\end{code}