db27b060639087952eedb6f7384d49d7487684db
[packages/base.git] / Foreign / StablePtr.hs
1 {-# LANGUAGE Trustworthy #-}
2 {-# LANGUAGE CPP, NoImplicitPrelude #-}
3
4 -----------------------------------------------------------------------------
5 -- |
6 -- Module : Foreign.StablePtr
7 -- Copyright : (c) The University of Glasgow 2001
8 -- License : BSD-style (see the file libraries/base/LICENSE)
9 --
10 -- Maintainer : ffi@haskell.org
11 -- Stability : provisional
12 -- Portability : portable
13 --
14 -- This module is part of the Foreign Function Interface (FFI) and will usually
15 -- be imported via the module "Foreign".
16 --
17 -----------------------------------------------------------------------------
18
19
20 module Foreign.StablePtr
21 ( -- * Stable references to Haskell values
22 StablePtr -- abstract
23 , newStablePtr
24 , deRefStablePtr
25 , freeStablePtr
26 , castStablePtrToPtr
27 , castPtrToStablePtr
28 , -- ** The C-side interface
29
30 -- $cinterface
31 ) where
32
33 #ifdef __GLASGOW_HASKELL__
34 import GHC.Stable
35 #endif
36
37 #ifdef __HUGS__
38 import Hugs.StablePtr
39 #endif
40
41 -- $cinterface
42 --
43 -- The following definition is available to C programs inter-operating with
44 -- Haskell code when including the header @HsFFI.h@.
45 --
46 -- > typedef void *HsStablePtr; /* C representation of a StablePtr */
47 --
48 -- Note that no assumptions may be made about the values representing stable
49 -- pointers. In fact, they need not even be valid memory addresses. The only
50 -- guarantee provided is that if they are passed back to Haskell land, the
51 -- function 'deRefStablePtr' will be able to reconstruct the
52 -- Haskell value referred to by the stable pointer.
53