2{-# LANGUAGE BangPatterns #-}
3{-# LANGUAGE CApiFFI #-}
4{-# LANGUAGE ScopedTypeVariables #-}
7-- Module : Streamly.FileSystem.IOVec
8-- Copyright : (c) 2019 Composewell Technologies
11-- Maintainer : streamly@composewell.com
12-- Stability : experimental
15-- Low level IO routines interfacing the operating system.
18module Streamly.FileSystem.IOVec
25import Data.Word (Word8, Word64)
26import Foreign.C.Types (CInt(..))
27import Foreign.Ptr (Ptr)
28import System.Posix.Types (CSsize(..))
29#if !defined(mingw32_HOST_OS)
30import Foreign.Storable (Storable(..))
33-------------------------------------------------------------------------------
35-------------------------------------------------------------------------------
38 { iovBase :: {-# UNPACK #-} !(Ptr Word8)
39 , iovLen :: {-# UNPACK #-} !Word64
42#if !defined(mingw32_HOST_OS)
46#if __GLASGOW_HASKELL__ < 800
47#let alignment t = "%lu", (unsigned long)offsetof(struct {char x__; t (y__); }, y__)
50instance Storable IOVec where
51 sizeOf _ = #{size struct iovec}
52 alignment _ = #{alignment struct iovec}
54 base <- #{peek struct iovec, iov_base} ptr
55 len :: #{type size_t} <- #{peek struct iovec, iov_len} ptr
56 return $ IOVec base len
58 let base = iovBase vec
59 len :: #{type size_t} = iovLen vec
60 #{poke struct iovec, iov_base} ptr base
61 #{poke struct iovec, iov_len} ptr len
64-- capi calling convention does not work without -fobject-code option with GHCi
65-- so using this in DEVBUILD only for now.
67#if !defined(mingw32_HOST_OS) && defined DEVBUILD
68foreign import capi unsafe "sys/uio.h writev"
69 c_writev :: CInt -> Ptr IOVec -> CInt -> IO CSsize
71foreign import capi safe "sys/uio.h writev"
72 c_safe_writev :: CInt -> Ptr IOVec -> CInt -> IO CSsize
75c_writev :: CInt -> Ptr IOVec -> CInt -> IO CSsize
76c_writev = error "writev not implemented"
78c_safe_writev :: CInt -> Ptr IOVec -> CInt -> IO CSsize
79c_safe_writev = error "writev not implemented"
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