on master help sign in
Hide writev, fix fdready for ghc-8.2 and lower

fix build, deepseq version, parse error fixup ghc version conditonal for fdReady

commitfb8e1d7717743fc6b26fc64a24d5d4ed3d3e6946 authorHarendra Kumar <harendra.kumar@gmail.com> dateSun 16 Jun 2019, 00:01 (7 years ago) parent7010a8f
3 files changed+29−16
src/Streamly/FileSystem/FD.hs+9−5 src/Streamly/FileSystem/FDIO.hs+11−2 streamly.cabal+9−9
src/Streamly/FileSystem/FD.hs+9−5
@@ -96,8 +96,10 @@ module Streamly.FileSystem.FD
9696 -- , writeArray
9797 , writeArrays
9898 , writeArraysPackedUpto
99− , writev
100− , writevArraysPackedUpto
99+
100+ -- XXX these are incomplete
101+ -- , writev
102+ -- , writevArraysPackedUpto
101103
102104 -- -- * Random Access (Seek)
103105 -- -- | Unlike the streaming APIs listed above, these APIs apply to devices or
@@ -342,6 +344,7 @@ read = A.flattenArrays . readArrays
342344writeArrays :: (MonadIO m, Storable a) => Handle -> SerialT m (Array a) -> m ()
343345writeArrays h m = S.mapM_ (liftIO . writeArray h) m
344346
347+-- XXX this is incomplete
345348-- | Write a stream of 'IOVec' arrays to a handle.
346349--
347350-- @since 0.7.0
@@ -360,16 +363,17 @@ writeArraysPackedUpto :: (MonadIO m, Storable a)
360363 => Int -> Handle -> SerialT m (Array a) -> m ()
361364writeArraysPackedUpto n h xs = writeArrays h $ A.packArraysChunksOf n xs
362365
366+-- XXX this is incomplete
363367-- | Write a stream of arrays to a handle after grouping them in 'IOVec' arrays
364368-- of up to a maximum total size. Writes are performed using gather IO via
365369-- @writev@ system call. The maximum number of entries in each 'IOVec' group
366370-- limited to 512.
367371--
368372-- @since 0.7.0
369−{-# INLINE writevArraysPackedUpto #-}
370−writevArraysPackedUpto :: MonadIO m
373+{-# INLINE _writevArraysPackedUpto #-}
374+_writevArraysPackedUpto :: MonadIO m
371375 => Int -> Handle -> SerialT m (Array a) -> m ()
372−writevArraysPackedUpto n h xs =
376+_writevArraysPackedUpto n h xs =
373377 writev h $ fromStreamD $ groupIOVecsOf n 512 (toStreamD xs)
374378
375379-- GHC buffer size dEFAULT_FD_BUFFER_SIZE=8192 bytes.
src/Streamly/FileSystem/FDIO.hs+11−2
@@ -33,7 +33,10 @@ import Control.Monad (when)
3333import Data.Int (Int64)
3434import Data.Word (Word8)
3535import Foreign.C.Error (throwErrnoIfMinus1RetryMayBlock)
36−import Foreign.C.Types (CSize(..), CInt(..), CBool(..))
36+import Foreign.C.Types (CSize(..), CInt(..))
37+#if __GLASGOW_HASKELL__ >= 802
38+import Foreign.C.Types (CBool(..))
39+#endif
3740import Foreign.Ptr (plusPtr, Ptr)
3841import System.Posix.Internals (c_write, c_safe_write)
3942
@@ -60,8 +63,13 @@ isNonBlocking fd = fdIsNonBlocking fd /= 0
6063
6164-- "poll"s the fd for data to become available or timeout
6265-- See cbits/inputReady.c in base package
66+#if __GLASGOW_HASKELL__ >= 804
6367foreign import ccall unsafe "fdReady"
64− unsafe_fdReady :: CInt -> CBool -> Int64 -> CBool -> IO CInt
68+ unsafe_fdReady :: CInt -> CBool -> Int64 -> CBool -> IO CInt
69+#else
70+foreign import ccall safe "fdReady"
71+ unsafe_fdReady :: CInt -> CInt -> CInt -> CInt -> IO CInt
72+#endif
6573
6674writeNonBlocking :: String -> FD -> Ptr Word8 -> Int -> CSize -> IO CInt
6775writeNonBlocking loc !fd !buf !off !len
@@ -183,6 +191,7 @@ writeAll fd ptr bytes = do
183191writev :: FD -> Ptr IOVec -> Int -> IO CInt
184192writev = writevNonBlocking "Streamly.FileSystem.FDIO"
185193
194+-- XXX incomplete
186195-- | Keep writing an iovec in a loop until all the iovec entries are written.
187196writevAll :: FD -> Ptr IOVec -> Int -> IO ()
188197writevAll fd iovec count = do
streamly.cabal+9−9
@@ -261,7 +261,7 @@ library
261261
262262 build-depends: base >= 4.8 && < 5
263263 , ghc-prim >= 0.2 && < 0.6
264− , deepseq >= 1.4.2 && < 1.5
264+ , deepseq >= 1.4.1 && < 1.5
265265 , containers >= 0.5 && < 0.7
266266 , heaps >= 0.3 && < 0.4
267267
@@ -533,7 +533,7 @@ benchmark linear
533533 build-depends:
534534 streamly
535535 , base >= 4.8 && < 5
536− , deepseq >= 1.4.2 && < 1.5
536+ , deepseq >= 1.4.1 && < 1.5
537537 , random >= 1.0 && < 2.0
538538 , gauge >= 0.2.4 && < 0.3
539539 if impl(ghc < 8.0)
@@ -568,7 +568,7 @@ benchmark linear-async
568568 build-depends:
569569 streamly
570570 , base >= 4.8 && < 5
571− , deepseq >= 1.4.2 && < 1.5
571+ , deepseq >= 1.4.1 && < 1.5
572572 , random >= 1.0 && < 2.0
573573 , gauge >= 0.2.4 && < 0.3
574574 if impl(ghc < 8.0)
@@ -602,7 +602,7 @@ benchmark linear-rate
602602 build-depends:
603603 streamly
604604 , base >= 4.8 && < 5
605− , deepseq >= 1.4.2 && < 1.5
605+ , deepseq >= 1.4.1 && < 1.5
606606 , random >= 1.0 && < 2.0
607607 , gauge >= 0.2.4 && < 0.3
608608 if impl(ghc < 8.0)
@@ -637,7 +637,7 @@ benchmark nested
637637 build-depends:
638638 streamly
639639 , base >= 4.8 && < 5
640− , deepseq >= 1.4.2 && < 1.5
640+ , deepseq >= 1.4.1 && < 1.5
641641 , random >= 1.0 && < 2.0
642642 , gauge >= 0.2.4 && < 0.3
643643 if impl(ghc < 8.0)
@@ -672,7 +672,7 @@ benchmark array
672672 build-depends:
673673 streamly
674674 , base >= 4.8 && < 5
675− , deepseq >= 1.4.2 && < 1.5
675+ , deepseq >= 1.4.1 && < 1.5
676676 , random >= 1.0 && < 2.0
677677 , gauge >= 0.2.4 && < 0.3
678678 if impl(ghc < 8.0)
@@ -708,7 +708,7 @@ benchmark fileio
708708 , base >= 4.8 && < 5
709709 , gauge >= 0.2.4 && < 0.3
710710 , typed-process >= 0.2.3 && < 0.3
711− , deepseq >= 1.4.2 && < 1.5
711+ , deepseq >= 1.4.1 && < 1.5
712712
713713-------------------------------------------------------------------------------
714714-- Internal benchmarks for unexposed modules
@@ -765,7 +765,7 @@ benchmark base
765765 buildable: True
766766 build-depends:
767767 base >= 4.8 && < 5
768− , deepseq >= 1.4.2 && < 1.5
768+ , deepseq >= 1.4.1 && < 1.5
769769 , random >= 1.0 && < 2.0
770770 , gauge >= 0.2.4 && < 0.3
771771
@@ -820,7 +820,7 @@ executable nano-bench
820820 , gauge >= 0.2.4 && < 0.3
821821 , ghc-prim >= 0.2 && < 0.6
822822 , containers >= 0.5 && < 0.7
823− , deepseq >= 1.4.2 && < 1.5
823+ , deepseq >= 1.4.1 && < 1.5
824824 , heaps >= 0.3 && < 0.4
825825 , random >= 1.0 && < 2.0
826826