summaryrefslogtreecommitdiffhomepage
path: root/compat
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-27 12:57:13 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-27 12:57:13 +0200
commitf8b9bed570735f5c11faa2e66da28e4e4236845d (patch)
tree2ee97a68d2e68819216888446ecc3d08970f973a /compat
parentd0d1f44ac77d4ce8c644e1fe2360ae0904f4e1a7 (diff)
roll up one's own abort()
Diffstat (limited to 'compat')
-rw-r--r--compat/assert.hpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/compat/assert.hpp b/compat/assert.hpp
index 29b6d081..3a6fed34 100644
--- a/compat/assert.hpp
+++ b/compat/assert.hpp
@@ -1,6 +1,5 @@
#pragma once
#include "defs.hpp"
-#include <cstdlib>
#include <cstdio>
#include <type_traits>
@@ -16,6 +15,16 @@
#define FM_KILL_WARN_double_promotion2()
#endif
+namespace floormat {
+
+[[noreturn]] [[maybe_unused]] static inline void _fm_abort() {
+ *(volatile int*)nullptr = 0;
+ for (;;)
+ ;
+}
+
+} // namespace floormat
+
#define fm_EMIT_DEBUG(pfx, ...) \
do { \
if (!std::is_constant_evaluated()) { \
@@ -32,15 +41,15 @@
#define fm_abort(...) \
do { \
fm_EMIT_DEBUG("fatal: ", __VA_ARGS__); \
- std::abort(); \
+ ::floormat::_fm_abort(); \
} while (false)
#define fm_assert(...) \
do { \
if (!(__VA_ARGS__)) { \
fm_EMIT_DEBUG("", "assertion failed: '%s' in %s:%d", \
- #__VA_ARGS__, __FILE__, __LINE__); \
- std::abort(); \
+ #__VA_ARGS__, __FILE__, __LINE__); \
+ ::floormat::_fm_abort(); \
} \
} while(false)