{-# OPTIONS_GHC -optc-D_GNU_SOURCE #-} {-# LINE 1 "src-fcntl-nocache/System/Posix/Fcntl/NoCache.hsc" #-} {-# LANGUAGE CPP #-} module System.Posix.Fcntl.NoCache ( readFcntlNoCache, writeFcntlNoCache, ) where {-# LINE 9 "src-fcntl-nocache/System/Posix/Fcntl/NoCache.hsc" #-} import Data.Bits (complement, (.&.), (.|.)) import Foreign.C.Error (throwErrnoIfMinus1) import System.Posix.Internals (c_fcntl_read) {-# LINE 13 "src-fcntl-nocache/System/Posix/Fcntl/NoCache.hsc" #-} import Foreign.C.Error (throwErrnoIfMinus1_) import System.Posix.Internals (c_fcntl_write) import System.Posix.Types (Fd (..)) readFcntlNoCache :: Fd -> IO Bool writeFcntlNoCache :: Fd -> Bool -> IO () {-# LINE 33 "src-fcntl-nocache/System/Posix/Fcntl/NoCache.hsc" #-} readFcntlNoCache :: Fd -> IO Bool readFcntlNoCache (Fd CInt fd) = do CInt r <- String -> IO CInt -> IO CInt forall a. (Eq a, Num a) => String -> IO a -> IO a throwErrnoIfMinus1 String "readFcntlNoCache" (CInt -> CInt -> IO CInt c_fcntl_read CInt fd CInt 3) {-# LINE 36 "src-fcntl-nocache/System/Posix/Fcntl/NoCache.hsc" #-} return ((r .&. opt_val) /= 0) where opt_val :: CInt opt_val = CInt 16384 {-# LINE 39 "src-fcntl-nocache/System/Posix/Fcntl/NoCache.hsc" #-} writeFcntlNoCache :: Fd -> Bool -> IO () writeFcntlNoCache (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 "writeFcntlNoCache" (CInt -> CInt -> IO CInt c_fcntl_read CInt fd CInt 3) {-# LINE 42 "src-fcntl-nocache/System/Posix/Fcntl/NoCache.hsc" #-} let r' | val = fromIntegral r .|. opt_val | otherwise = fromIntegral r .&. complement opt_val String -> IO CInt -> IO () forall a. (Eq a, Num a) => String -> IO a -> IO () throwErrnoIfMinus1_ String "writeFcntlNoCache" (CInt -> CInt -> CLong -> IO CInt c_fcntl_write CInt fd CInt 4 CLong r') {-# LINE 45 "src-fcntl-nocache/System/Posix/Fcntl/NoCache.hsc" #-} where opt_val :: CLong opt_val = CLong 16384 {-# LINE 47 "src-fcntl-nocache/System/Posix/Fcntl/NoCache.hsc" #-} {-# LINE 48 "src-fcntl-nocache/System/Posix/Fcntl/NoCache.hsc" #-}