2006-03-15 13:06:18 +01:00
|
|
|
/*
|
|
|
|
* assert.c - diagnostics
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdio.h>
|
2011-04-27 15:00:52 +02:00
|
|
|
|
|
|
|
#ifndef __NBSD_LIBC
|
2006-03-15 13:06:18 +01:00
|
|
|
#include <minix/config.h>
|
|
|
|
#include <minix/const.h>
|
|
|
|
#include <minix/sysutil.h>
|
|
|
|
|
|
|
|
void __bad_assertion(const char *mess) {
|
2010-03-05 16:05:11 +01:00
|
|
|
panic("%s", mess);
|
2006-03-15 13:06:18 +01:00
|
|
|
}
|
2011-04-27 15:00:52 +02:00
|
|
|
|
|
|
|
#else /* NBSD_LIBC */
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
void
|
|
|
|
__assert13(file, line, function, failedexpr)
|
|
|
|
const char *file, *function, *failedexpr;
|
|
|
|
int line;
|
|
|
|
{
|
|
|
|
|
|
|
|
(void)fprintf(stderr,
|
|
|
|
"assertion \"%s\" failed: file \"%s\", line %d%s%s%s\n",
|
|
|
|
failedexpr, file, line,
|
|
|
|
function ? ", function \"" : "",
|
|
|
|
function ? function : "",
|
|
|
|
function ? "\"" : "");
|
|
|
|
abort();
|
|
|
|
/* NOTREACHED */
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
__assert(file, line, failedexpr)
|
|
|
|
const char *file, *failedexpr;
|
|
|
|
int line;
|
|
|
|
{
|
|
|
|
|
|
|
|
__assert13(file, line, NULL, failedexpr);
|
|
|
|
/* NOTREACHED */
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* NBSD_LIBC */
|