aboutsummaryrefslogtreecommitdiff
path: root/src/util.cpp
diff options
context:
space:
mode:
authorhryx <codroid@gmail.com>2019-05-12 02:00:49 -0700
committerhryx <codroid@gmail.com>2019-05-12 02:00:49 -0700
commit3787f3428625e830fd852a8f5a40c7d8a2d429f6 (patch)
tree23fb493b9d2f07c7abe57955874682959936319a /src/util.cpp
parent16aee1f58a80295f7599a8290d764a5c7040c373 (diff)
parentedcc7c72d1a684a8a16ca23ad26689f2cce4e803 (diff)
downloadzig-3787f3428625e830fd852a8f5a40c7d8a2d429f6.tar.gz
zig-3787f3428625e830fd852a8f5a40c7d8a2d429f6.zip
Merge branch 'master' into rebased
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp10
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);
}