1{-# LANGUAGE UnboxedTuples #-}
4-- Module : Streamly.Internal.System.IO
5-- Copyright : (c) 2020 Composewell Technologies
6-- License : BSD-3-Clause
7-- Maintainer : streamly@composewell.com
8-- Stability : experimental
12module Streamly.Internal.System.IO
21-------------------------------------------------------------------------------
23-------------------------------------------------------------------------------
25import Foreign.Storable (Storable(sizeOf))
26import GHC.Base (realWorld#)
29-------------------------------------------------------------------------------
31-------------------------------------------------------------------------------
33{-# INLINE unsafeInlineIO #-}
34unsafeInlineIO :: IO a -> a
35unsafeInlineIO (IO m) = case m realWorld# of (# _, r #) -> r
37-- | GHC memory management allocation header overhead
39allocOverhead = 2 * sizeOf (undefined :: Int)
41mkChunkSize :: Int -> Int
42mkChunkSize n = let size = n - allocOverhead in max size 0
44mkChunkSizeKB :: Int -> Int
45mkChunkSizeKB n = mkChunkSize (n * k)
48-- | Default maximum buffer size in bytes, for reading from and writing to IO
49-- devices, the value is 32KB minus GHC allocation overhead, which is a few
50-- bytes, so that the actual allocation is 32KB.
51defaultChunkSize :: Int
52defaultChunkSize = mkChunkSizeKB 32
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list