[project @ 2001-01-28 19:43:01 by simonmar]
[ghc-hetmet.git] / ghc / lib / std / PrelCError.lhs
index 0169233..12132fb 100644 (file)
@@ -1,5 +1,5 @@
 % -----------------------------------------------------------------------------
-% $Id: PrelCError.lhs,v 1.4 2001/01/16 06:02:29 qrczak Exp $
+% $Id: PrelCError.lhs,v 1.6 2001/01/27 07:46:27 qrczak Exp $
 %
 % (c) The FFI task force, 2000
 %
@@ -7,7 +7,7 @@
 C-specific Marshalling support: Handling of C "errno" error codes
 
 \begin{code}
-{-# OPTIONS -fno-implicit-prelude #-}
+{-# OPTIONS -fno-implicit-prelude -#include "cbits/ghc_errno.h" #-}
 
 -- this is were we get the CCONST_XXX definitions from that configure
 -- calculated for us
@@ -135,6 +135,10 @@ data IOErrorType
 -- "errno" type
 -- ------------
 
+-- import of C function that gives address of errno
+--
+foreign import "ghcErrno" unsafe _errno :: Ptr CInt
+
 -- Haskell representation for "errno" values
 --
 newtype Errno = Errno CInt
@@ -594,9 +598,4 @@ errnoToIOError loc errno@(Errno no) maybeHdl maybeName =
       | otherwise                 = (OtherError, 
                                     "unexpected error (error code: " 
                                     ++ show no ++")")
-
-foreign label "errno" _errno :: Ptr CInt
-  -- FIXME: this routine should eventually be provided by the Haskell runtime
-  --       and guarantee that the "errno" of the last operation performed by
-  --       the current thread is returned 
 \end{code}