X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=Control%2FException.hs;h=83f37cb23970c0aebbe710410bcb009133f7de37;hb=99a329d9b272925dcdf474ce2369e9421b51e51c;hp=05157d1e51cd155b14cd592652c60da9821bb414;hpb=5505736fa4594514aab2b3ea8b15171e8349b91e;p=ghc-base.git diff --git a/Control/Exception.hs b/Control/Exception.hs index 05157d1..83f37cb 100644 --- a/Control/Exception.hs +++ b/Control/Exception.hs @@ -117,7 +117,7 @@ import GHC.Base ( assert ) import GHC.Exception as ExceptionBase hiding (catch) import GHC.Conc ( throwTo, ThreadId ) import Data.IORef ( IORef, newIORef, readIORef, writeIORef ) -import Foreign.C.String ( CString, withCStringLen ) +import Foreign.C.String ( CString, withCString ) import System.IO ( stdout, hFlush ) #endif @@ -510,10 +510,11 @@ uncaughtExceptionHandler = unsafePerformIO (newIORef defaultHandler) Deadlock -> "no threads to run: infinite loop or deadlock?" ErrorCall s -> s other -> showsPrec 0 other "\n" - withCStringLen ("Fail: "++msg) $ \(cstr,len) -> writeErrString cstr len - -foreign import ccall unsafe "writeErrString__" - writeErrString :: CString -> Int -> IO () + withCString "%s" $ \cfmt -> + withCString msg $ \cmsg -> + errorBelch cfmt cmsg + +foreign import ccall unsafe errorBelch :: CString -> CString -> IO () setUncaughtExceptionHandler :: (Exception -> IO ()) -> IO () setUncaughtExceptionHandler = writeIORef uncaughtExceptionHandler