abort() on assertion failure
This commit is contained in:
parent
17bc4609e8
commit
857f7095ff
@ -1,7 +1,7 @@
|
|||||||
// TODO: move to a proper place once I do abort()
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
_Noreturn void _assert_fail(const char *func, const char *msg) {
|
_Noreturn void _assert_fail(const char *func, const char *msg) {
|
||||||
static const char msg0[] = "In function `";
|
static const char msg0[] = "In function `";
|
||||||
@ -12,5 +12,6 @@ _Noreturn void _assert_fail(const char *func, const char *msg) {
|
|||||||
write(STDERR_FILENO, msg, strlen(msg));
|
write(STDERR_FILENO, msg, strlen(msg));
|
||||||
write(STDERR_FILENO, msg1 + 2, 1);
|
write(STDERR_FILENO, msg1 + 2, 1);
|
||||||
|
|
||||||
_exit(-1);
|
abort();
|
||||||
|
while (1);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user