X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Foreign%2FC%2FError.hs;h=33a7bfd263184041d8ecb1ca6eb75a7b8cd2e710;hb=d539a9457e2c79a9f13744d073d3f253ea2fb33e;hp=dcee040373e4992d0527e8db8809cce4a692da77;hpb=a3e56f82973d7117fe4544e5702d1c0180ae7d79;p=ghc-base.git diff --git a/Foreign/C/Error.hs b/Foreign/C/Error.hs index dcee040..33a7bfd 100644 --- a/Foreign/C/Error.hs +++ b/Foreign/C/Error.hs @@ -9,7 +9,7 @@ -- Stability : provisional -- Portability : portable -- --- C-specific Marshalling support: Handling of C "errno" error codes +-- C-specific Marshalling support: Handling of C \"errno\" error codes -- ----------------------------------------------------------------------------- @@ -82,7 +82,9 @@ module Foreign.C.Error ( -- this is were we get the CCONST_XXX definitions from that configure -- calculated for us -- +#ifndef __NHC__ #include "config.h" +#endif -- system dependent imports -- ------------------------ @@ -105,7 +107,6 @@ import Foreign.Marshal.Error ( void ) import Data.Maybe #if __GLASGOW_HASKELL__ -import GHC.Storable import GHC.IOBase import GHC.Num import GHC.Base @@ -114,6 +115,11 @@ import System.IO ( IOError, Handle, ioError ) import System.IO.Unsafe ( unsafePerformIO ) #endif +#ifdef __HUGS__ +{-# CBITS errno.c #-} +#endif + + -- "errno" type -- ------------ @@ -121,7 +127,11 @@ import System.IO.Unsafe ( unsafePerformIO ) -- This function exists because errno is a variable on some systems, but on -- Windows it is a macro for a function... -- [yes, global variables and thread safety don't really go hand-in-hand. -- sof] +#ifdef __NHC__ +foreign import ccall unsafe "errno.h &errno" _errno :: Ptr CInt +#else foreign import ccall unsafe "HsBase.h ghcErrno" _errno :: Ptr CInt +#endif -- Haskell representation for "errno" values -- @@ -153,6 +163,9 @@ eOK, e2BIG, eACCES, eADDRINUSE, eADDRNOTAVAIL, eADV, eAFNOSUPPORT, eAGAIN, -- configure -- eOK = Errno 0 +#ifdef __NHC__ +#include "Errno.hs" +#else e2BIG = Errno (CCONST_E2BIG) eACCES = Errno (CCONST_EACCES) eADDRINUSE = Errno (CCONST_EADDRINUSE) @@ -251,6 +264,7 @@ eTXTBSY = Errno (CCONST_ETXTBSY) eUSERS = Errno (CCONST_EUSERS) eWOULDBLOCK = Errno (CCONST_EWOULDBLOCK) eXDEV = Errno (CCONST_EXDEV) +#endif -- checks whether the given errno value is supported on the current -- architecture