[project @ 2001-06-28 14:15:04 by simonmar]
[packages/old-time.git] / Foreign / Ptr.hs
1 {-# OPTIONS -fno-implicit-prelude #-}
2 -----------------------------------------------------------------------------
3 --
4 -- Module : Foreign.Ptr
5 -- Copyright : (c) The FFI task force 2001
6 -- License : BSD-style (see the file libraries/core/LICENSE)
7 --
8 -- Maintainer : ffi@haskell.org
9 -- Stability : experimental
10 -- Portability : non-portable
11 --
12 -- $Id: Ptr.hs,v 1.1 2001/06/28 14:15:03 simonmar Exp $
13 --
14 -- Pointer types.
15 --
16 -----------------------------------------------------------------------------
17
18 module Foreign.Ptr (
19 --------------------------------------------------------------------
20 -- Data pointers.
21
22 Ptr(..), -- data Ptr a
23 nullPtr, -- :: Ptr a
24 castPtr, -- :: Ptr a -> Ptr b
25 plusPtr, -- :: Ptr a -> Int -> Ptr b
26 alignPtr, -- :: Ptr a -> Int -> Ptr a
27 minusPtr, -- :: Ptr a -> Ptr b -> Int
28
29 --------------------------------------------------------------------
30 -- Function pointers.
31
32 FunPtr(..), -- data FunPtr a
33 nullFunPtr, -- :: FunPtr a
34 castFunPtr, -- :: FunPtr a -> FunPtr b
35 castFunPtrToPtr, -- :: FunPtr a -> Ptr b
36 castPtrToFunPtr, -- :: Ptr a -> FunPtr b
37
38 freeHaskellFunPtr, -- :: FunPtr a -> IO ()
39 -- Free the function pointer created by foreign export dynamic.
40
41 ) where
42
43 import Data.Dynamic
44
45 #ifdef __GLASGOW_HASKELL__
46 import GHC.Ptr
47 import GHC.IOBase
48 import GHC.Err
49 #endif
50
51 foreign import "freeHaskellFunctionPtr" unsafe
52 freeHaskellFunPtr :: FunPtr a -> IO ()
53
54 #include "Dynamic.h"
55 INSTANCE_TYPEABLE1(Ptr,ptrTc,"Ptr")