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)
26#if defined(i386_HOST_ARCH)
27import Data.Word (Word32)
29import Data.Word (Word64)
31import Foreign.C.Types (CInt(..))
32import Foreign.Ptr (Ptr)
33import System.Posix.Types (CSsize(..))
34#if !defined(mingw32_HOST_OS)
35import Foreign.Storable (Storable(..))
38-------------------------------------------------------------------------------
40-------------------------------------------------------------------------------
43 { iovBase :: {-# UNPACK #-} !(Ptr Word8)
44#if defined(i386_HOST_ARCH)
45 , iovLen :: {-# UNPACK #-} !Word32
47 , iovLen :: {-# UNPACK #-} !Word64
51#if !defined(mingw32_HOST_OS)
55#if __GLASGOW_HASKELL__ < 800
56#let alignment t = "%lu", (unsigned long)offsetof(struct {char x__; t (y__); }, y__)
59instance Storable IOVec where
60 sizeOf _ = #{size struct iovec}
61 alignment _ = #{alignment struct iovec}
63 base <- #{peek struct iovec, iov_base} ptr
64 len :: #{type size_t} <- #{peek struct iovec, iov_len} ptr
65 return $ IOVec base len
67 let base = iovBase vec
68 len :: #{type size_t} = iovLen vec
69 #{poke struct iovec, iov_base} ptr base
70 #{poke struct iovec, iov_len} ptr len
73-- capi calling convention does not work without -fobject-code option with GHCi
74-- so using this in DEVBUILD only for now.
76#if !defined(mingw32_HOST_OS) && defined DEVBUILD
77foreign import capi unsafe "sys/uio.h writev"
78 c_writev :: CInt -> Ptr IOVec -> CInt -> IO CSsize
80foreign import capi safe "sys/uio.h writev"
81 c_safe_writev :: CInt -> Ptr IOVec -> CInt -> IO CSsize
84c_writev :: CInt -> Ptr IOVec -> CInt -> IO CSsize
85c_writev = error "writev not implemented"
87c_safe_writev :: CInt -> Ptr IOVec -> CInt -> IO CSsize
88c_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