From f8b9bed570735f5c11faa2e66da28e4e4236845d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 27 Oct 2022 12:57:13 +0200 Subject: roll up one's own abort() --- compat/assert.hpp | 17 +++++++++++++---- 1 file 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 #include #include @@ -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) -- cgit v1.2.3