Tweaked imports and includes for compatibility.
import GHC.Ptr
import GHC.Err
import GHC.Base
import GHC.Ptr
import GHC.Err
import GHC.Base
+#else
+import Control.Exception ( bracket )
-- basic C routines needed for memory allocation
--
-- basic C routines needed for memory allocation
--
-foreign import ccall unsafe "malloc" _malloc :: CSize -> IO (Ptr a)
-foreign import ccall unsafe "realloc" _realloc :: Ptr a -> CSize -> IO (Ptr b)
-foreign import ccall unsafe "free" _free :: Ptr a -> IO ()
+foreign import ccall unsafe "stdlib.h malloc" _malloc :: CSize -> IO (Ptr a)
+foreign import ccall unsafe "stdlib.h realloc" _realloc :: Ptr a -> CSize -> IO (Ptr b)
+foreign import ccall unsafe "stdlib.h free" _free :: Ptr a -> IO ()
) where
import Control.Monad
) where
import Control.Monad
-
-#ifdef __GLASGOW_HASKELL__
-import Foreign.Ptr (Ptr, plusPtr)
-import GHC.Storable (Storable(sizeOf,peekElemOff,pokeElemOff))
+import Foreign.Ptr (Ptr, plusPtr)
+import Foreign.Storable (Storable(sizeOf,peekElemOff,pokeElemOff))
import Foreign.Marshal.Alloc (alloca, mallocBytes, allocaBytes, reallocBytes)
import Foreign.Marshal.Utils (copyBytes, moveBytes)
import Foreign.Marshal.Alloc (alloca, mallocBytes, allocaBytes, reallocBytes)
import Foreign.Marshal.Utils (copyBytes, moveBytes)
+
+#ifdef __GLASGOW_HASKELL__
import GHC.IOBase
import GHC.Num
import GHC.List
import GHC.IOBase
import GHC.Num
import GHC.List
) where
import Data.Maybe
) where
import Data.Maybe
-
-#ifdef __GLASGOW_HASKELL__
import Foreign.Ptr ( Ptr, nullPtr )
import Foreign.Ptr ( Ptr, nullPtr )
-import GHC.Storable ( Storable(poke) )
+import Foreign.Storable ( Storable(poke) )
import Foreign.C.TypesISO ( CSize )
import Foreign.Marshal.Alloc ( malloc, alloca )
import Foreign.C.TypesISO ( CSize )
import Foreign.Marshal.Alloc ( malloc, alloca )
+
+#ifdef __GLASGOW_HASKELL__
import GHC.IOBase
import GHC.Real ( fromIntegral )
import GHC.Num
import GHC.IOBase
import GHC.Real ( fromIntegral )
import GHC.Num
-- |Basic C routines needed for memory copying
--
-- |Basic C routines needed for memory copying
--
-foreign import ccall unsafe memcpy :: Ptr a -> Ptr a -> CSize -> IO ()
-foreign import ccall unsafe memmove :: Ptr a -> Ptr a -> CSize -> IO ()
+foreign import ccall unsafe "string.h" memcpy :: Ptr a -> Ptr a -> CSize -> IO ()
+foreign import ccall unsafe "string.h" memmove :: Ptr a -> Ptr a -> CSize -> IO ()