| ... | @@ -43,15 +43,21 @@ ATTRIBUTE_NORETURN | ... | @@ -43,15 +43,21 @@ ATTRIBUTE_NORETURN |
| 43 | ATTRIBUTE_PRINTF(1, 2) | 43 | ATTRIBUTE_PRINTF(1, 2) |
| 44 | void zig_panic(const char *format, ...); | 44 | void zig_panic(const char *format, ...); |
| 45 | | 45 | |
| | 46 | static inline void zig_assert(bool ok, const char *file, int line, const char *func) { |
| | 47 | if (!ok) { |
| | 48 | zig_panic("Assertion failed at %s:%d in %s. This is a bug in the Zig compiler.", file, line, func); |
| | 49 | } |
| | 50 | } |
| | 51 | |
| 46 | #ifdef _WIN32 | 52 | #ifdef _WIN32 |
| 47 | #define __func__ __FUNCTION__ | 53 | #define __func__ __FUNCTION__ |
| 48 | #endif | 54 | #endif |
| 49 | | 55 | |
| 50 | #define zig_unreachable() zig_panic("unreachable: %s:%s:%d", __FILE__, __func__, __LINE__) | 56 | #define zig_unreachable() zig_panic("Unreachable at %s:%d in %s. This is a bug in the Zig compiler.", __FILE__, __LINE__, __func__) |
| 51 | | 57 | |
| 52 | // Assertions in stage1 are always on, and they call zig @panic. | 58 | // Assertions in stage1 are always on, and they call zig @panic. |
| 53 | #undef assert | 59 | #undef assert |
| 54 | void assert(bool ok); | 60 | #define assert(ok) zig_assert(ok, __FILE__, __LINE__, __func__) |
| 55 | | 61 | |
| 56 | #if defined(_MSC_VER) | 62 | #if defined(_MSC_VER) |
| 57 | static inline int clzll(unsigned long long mask) { | 63 | static inline int clzll(unsigned long long mask) { |