{-# OPTIONS_GHC -optc-D_GNU_SOURCE #-}
{-# LINE 1 "src-linux/System/FS/BlockIO/Internal/Fcntl.hsc" #-}
{-# LANGUAGE CPP #-}
module System.FS.BlockIO.Internal.Fcntl (fileSetCaching) where
{-# LINE 14 "src-linux/System/FS/BlockIO/Internal/Fcntl.hsc" #-}
import Data.Bits (complement, (.&.), (.|.))
import Foreign.C (throwErrnoIfMinus1, throwErrnoIfMinus1_)
import System.Posix.Internals
import System.Posix.Types (Fd (Fd))
fileSetCaching :: Fd -> Bool -> IO ()
fileSetCaching :: Fd -> Bool -> IO ()
fileSetCaching (Fd CInt
fd) Bool
val = do
CInt
r <- String -> IO CInt -> IO CInt
forall a. (Eq a, Num a) => String -> IO a -> IO a
throwErrnoIfMinus1 String
"fileSetCaching" (CInt -> CInt -> IO CInt
c_fcntl_read CInt
fd CInt
3)
{-# LINE 33 "src-linux/System/FS/BlockIO/Internal/Fcntl.hsc" #-}
let r' | val = fromIntegral r .&. complement opt_val
| otherwise = fromIntegral r .|. opt_val
String -> IO CInt -> IO ()
forall a. (Eq a, Num a) => String -> IO a -> IO ()
throwErrnoIfMinus1_ String
"fileSetCaching" (CInt -> CInt -> CLong -> IO CInt
c_fcntl_write CInt
fd CInt
4 CLong
r')
{-# LINE 36 "src-linux/System/FS/BlockIO/Internal/Fcntl.hsc" #-}
where
opt_val :: CLong
opt_val = CLong
16384
{-# LINE 38 "src-linux/System/FS/BlockIO/Internal/Fcntl.hsc" #-}
{-# LINE 39 "src-linux/System/FS/BlockIO/Internal/Fcntl.hsc" #-}