-{-# OPTIONS_GHC -XNoImplicitPrelude -#include "HsBase.h" #-}
+{-# LANGUAGE CPP, NoImplicitPrelude, ForeignFunctionInterface #-}
+{-# OPTIONS_GHC -#include "HsBase.h" #-}
+
-----------------------------------------------------------------------------
-- |
-- Module : Foreign.C.Error
import Data.Maybe
#if __GLASGOW_HASKELL__
-import GHC.IOBase
+import GHC.IO
+import GHC.IO.Exception
+import GHC.IO.Handle.Types
import GHC.Num
import GHC.Base
#elif __HUGS__
else throwErrno loc
else return res
--- | as 'throwErrnoIfRetry', but checks for operations that would block and
--- executes an alternative action before retrying in that case.
+-- | as 'throwErrnoIfRetry', but additionally if the operation
+-- yields the error code 'eAGAIN' or 'eWOULDBLOCK', an alternative
+-- action is executed before retrying.
--
throwErrnoIfRetryMayBlock
:: (a -> Bool) -- ^ predicate to apply to the result value
if err == eINTR
then throwErrnoIfRetryMayBlock pred loc f on_block
else if err == eWOULDBLOCK || err == eAGAIN
- then do on_block; throwErrnoIfRetryMayBlock pred loc f on_block
+ then do _ <- on_block
+ throwErrnoIfRetryMayBlock pred loc f on_block
else throwErrno loc
else return res
-- conversion of an "errno" value into IO error
-- --------------------------------------------
--- | Construct a Haskell 98 I\/O error based on the given 'Errno' value.
+-- | Construct an 'IOError' based on the given 'Errno' value.
-- The optional information can be used to improve the accuracy of
-- error messages.
--