stage1 assertions always on, and have stack traces

This commit is contained in:
Andrew Kelley
2019-04-17 15:58:20 -04:00
parent 4ad7d09ba5
commit ff3cdbc3a0
8 changed files with 38 additions and 13 deletions

View File

@@ -10,17 +10,25 @@
#include <stdarg.h>
#include "util.hpp"
#include "userland.h"
void zig_panic(const char *format, ...) {
va_list ap;
va_start(ap, format);
vfprintf(stderr, format, ap);
fprintf(stderr, "\n");
fflush(stderr);
va_end(ap);
stage2_panic(nullptr, 0);
abort();
}
void assert(bool ok) {
if (!ok) {
const char *msg = "Assertion failed. This is a bug in the Zig compiler.";
stage2_panic(msg, strlen(msg));
}
}
uint32_t int_hash(int i) {
return (uint32_t)(i % UINT32_MAX);
}