1 % -----------------------------------------------------------------------------
2 % $Id: PrelStable.lhs,v 1.9 2001/03/25 09:57:26 qrczak Exp $
4 % (c) The GHC Team, 1992-2000
7 \section{Module @PrelStable@}
10 {-# OPTIONS -fno-implicit-prelude #-}
14 , newStablePtr -- :: a -> IO (StablePtr a)
15 , deRefStablePtr -- :: StablePtr a -> a
16 , freeStablePtr -- :: StablePtr a -> IO ()
22 -----------------------------------------------------------------------------
25 data StablePtr a = StablePtr (StablePtr# a)
27 instance CCallable (StablePtr a)
28 instance CReturnable (StablePtr a)
30 newStablePtr :: a -> IO (StablePtr a)
31 newStablePtr a = IO $ \ s ->
32 case makeStablePtr# a s of (# s', sp #) -> (# s', StablePtr sp #)
34 deRefStablePtr :: StablePtr a -> IO a
35 deRefStablePtr (StablePtr sp) = IO $ \s -> deRefStablePtr# sp s
37 foreign import unsafe freeStablePtr :: StablePtr a -> IO ()
39 instance Eq (StablePtr a) where
40 (StablePtr sp1) == (StablePtr sp2) =
41 case eqStablePtr# sp1 sp2 of