From a296464ea37be983319a0411d5439a29e3835d17 Mon Sep 17 00:00:00 2001 From: rrt Date: Wed, 15 Aug 2001 14:36:21 +0000 Subject: [PATCH] [project @ 2001-08-15 14:36:21 by rrt] Cut'n'paste rawSystem from hslibs rather than messing around trying to copy SystemExts.lhs into compiler/main, which makes for Makefile pain. --- ghc/compiler/Makefile | 9 +++------ ghc/compiler/main/SysTools.lhs | 21 +++++++++++++++++++-- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/ghc/compiler/Makefile b/ghc/compiler/Makefile index 1de433c..b229639 100644 --- a/ghc/compiler/Makefile +++ b/ghc/compiler/Makefile @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# $Id: Makefile,v 1.186 2001/08/15 14:02:54 sewardj Exp $ +# $Id: Makefile,v 1.187 2001/08/15 14:36:21 rrt Exp $ TOP = .. include $(TOP)/mk/boilerplate.mk @@ -143,19 +143,16 @@ HS_SRCS += $(CONFIG_HS) # GHC with GHC 5.02 or better, but lacking that we have the following # hack: # copy rawSystem.c from hslibs/lang/cbits -# and SystemExts.lhs from hslibs/lang -# into main/ (where they'll be compiled and linked with the compiler) +# into main/ (where it'll be compiled and linked with the compiler) +# (the Haskell-side code is ifdefed into main/SysTools.lhs) ifneq "$(ghc_502_at_least)" "YES" C_SRCS += main/rawSystem.c -HS_SRCS := $(filter-out main/SystemExts.lhs,$(HS_SRCS)) main/SystemExts.lhs SRC_CC_OPTS += -I$(GHC_LIB_DIR)/std/cbits SRC_MKDEPENDC_OPTS += -I$(GHC_LIB_DIR)/std/cbits HS_OBJS += main/rawSystem.o main/rawSystem.c : $(FPTOOLS_TOP)/hslibs/lang/cbits/rawSystem.c $(CP) $< main -main/SystemExts.lhs: $(FPTOOLS_TOP)/hslibs/lang/SystemExts.lhs - $(CP) $< main endif endif # End of system hack diff --git a/ghc/compiler/main/SysTools.lhs b/ghc/compiler/main/SysTools.lhs index cbd7bb1..8c4694b 100644 --- a/ghc/compiler/main/SysTools.lhs +++ b/ghc/compiler/main/SysTools.lhs @@ -1,5 +1,5 @@ ----------------------------------------------------------------------------- --- $Id: SysTools.lhs,v 1.49 2001/08/15 09:32:40 rrt Exp $ +-- $Id: SysTools.lhs,v 1.50 2001/08/15 14:36:21 rrt Exp $ -- -- (c) The University of Glasgow 2001 -- @@ -74,7 +74,12 @@ import qualified Posix #else import List ( isPrefixOf ) import MarshalArray -import SystemExts ( rawSystem ) +-- use the line below when we can be sure of compiling with GHC >= +-- 5.02, and remove the implementation of rawSystem at the end of this +-- file +import PrelIOBase -- this can be removed when SystemExts is used +import CError ( throwErrnoIfMinus1 ) -- as can this +-- import SystemExts ( rawSystem ) #endif #include "HsVersions.h" @@ -795,4 +800,16 @@ foreign import "_getpid" getProcessID :: IO Int -- relies on Int == Int32 on Win getProcessID :: IO Int getProcessID = Posix.getProcessID #endif + +rawSystem :: String -> IO ExitCode +rawSystem "" = ioException (IOError Nothing InvalidArgument "rawSystem" "null command" Nothing) +rawSystem cmd = + withUnsafeCString cmd $ \s -> do + status <- throwErrnoIfMinus1 "rawSystem" (primRawSystem s) + case status of + 0 -> return ExitSuccess + n -> return (ExitFailure n) + +foreign import ccall "rawSystemCmd" unsafe primRawSystem :: UnsafeCString -> IO Int + \end{code} -- 1.7.10.4