1 % -----------------------------------------------------------------------------
2 % $Id: PrelStable.lhs,v 1.3 1999/12/20 10:34:35 simonpj Exp $
4 % (c) The GHC Team, 1992-1999
8 {-# OPTIONS -fno-implicit-prelude #-}
12 , makeStablePtr -- :: a -> IO (StablePtr a)
13 , deRefStablePtr -- :: StablePtr a -> a
14 , freeStablePtr -- :: StablePtr a -> IO ()
20 -----------------------------------------------------------------------------
23 data StablePtr a = StablePtr (StablePtr# a)
25 instance CCallable (StablePtr a)
26 instance CReturnable (StablePtr a)
28 makeStablePtr :: a -> IO (StablePtr a)
29 deRefStablePtr :: StablePtr a -> IO a
30 foreign import "freeStablePtr" freeStablePtr :: StablePtr a -> IO ()
32 makeStablePtr a = IO $ \ s ->
33 case makeStablePtr# a s of (# s', sp #) -> (# s', StablePtr sp #)
35 deRefStablePtr (StablePtr sp) = IO $ \s -> deRefStablePtr# sp s
38 instance Eq (StablePtr a) where
39 (StablePtr sp1) == (StablePtr sp2) =
40 case eqStablePtr# sp1 sp2 of