diff options
Diffstat (limited to 'src/util.cpp')
| -rw-r--r-- | src/util.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/util.cpp b/src/util.cpp index 192d74e766..9a6a382993 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -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); } |
