@@ -30,17 +30,17 @@ module System.Posix.Fcntl (
3030import Foreign.C
3131import System.Posix.Types
3232
33- #if !HAVE_POSIX_FALLOCATE || !HAVE_O_DIRECT
33+ #if !HAVE_POSIX_FALLOCATE || !HAVE_DECL_O_DIRECT
3434import System.IO.Error ( ioeSetLocation )
3535import GHC.IO.Exception ( unsupportedOperation )
3636#endif
3737
38- #if HAVE_O_DIRECT
38+ #if HAVE_DECL_O_DIRECT
3939import Data.Bits (complement , (.&.) , (.|.) )
4040import System.Posix.Internals (c_fcntl_read )
4141#endif
4242
43- #if HAVE_O_DIRECT || HAVE_F_NOCACHE
43+ #if HAVE_DECL_O_DIRECT || HAVE_DECL_F_NOCACHE
4444import System.Posix.Internals (c_fcntl_write )
4545#endif
4646
@@ -128,20 +128,20 @@ fileAllocate _ _ _ = ioError (ioeSetLocation unsupportedOperation
128128-- Throws 'IOError' (\"unsupported operation\") if platform does not support
129129-- getting the cache mode.
130130--
131- -- Use @#if HAVE_O_DIRECT @ CPP guard to detect availability. Use @#include
132- -- "HsUnix.h"@ to bring @HAVE_O_DIRECT @ into scope.
131+ -- Use @#if HAVE_DECL_O_DIRECT @ CPP guard to detect availability. Use @#include
132+ -- "HsUnix.h"@ to bring @HAVE_DECL_O_DIRECT @ into scope.
133133--
134134-- @since 2.8.7.0
135135fileGetCaching :: Fd -> IO Bool
136- #if HAVE_O_DIRECT
136+ #if HAVE_DECL_O_DIRECT
137137fileGetCaching (Fd fd) = do
138138 r <- throwErrnoIfMinus1 " fileGetCaching" (c_fcntl_read fd # {const F_GETFL })
139139 return ((r .&. opt_val) == 0 )
140140 where
141141 opt_val = # {const O_DIRECT }
142142#else
143143{-# WARNING fileGetCaching
144- "operation will throw 'IOError' \"unsupported operation\" (CPP guard: @#if HAVE_O_DIRECT @)" #-}
144+ "operation will throw 'IOError' \"unsupported operation\" (CPP guard: @#if HAVE_DECL_O_DIRECT @)" #-}
145145fileGetCaching _ = ioError (ioeSetLocation unsupportedOperation " fileGetCaching" )
146146#endif
147147
@@ -158,25 +158,25 @@ fileGetCaching _ = ioError (ioeSetLocation unsupportedOperation "fileGetCaching"
158158-- Throws 'IOError' (\"unsupported operation\") if platform does not support
159159-- setting the cache mode.
160160--
161- -- Use @#if HAVE_O_DIRECT || HAVE_F_NOCACHE @ CPP guard to detect availability.
162- -- Use @#include "HsUnix.h"@ to bring @HAVE_O_DIRECT @ and @HAVE_F_NOCACHE @ into
161+ -- Use @#if HAVE_DECL_O_DIRECT || HAVE_DECL_F_NOCACHE @ CPP guard to detect availability.
162+ -- Use @#include "HsUnix.h"@ to bring @HAVE_DECL_O_DIRECT @ and @HAVE_DECL_F_NOCACHE @ into
163163-- scope.
164164--
165165-- @since 2.8.7.0
166166fileSetCaching :: Fd -> Bool -> IO ()
167- #if HAVE_O_DIRECT
167+ #if HAVE_DECL_O_DIRECT
168168fileSetCaching (Fd fd) val = do
169169 r <- throwErrnoIfMinus1 " fileSetCaching" (c_fcntl_read fd # {const F_GETFL })
170170 let r' | val = fromIntegral r .&. complement opt_val
171171 | otherwise = fromIntegral r .|. opt_val
172172 throwErrnoIfMinus1_ " fileSetCaching" (c_fcntl_write fd # {const F_SETFL } r')
173173 where
174174 opt_val = # {const O_DIRECT }
175- #elif HAVE_F_NOCACHE
175+ #elif HAVE_DECL_F_NOCACHE
176176fileSetCaching (Fd fd) val = do
177177 throwErrnoIfMinus1_ " fileSetCaching" (c_fcntl_write fd # {const F_NOCACHE } (if val then 0 else 1 ))
178178#else
179179{-# WARNING fileSetCaching
180- "operation will throw 'IOError' \"unsupported operation\" (CPP guard: @#if HAVE_O_DIRECT || HAVE_F_NOCACHE @)" #-}
180+ "operation will throw 'IOError' \"unsupported operation\" (CPP guard: @#if HAVE_DECL_O_DIRECT || HAVE_DECL_F_NOCACHE @)" #-}
181181fileSetCaching _ _ = ioError (ioeSetLocation unsupportedOperation " fileSetCaching" )
182182#endif
0 commit comments