From ad455445e0c798e348a96a7a835c8d0ccf939e89 Mon Sep 17 00:00:00 2001 From: simonmar Date: Wed, 16 Feb 2005 11:16:42 +0000 Subject: [PATCH] [project @ 2005-02-16 11:16:40 by simonmar] assertion failures should go through the RtsMessages layer, so they get a pop-up box in a Windows app. --- ghc/includes/Cmm.h | 2 +- ghc/includes/Rts.h | 4 ++-- ghc/includes/RtsMessages.h | 3 +++ ghc/rts/RtsMessages.c | 15 +++++++++++++++ ghc/rts/RtsUtils.c | 9 --------- ghc/rts/RtsUtils.h | 2 -- 6 files changed, 21 insertions(+), 14 deletions(-) diff --git a/ghc/includes/Cmm.h b/ghc/includes/Cmm.h index 486df2f..240b16a 100644 --- a/ghc/includes/Cmm.h +++ b/ghc/includes/Cmm.h @@ -188,7 +188,7 @@ if (predicate) { \ /*null*/; \ } else { \ - foreign "C" _stgAssert(NULL, __LINE__); \ + foreign "C" _assertFail(NULL, __LINE__); \ } #else #define ASSERT(p) /* nothing */ diff --git a/ghc/includes/Rts.h b/ghc/includes/Rts.h index 4e59472..fb2a70b 100644 --- a/ghc/includes/Rts.h +++ b/ghc/includes/Rts.h @@ -57,13 +57,13 @@ extern "C" { #define ASSERT(predicate) /* nothing */ #else -void _stgAssert (char *, unsigned int); +extern void _assertFail (char *, unsigned int); #define ASSERT(predicate) \ if (predicate) \ /*null*/; \ else \ - _stgAssert(__FILE__, __LINE__) + _assertFail(__FILE__, __LINE__) #endif /* DEBUG */ /* diff --git a/ghc/includes/RtsMessages.h b/ghc/includes/RtsMessages.h index 40baaa0..7e75349 100644 --- a/ghc/includes/RtsMessages.h +++ b/ghc/includes/RtsMessages.h @@ -32,6 +32,9 @@ extern void barf(char *s, ...) extern void vbarf(char *s, va_list ap) GNUC3_ATTRIBUTE(__noreturn__); +extern void _assertFail(char *filename, unsigned int linenum) + GNUC3_ATTRIBUTE(__noreturn__); + /* * An error condition which is caused by and/or can be corrected by * the user. diff --git a/ghc/rts/RtsMessages.c b/ghc/rts/RtsMessages.c index 60173c1..b8fed78 100644 --- a/ghc/rts/RtsMessages.c +++ b/ghc/rts/RtsMessages.c @@ -46,6 +46,21 @@ vbarf(char *s, va_list ap) stg_exit(EXIT_INTERNAL_ERROR); // just in case fatalInternalErrorFn() returns } +void +_assertFail(char *filename, unsigned int linenum) +{ + internalErrorBelch("ASSERTION FAILED: file %s, line %u\n", filename, linenum); + abort(); +} + +internalErrorBelch(char *s, ...) +{ + va_list ap; + va_start(ap,s); + (*fatalInternalErrorFn)(s,ap); + va_end(ap); +} + void errorBelch(char *s, ...) { diff --git a/ghc/rts/RtsUtils.c b/ghc/rts/RtsUtils.c index ce1c0a2..646fba9 100644 --- a/ghc/rts/RtsUtils.c +++ b/ghc/rts/RtsUtils.c @@ -89,15 +89,6 @@ stgFree(void* p) free(p); } -void -_stgAssert (char *filename, unsigned int linenum) -{ - fflush(stdout); - fprintf(stderr, "ASSERTION FAILED: file %s, line %u\n", filename, linenum); - fflush(stderr); - abort(); -} - /* ----------------------------------------------------------------------------- Stack overflow diff --git a/ghc/rts/RtsUtils.h b/ghc/rts/RtsUtils.h index 97769b9..e2222ae 100644 --- a/ghc/rts/RtsUtils.h +++ b/ghc/rts/RtsUtils.h @@ -27,8 +27,6 @@ extern void stgFree(void* p); * Misc other utilities * -------------------------------------------------------------------------- */ -extern void _stgAssert (char *filename, unsigned int linenum); - extern void heapOverflow(void); extern void setNonBlockingFd(int fd); -- 1.7.10.4