Commit: fd21f553e18db0a6d0407b4ab296c0e1c82b2c54
Parent: b9168939493649c54bbaf9c23d34347181fd5471
Author: Randy Palamar
Date: Mon, 7 Oct 2024 21:19:56 -0600
add unreachable() for ensuring compiler doesn't do dumb things
Diffstat:
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/os_win32.c b/os_win32.c
@@ -85,6 +85,7 @@ static void __attribute__((noreturn))
os_fail(void)
{
ExitProcess(1);
+ unreachable();
}
static void
diff --git a/util.h b/util.h
@@ -17,6 +17,14 @@
#define asm __asm__
#endif
+#ifndef unreachable
+#ifdef _MSC_VER
+ #define unreachable() __assume(0)
+#else
+ #define unreachable() __builtitin_unreachable()
+#endif
+#endif
+
#ifdef _DEBUG
#define ASSERT(c) do { if (!(c)) asm("int3; nop"); } while (0);
#else