{-# LANGUAGE CPP #-}
{-# OPTIONS_HADDOCK hide #-}
module Data.Vector.Storable.Internal (
getPtr, setPtr, updPtr, unsafeWithForeignPtr
) where
import Foreign.ForeignPtr ()
import Foreign.Ptr ()
import GHC.ForeignPtr ( ForeignPtr(..) )
#if MIN_VERSION_base(4,15,0)
import GHC.ForeignPtr ( unsafeWithForeignPtr )
#else
import Foreign.ForeignPtr ( withForeignPtr )
#endif
import GHC.Ptr ( Ptr(..) )
getPtr :: ForeignPtr a -> Ptr a
{-# INLINE getPtr #-}
getPtr :: forall a. ForeignPtr a -> Ptr a
getPtr (ForeignPtr Addr#
addr ForeignPtrContents
_) = forall a. Addr# -> Ptr a
Ptr Addr#
addr
setPtr :: ForeignPtr a -> Ptr a -> ForeignPtr a
{-# INLINE setPtr #-}
setPtr :: forall a. ForeignPtr a -> Ptr a -> ForeignPtr a
setPtr (ForeignPtr Addr#
_ ForeignPtrContents
c) (Ptr Addr#
addr) = forall a. Addr# -> ForeignPtrContents -> ForeignPtr a
ForeignPtr Addr#
addr ForeignPtrContents
c
updPtr :: (Ptr a -> Ptr a) -> ForeignPtr a -> ForeignPtr a
{-# INLINE updPtr #-}
updPtr :: forall a. (Ptr a -> Ptr a) -> ForeignPtr a -> ForeignPtr a
updPtr Ptr a -> Ptr a
f (ForeignPtr Addr#
p ForeignPtrContents
c) = case Ptr a -> Ptr a
f (forall a. Addr# -> Ptr a
Ptr Addr#
p) of { Ptr Addr#
q -> forall a. Addr# -> ForeignPtrContents -> ForeignPtr a
ForeignPtr Addr#
q ForeignPtrContents
c }
#if !MIN_VERSION_base(4,15,0)
unsafeWithForeignPtr :: ForeignPtr a -> (Ptr a -> IO b) -> IO b
unsafeWithForeignPtr = withForeignPtr
#endif