X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Flib%2Fstd%2FPrelStable.lhs;h=2d6f8ae451474fdff428be8c7d622fd090c0a680;hb=21c60059fff93a95ab5bcec60dd4f2edb8f7b23f;hp=7de56662a78eef8a8b0c53693dae90767bd350d1;hpb=1e2dc51066e0ebaf5d9baa8578386478078a430f;p=ghc-hetmet.git diff --git a/ghc/lib/std/PrelStable.lhs b/ghc/lib/std/PrelStable.lhs index 7de5666..2d6f8ae 100644 --- a/ghc/lib/std/PrelStable.lhs +++ b/ghc/lib/std/PrelStable.lhs @@ -1,15 +1,17 @@ % ----------------------------------------------------------------------------- -% $Id: PrelStable.lhs,v 1.6 2000/05/01 14:53:47 panne 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 @@ -20,20 +22,19 @@ import PrelIOBase ----------------------------------------------------------------------------- -- Stable Pointers -data StablePtr a = StablePtr (StablePtr# a) +data StablePtr a = StablePtr (StablePtr# a) instance CCallable (StablePtr a) instance CReturnable (StablePtr a) -makeStablePtr :: a -> IO (StablePtr a) -deRefStablePtr :: StablePtr a -> IO a -foreign import "freeStablePtr" unsafe 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) =