[project @ 2005-02-16 11:16:40 by simonmar]
authorsimonmar <unknown>
Wed, 16 Feb 2005 11:16:42 +0000 (11:16 +0000)
committersimonmar <unknown>
Wed, 16 Feb 2005 11:16:42 +0000 (11:16 +0000)
assertion failures should go through the RtsMessages layer, so they
get a pop-up box in a Windows app.

ghc/includes/Cmm.h
ghc/includes/Rts.h
ghc/includes/RtsMessages.h
ghc/rts/RtsMessages.c
ghc/rts/RtsUtils.c
ghc/rts/RtsUtils.h

index 486df2f..240b16a 100644 (file)
        if (predicate) {                        \
            /*null*/;                           \
        } else {                                \
-           foreign "C" _stgAssert(NULL, __LINE__); \
+           foreign "C" _assertFail(NULL, __LINE__); \
         }
 #else
 #define ASSERT(p) /* nothing */
index 4e59472..fb2a70b 100644 (file)
@@ -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 */
 
 /* 
index 40baaa0..7e75349 100644 (file)
@@ -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.
index 60173c1..b8fed78 100644 (file)
@@ -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, ...)
 {
index ce1c0a2..646fba9 100644 (file)
@@ -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
    
index 97769b9..e2222ae 100644 (file)
@@ -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);