1 {-# LANGUAGE CPP, NoImplicitPrelude #-}
3 -----------------------------------------------------------------------------
5 -- Module : Foreign.StablePtr
6 -- Copyright : (c) The University of Glasgow 2001
7 -- License : BSD-style (see the file libraries/base/LICENSE)
9 -- Maintainer : ffi@haskell.org
10 -- Stability : provisional
11 -- Portability : portable
13 -- This module is part of the Foreign Function Interface (FFI) and will usually
14 -- be imported via the module "Foreign".
16 -----------------------------------------------------------------------------
19 module Foreign.StablePtr
20 ( -- * Stable references to Haskell values
22 , newStablePtr -- :: a -> IO (StablePtr a)
23 , deRefStablePtr -- :: StablePtr a -> IO a
24 , freeStablePtr -- :: StablePtr a -> IO ()
25 , castStablePtrToPtr -- :: StablePtr a -> Ptr ()
26 , castPtrToStablePtr -- :: Ptr () -> StablePtr a
27 , -- ** The C-side interface
32 #ifdef __GLASGOW_HASKELL__
53 -- The following definition is available to C programs inter-operating with
54 -- Haskell code when including the header @HsFFI.h@.
56 -- > typedef void *HsStablePtr; /* C representation of a StablePtr */
58 -- Note that no assumptions may be made about the values representing stable
59 -- pointers. In fact, they need not even be valid memory addresses. The only
60 -- guarantee provided is that if they are passed back to Haskell land, the
61 -- function 'deRefStablePtr' will be able to reconstruct the
62 -- Haskell value referred to by the stable pointer.