Z-Data 1.3.0.0 → 1.3.0.1
raw patch · 2 files changed
+9/−1 lines, 2 files
Files
- Z-Data.cabal +1/−1
- Z/Foreign/CPtr.hs +8/−0
Z-Data.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: Z-Data-version: 1.3.0.0+version: 1.3.0.1 synopsis: Array, vector and text description: This package provides array, slice and text operations license: BSD-3-Clause
Z/Foreign/CPtr.hs view
@@ -118,10 +118,18 @@ -- so it may be optimized away, 'withCPtrForever' solves that. -- withCPtrForever :: CPtr a -> (Ptr a -> IO b) -> IO b+#if MIN_VERSION_base(4,15,0) {-# INLINABLE withCPtrForever #-} withCPtrForever (CPtr pa@(PrimArray ba#)) f = IO $ \ s -> case f (indexPrimArray pa 0) of IO action# -> keepAlive# ba# s action#+#else+{-# NOINLINE withCPtrForever #-}+withCPtrForever (CPtr pa@(PrimArray ba#)) f = do+ r <- f (indexPrimArray pa 0)+ primitive_ (touch# ba#)+ return r+#endif -- | Pass a list of 'CPtr Foo' as @foo**@. USE THIS FUNCTION WITH UNSAFE FFI ONLY! withCPtrsUnsafe :: forall a b. [CPtr a] -> (BA# (Ptr a) -> Int -> IO b) -> IO b