X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fmain%2FSysTools.lhs;h=d99ce5d195148dbea1e9e544b1f781726f8f2fd4;hb=b301b6ecef42b3787c0b6bbf81ad3301c36331fc;hp=d217469181e9aa3c8afaef109cdc7eb9a994e35b;hpb=99cccd623b63570df4d33cbe335faaee323826df;p=ghc-hetmet.git diff --git a/ghc/compiler/main/SysTools.lhs b/ghc/compiler/main/SysTools.lhs index d217469..d99ce5d 100644 --- a/ghc/compiler/main/SysTools.lhs +++ b/ghc/compiler/main/SysTools.lhs @@ -11,7 +11,8 @@ module SysTools ( -- Initialisation initSysTools, - setPgmP, -- String -> IO () + setPgmL, -- String -> IO () + setPgmP, setPgmF, setPgmc, setPgmm, @@ -91,7 +92,7 @@ import Directory ( doesFileExist, removeFile ) #ifndef mingw32_HOST_OS #if __GLASGOW_HASKELL__ > 504 -import qualified GHC.Posix +import qualified System.Posix.Internals #else import qualified Posix #endif @@ -106,17 +107,7 @@ import CString ( CString, peekCString ) #if __GLASGOW_HASKELL__ > 504 import System.Cmd ( rawSystem ) #else - - -- For Win32 and GHC <= 504 - -- rawSystem is defined in this module - -- We just need an import -#if __GLASGOW_HASKELL__ < 503 -import PrelIOBase( ioException, IOException(..), IOErrorType(InvalidArgument) ) -#else -import GHC.IOBase( ioException, IOException(..), IOErrorType(InvalidArgument) ) -#endif -import CError ( throwErrnoIfMinus1 ) -import CString ( withCString ) +import SystemExts ( rawSystem ) #endif #else /* Not Win32 */ @@ -439,6 +430,7 @@ like is used to override a particular program with a new one \begin{code} +setPgmL = writeIORef v_Pgm_L setPgmP = writeIORef v_Pgm_P setPgmF = writeIORef v_Pgm_F setPgmc = writeIORef v_Pgm_c @@ -851,50 +843,24 @@ getExecDir = do let len = (2048::Int) -- plenty, PATH_MAX is 512 under Win32. return (Just (reverse (dropList "/bin/ghc.exe" (reverse (unDosifyPath s))))) -foreign import stdcall "GetModuleFileNameA" unsafe +foreign import stdcall "GetModuleFileNameA" unsafe getModuleFileName :: Ptr () -> CString -> Int -> IO Int32 #else getExecDir :: IO (Maybe String) = do return Nothing #endif #ifdef mingw32_HOST_OS -foreign import "_getpid" unsafe getProcessID :: IO Int -- relies on Int == Int32 on Windows +foreign import ccall "_getpid" unsafe getProcessID :: IO Int -- relies on Int == Int32 on Windows #elif __GLASGOW_HASKELL__ > 504 getProcessID :: IO Int -getProcessID = GHC.Posix.c_getpid >>= return . fromIntegral +getProcessID = System.Posix.Internals.c_getpid >>= return . fromIntegral #else getProcessID :: IO Int getProcessID = Posix.getProcessID #endif quote :: String -> String -#if defined(mingw32_HOST_OS) quote "" = "" quote s = "\"" ++ s ++ "\"" -#else -quote s = s -#endif \end{code} - -This next blob is in System.Cmd after 5.04, but until then it needs -to be here (for Win32 only). - -\begin{code} -#if defined(mingw32_HOST_OS) -#if __GLASGOW_HASKELL__ <= 504 - -rawSystem :: String -> IO ExitCode -rawSystem "" = ioException (IOError Nothing InvalidArgument "rawSystem" "null command" Nothing) -rawSystem cmd = - withCString cmd $ \s -> do - status <- throwErrnoIfMinus1 "rawSystem" (primRawSystem s) - case status of - 0 -> return ExitSuccess - n -> return (ExitFailure n) - -foreign import ccall "rawSystemCmd" unsafe primRawSystem :: CString -> IO Int - -#endif -#endif -\end{code} \ No newline at end of file