1 {-# OPTIONS_GHC -XNoImplicitPrelude #-}
2 -----------------------------------------------------------------------------
4 -- Module : Foreign.Marshal
5 -- Copyright : (c) The FFI task force 2003
6 -- License : BSD-style (see the file libraries/base/LICENSE)
8 -- Maintainer : ffi@haskell.org
9 -- Stability : provisional
10 -- Portability : portable
12 -- Marshalling support
14 -----------------------------------------------------------------------------
16 module Foreign.Marshal
18 -- | The module "Foreign.Marshal" re-exports the other modules in the
19 -- @Foreign.Marshal@ hierarchy:
20 module Foreign.Marshal.Alloc
21 , module Foreign.Marshal.Array
22 , module Foreign.Marshal.Error
23 , module Foreign.Marshal.Pool
24 , module Foreign.Marshal.Utils
25 -- | and provides one function:
29 import Foreign.Marshal.Alloc
30 import Foreign.Marshal.Array
31 import Foreign.Marshal.Error
32 import Foreign.Marshal.Pool
33 import Foreign.Marshal.Utils
35 #ifdef __GLASGOW_HASKELL__
38 import System.IO.Unsafe
42 Sometimes an external entity is a pure function, except that it passes
43 arguments and/or results via pointers. The function
44 @unsafeLocalState@ permits the packaging of such entities as pure
47 The only IO operations allowed in the IO action passed to
48 @unsafeLocalState@ are (a) local allocation (@alloca@, @allocaBytes@
49 and derived operations such as @withArray@ and @withCString@), and (b)
50 pointer operations (@Foreign.Storable@ and @Foreign.Ptr@) on the
51 pointers to local storage, and (c) foreign functions whose only
52 observable effect is to read and/or write the locally allocated
53 memory. Passing an IO operation that does not obey these rules
54 results in undefined behaviour.
56 It is expected that this operation will be
57 replaced in a future revision of Haskell.
59 unsafeLocalState :: IO a -> a
60 unsafeLocalState = unsafePerformIO