Commit ad455445 authored by simonmar's avatar simonmar
Browse files

[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.
parent 4553e941
......@@ -188,7 +188,7 @@
if (predicate) { \
/*null*/; \
} else { \
foreign "C" _stgAssert(NULL, __LINE__); \
foreign "C" _assertFail(NULL, __LINE__); \
}
#else
#define ASSERT(p) /* nothing */
......
......@@ -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 */
/*
......
......@@ -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.
......
......@@ -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, ...)
{
......
......@@ -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
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment