From 3c52c938ecbf4c769d0dfcb310707149dcef1f93 Mon Sep 17 00:00:00 2001 From: malcolm Date: Wed, 18 Dec 2002 10:45:33 +0000 Subject: [PATCH] [project @ 2002-12-18 10:45:31 by malcolm] Now compiles with nhc98. --- Data/Ratio.hs | 5 +++++ Foreign/C/Error.hs | 10 ++++++++++ System/Directory.hs | 6 ++++++ System/Info.hs | 9 +++++++++ 4 files changed, 30 insertions(+) diff --git a/Data/Ratio.hs b/Data/Ratio.hs index 8a5b55f..14e5f65 100644 --- a/Data/Ratio.hs +++ b/Data/Ratio.hs @@ -43,6 +43,10 @@ import GHC.Real -- The basic defns for Ratio import Hugs.Prelude(Ratio(..), (%), numerator, denominator) #endif +#ifdef __NHC__ +import Ratio (Ratio(..), (%), numerator, denominator, approxRational) +#else + -- ----------------------------------------------------------------------------- -- approxRational @@ -80,3 +84,4 @@ approxRational rat eps = simplest (rat-eps) (rat+eps) nd'' = simplest' d' r' d r n'' = numerator nd'' d'' = denominator nd'' +#endif diff --git a/Foreign/C/Error.hs b/Foreign/C/Error.hs index dcee040..069367b 100644 --- a/Foreign/C/Error.hs +++ b/Foreign/C/Error.hs @@ -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 -- ------------------------ @@ -121,7 +123,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 +159,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 +260,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 diff --git a/System/Directory.hs b/System/Directory.hs index d3245df..f05846b 100644 --- a/System/Directory.hs +++ b/System/Directory.hs @@ -55,6 +55,10 @@ module System.Directory , getModificationTime -- :: FilePath -> IO ClockTime ) where +#ifdef __NHC__ +import Directory +#else + import Prelude import Control.Exception ( bracket ) @@ -621,3 +625,5 @@ foreign import ccall unsafe "__hscore_X_OK" x_OK :: CMode foreign import ccall unsafe "__hscore_S_IRUSR" s_IRUSR :: CMode foreign import ccall unsafe "__hscore_S_IWUSR" s_IWUSR :: CMode foreign import ccall unsafe "__hscore_S_IXUSR" s_IXUSR :: CMode + +#endif diff --git a/System/Info.hs b/System/Info.hs index 452cec5..02cd45d 100644 --- a/System/Info.hs +++ b/System/Info.hs @@ -13,7 +13,9 @@ -- ----------------------------------------------------------------------------- +#ifndef __NHC__ #include "MachDeps.h" +#endif module System.Info ( @@ -23,8 +25,15 @@ module System.Info import Prelude +#ifndef __NHC__ + arch :: String arch = HOST_ARCH os :: String os = HOST_OS + +#else +os,arch ::String +#include "OSInfo.hs" +#endif -- 1.7.10.4