X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Foreign%2FForeignPtr.hs;h=53275c10a2ea02e2ba29391721f0e104da979a79;hb=d4aaa2cbdb06a88d99545da53d3da69b48702b1e;hp=515c0d8be45c6b5f261e469e74f0a3db5df3b370;hpb=f444698bf6b09b2da6a1fec8aecc1eaf37847980;p=haskell-directory.git diff --git a/Foreign/ForeignPtr.hs b/Foreign/ForeignPtr.hs index 515c0d8..53275c1 100644 --- a/Foreign/ForeignPtr.hs +++ b/Foreign/ForeignPtr.hs @@ -1,4 +1,4 @@ -{-# OPTIONS -fno-implicit-prelude #-} +{-# OPTIONS_GHC -fno-implicit-prelude #-} ----------------------------------------------------------------------------- -- | -- Module : Foreign.ForeignPtr @@ -33,6 +33,10 @@ module Foreign.ForeignPtr #endif , withForeignPtr +#ifdef __GLASGOW_HASKELL__ + , finalizeForeignPtr +#endif + -- ** Low-level operations , unsafeForeignPtrToPtr , touchForeignPtr @@ -82,10 +86,6 @@ import GHC.ForeignPtr #if !defined(__NHC__) && !defined(__GLASGOW_HASKELL__) import Foreign.Marshal.Alloc ( malloc, mallocBytes, finalizerFree ) -import Data.Typeable - -#include "Typeable.h" -INSTANCE_TYPEABLE1(ForeignPtr,foreignPtrTc,"ForeignPtr") instance Eq (ForeignPtr a) where p == q = unsafeForeignPtrToPtr p == unsafeForeignPtrToPtr q @@ -122,7 +122,7 @@ withForeignPtr :: ForeignPtr a -> (Ptr a -> IO b) -> IO b -- the action and use it after the action completes. All uses -- of the pointer should be inside the -- 'withForeignPtr' bracket. The reason for --- this unsafety is the same as for +-- this unsafeness is the same as for -- 'unsafeForeignPtrToPtr' below: the finalizer -- may run earlier than expected, because the compiler can only -- track usage of the 'ForeignPtr' object, not @@ -170,7 +170,7 @@ mallocForeignPtrBytes n = do mallocForeignPtrArray :: Storable a => Int -> IO (ForeignPtr a) mallocForeignPtrArray = doMalloc undefined where - doMalloc :: Storable a => a -> Int -> IO (ForeignPtr a) + doMalloc :: Storable b => b -> Int -> IO (ForeignPtr b) doMalloc dummy size = mallocForeignPtrBytes (size * sizeOf dummy) -- | This function is similar to 'Foreign.Marshal.Array.mallocArray0',