@@ -30,18 +30,19 @@ module System.Posix.Fcntl (
30
30
import Foreign.C
31
31
import System.Posix.Types
32
32
33
- #if !HAVE_POSIX_FALLOCATE
33
+ #if !HAVE_POSIX_FALLOCATE || !HAVE_O_DIRECT
34
34
import System.IO.Error ( ioeSetLocation )
35
35
import GHC.IO.Exception ( unsupportedOperation )
36
36
#endif
37
37
38
- #ifndef darwin_HOST_OS
38
+ #if HAVE_O_DIRECT
39
39
import Data.Bits (complement , (.&.) , (.|.) )
40
40
import System.Posix.Internals (c_fcntl_read )
41
41
#endif
42
42
43
+ #if HAVE_O_DIRECT || HAVE_F_NOCACHE
43
44
import System.Posix.Internals (c_fcntl_write )
44
-
45
+ #endif
45
46
46
47
-- -----------------------------------------------------------------------------
47
48
-- File control
@@ -140,7 +141,7 @@ fileGetCaching (Fd fd) = do
140
141
#else
141
142
{-# WARNING fileGetCaching
142
143
"operation will throw 'IOError' \"unsupported operation\" (CPP guard: @#if HAVE_O_DIRECT@)" #-}
143
- fileGetCaching _ _ = ioError (ioeSetLocation unsupportedOperation " fileGetCaching" )
144
+ fileGetCaching _ = ioError (ioeSetLocation unsupportedOperation " fileGetCaching" )
144
145
#endif
145
146
146
147
-- | Performs the @fcntl(2)@ operation on a file-desciptor to set the cache
@@ -172,7 +173,7 @@ fileSetCaching (Fd fd) val = do
172
173
fileSetCaching (Fd fd) val = do
173
174
throwErrnoIfMinus1_ " fileSetCaching" (c_fcntl_write fd # {const F_NOCACHE } (if val then 1 else 0 ))
174
175
#else
175
- {-# WARNING fileGetCaching
176
+ {-# WARNING fileSetCaching
176
177
"operation will throw 'IOError' \"unsupported operation\" (CPP guard: @#if HAVE_O_DIRECT || HAVE_F_NOCACHE @)" #-}
177
- fileGetCaching _ _ = ioError (ioeSetLocation unsupportedOperation " fileGetCaching " )
178
+ fileSetCaching _ _ = ioError (ioeSetLocation unsupportedOperation " fileSetCaching " )
178
179
#endif
0 commit comments