From: Malcolm.Wallace@cs.york.ac.uk Date: Fri, 6 Feb 2009 11:11:52 +0000 (+0000) Subject: Make System.Posix.Internals buildable by nhc98. X-Git-Tag: 2009-06-25~66 X-Git-Url: http://git.megacz.com/?p=ghc-base.git;a=commitdiff_plain;h=882ba4a2b3d4a7f72ad3b1fd239903ec7a8c8bae Make System.Posix.Internals buildable by nhc98. --- diff --git a/Makefile.nhc98 b/Makefile.nhc98 index 6d7752b..b46a8a9 100644 --- a/Makefile.nhc98 +++ b/Makefile.nhc98 @@ -40,7 +40,7 @@ SRCS = \ Text/ParserCombinators/ReadP.hs Data/Version.hs \ Unsafe/Coerce.hs \ WCsubst.c \ - System/Posix/Types.hs \ + System/Posix/Types.hs System/Posix/Internals.hs \ # Data/String.hs # Text/ParserCombinators/ReadPrec.hs diff --git a/System/Posix/Internals.hs b/System/Posix/Internals.hs index c4d9b19..09243ac 100644 --- a/System/Posix/Internals.hs +++ b/System/Posix/Internals.hs @@ -23,7 +23,9 @@ -- #hide module System.Posix.Internals where -#include "HsBaseConfig.h" +#ifndef __NHC__ +# include "HsBaseConfig.h" +#endif #if ! (defined(mingw32_HOST_OS) || defined(__MINGW32__)) import Control.Monad @@ -48,8 +50,10 @@ import GHC.IOBase #elif __HUGS__ import Hugs.Prelude (IOException(..), IOErrorType(..)) import Hugs.IO (IOMode(..)) -#else +#elif __NHC__ import System.IO +import Control.Exception +import DIOError #endif #ifdef __HUGS__ @@ -90,8 +94,8 @@ fdFileSize fd = if not (s_isreg c_mode) then return (-1) else do - c_size <- st_size p_stat - return (fromIntegral c_size) + c_size <- st_size p_stat + return (fromIntegral c_size) data FDType = Directory | Stream | RegularFile | RawDevice deriving (Eq) @@ -132,12 +136,16 @@ statGetType p_stat = do | otherwise -> ioError ioe_unknownfiletype ioe_unknownfiletype :: IOException +#ifndef __NHC__ ioe_unknownfiletype = IOError Nothing UnsupportedOperation "fdType" "unknown file type" -#if __GLASGOW_HASKELL__ +# if __GLASGOW_HASKELL__ Nothing -#endif +# endif Nothing +#else +ioe_unknownfiletype = UserError "fdType" "unknown file type" +#endif #if __GLASGOW_HASKELL__ && (defined(mingw32_HOST_OS) || defined(__MINGW32__)) closeFd :: Bool -> CInt -> IO CInt @@ -274,7 +282,11 @@ setCooked fd cooked = do ioe_unk_error :: String -> String -> IOException ioe_unk_error loc msg +#ifndef __NHC__ = ioeSetErrorString (mkIOError OtherError loc Nothing Nothing) msg +#else + = UserError loc msg +#endif -- Note: echoing goes hand in hand with enabling 'line input' / raw-ness -- for Win32 consoles, hence setEcho ends up being the inverse of setCooked. diff --git a/include/HsBase.h b/include/HsBase.h index fd10e11..dfc545f 100644 --- a/include/HsBase.h +++ b/include/HsBase.h @@ -9,7 +9,11 @@ #ifndef __HSBASE_H__ #define __HSBASE_H__ +#ifdef __NHC__ +# include "Nhc98BaseConfig.h" +#else #include "HsBaseConfig.h" +#endif /* ultra-evil... */ #undef PACKAGE_BUGREPORT diff --git a/include/Nhc98BaseConfig.h b/include/Nhc98BaseConfig.h new file mode 100644 index 0000000..5b6e23e --- /dev/null +++ b/include/Nhc98BaseConfig.h @@ -0,0 +1,44 @@ +/* ----------------------------------------------------------------------------- + * (c) Malcolm Wallace 2009 + * ---------------------------------------------------------------------------*/ + +/* Until we work out how to use a configure script to determine the available + system headers (without going down the horrid autoconf route), let's just + take a reasonable hard-coded guess for now. Feel free to change these + for your platform. + */ +#define HAVE_SYS_TYPES_H 1 +#define HAVE_UNISTD_H 1 +#define HAVE_SYS_STAT_H 1 +#define HAVE_FCNTL_H 1 +#define HAVE_TERMIOS_H 1 +#define HAVE_SIGNAL_H 1 +#define HAVE_ERRNO_H 1 +#define HAVE_STRING_H 1 +#define HAVE_UTIME_H 1 +#define HAVE_SYS_UTSNAME_H 1 +#define HAVE_GETTIMEOFDAY 1 +#define HAVE_SYS_TIME_H 1 +#define HAVE_GETCLOCK 0 +#define HAVE_SYS_TIMERS_H 0 +#define HAVE_TIME_H 1 +#define HAVE_SYS_TIMEB_H 1 +#define HAVE_WINDOWS_H 0 +#define HAVE_SYS_TIMES_H 1 +#define HAVE_WINSOCK_H 0 +#define HAVE_LIMITS_H 1 +#define HAVE_WCTYPE_H 1 +#define HAVE_INTTYPES_H 1 +// #define HAVE_STDINT_H 1 +#define HAVE_SYS_RESOURCE_H 1 +#define HAVE_GETRUSAGE 1 +#define HAVE_SYS_SYSCALL_H 1 +#define HAVE_SYS_WAIT_H 1 +#define HAVE_VFORK_H 0 +#define HAVE_SYS_SELECT_H 1 +#define HAVE_FTRUNCATE 1 + +#undef SUPPORT_LONG_LONGS +#define CONST_O_BINARY 0 +#define READDIR_ERRNO_EOF 0 + diff --git a/include/dirUtils.h b/include/dirUtils.h index d5d75bb..87a3041 100644 --- a/include/dirUtils.h +++ b/include/dirUtils.h @@ -5,6 +5,8 @@ */ #ifndef __DIRUTILS_H__ #define __DIRUTILS_H__ +#include +#include extern int __hscore_readdir(DIR *dirPtr, struct dirent **pDirEnt);