% -----------------------------------------------------------------------------
-% $Id: PrelStable.lhs,v 1.2 1999/09/19 19:12:42 sof Exp $
+% $Id: PrelStable.lhs,v 1.9 2001/03/25 09:57:26 qrczak Exp $
%
-% (c) The GHC Team, 1992-1999
+% (c) The GHC Team, 1992-2000
%
+\section{Module @PrelStable@}
+
\begin{code}
{-# OPTIONS -fno-implicit-prelude #-}
module PrelStable
( StablePtr(..)
- , makeStablePtr -- :: a -> IO (StablePtr a)
+ , newStablePtr -- :: a -> IO (StablePtr a)
, deRefStablePtr -- :: StablePtr a -> a
, freeStablePtr -- :: StablePtr a -> IO ()
) where
-----------------------------------------------------------------------------
-- Stable Pointers
-data StablePtr a = StablePtr (StablePtr# a)
+data StablePtr a = StablePtr (StablePtr# a)
instance CCallable (StablePtr a)
-instance CCallable (StablePtr# a)
instance CReturnable (StablePtr a)
-makeStablePtr :: a -> IO (StablePtr a)
-deRefStablePtr :: StablePtr a -> IO a
-foreign import "freeStablePtr" freeStablePtr :: StablePtr a -> IO ()
-
-makeStablePtr a = IO $ \ s ->
+newStablePtr :: a -> IO (StablePtr a)
+newStablePtr a = IO $ \ s ->
case makeStablePtr# a s of (# s', sp #) -> (# s', StablePtr sp #)
+deRefStablePtr :: StablePtr a -> IO a
deRefStablePtr (StablePtr sp) = IO $ \s -> deRefStablePtr# sp s
+foreign import unsafe freeStablePtr :: StablePtr a -> IO ()
instance Eq (StablePtr a) where
(StablePtr sp1) == (StablePtr sp2) =