-- Initialisation
initSysTools,
- setPgmP, -- String -> IO ()
+ setPgmL, -- String -> IO ()
+ setPgmP,
setPgmF,
setPgmc,
setPgmm,
import CmdLineOpts ( dynFlag, verbosity )
import EXCEPTION ( throwDyn )
-#if __GLASGOW_HASKELL__ > 408
-import qualified EXCEPTION as Exception ( catch )
-#else
-import EXCEPTION ( catchAllIO )
-#endif
-
import DATA_IOREF ( IORef, readIORef, writeIORef )
import DATA_INT
import Monad ( when, unless )
import System ( ExitCode(..), exitWith, getEnv, system )
-import IO
+import IO ( try, catch,
+ openFile, hPutChar, hPutStrLn, hPutStr, hClose, hFlush, IOMode(..),
+ stderr )
import Directory ( doesFileExist, removeFile )
#include "../includes/config.h"
#endif
#ifndef mingw32_HOST_OS
-import qualified Posix
+#if __GLASGOW_HASKELL__ > 504
+import qualified System.Posix.Internals
#else
+import qualified Posix
+#endif
+#else /* Must be Win32 */
import List ( isPrefixOf )
import Util ( dropList )
-import MarshalArray
import Foreign
+import CString ( CString, peekCString )
#endif
#ifdef mingw32_HOST_OS
#else
import SystemExts ( rawSystem )
#endif
-#else
-import System ( system )
-#endif
--- Make catch work on older GHCs
-#if __GLASGOW_HASKELL__ > 408
-myCatch = Exception.catch
-#else
-myCatch = catchAllIO
-#endif
+#else /* Not Win32 */
+import System ( system )
+#endif
\end{code}
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
("Deleting: " ++ unwords fs)
(mapM_ rm fs)
where
- rm f = removeFile f `myCatch`
+ rm f = removeFile f `IO.catch`
(\_ignored ->
when (verb >= 2) $
hPutStrLn stderr ("Warning: deleting non-existent " ++ f)
; unless n $ do {
-- And run it!
- ; action `myCatch` handle_exn verb
+ ; action `IO.catch` handle_exn verb
}}
where
handle_exn verb exn = do { when (verb >= 2) (hPutStr stderr "\n")
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 = System.Posix.Internals..c_getpid >>= return . fromIntegral
#else
getProcessID :: IO Int
getProcessID = Posix.getProcessID