HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
assert.hpp
1// Copyright Take Vos 2020-2021.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "architecture.hpp"
8#include "debugger.hpp"
9#include "utils.hpp"
10#include "required.hpp"
11#include <exception>
12
13namespace hi::inline v1 {
14
20#define hi_assert(expression) \
21 do { \
22 if (not(expression)) { \
23 hi_debug_abort(); \
24 } \
25 } while (false)
26
33#define hi_assert_or_return(x, y) \
34 if (!(x)) { \
35 [[unlikely]] return y; \
36 }
37
38#if HI_BUILD_TYPE == HI_BT_DEBUG
45#define hi_axiom(expression) hi_assert(expression)
46
50#define hi_no_default() [[unlikely]] hi_debug_abort()
51
52#else
59#define hi_axiom(expression) hi_assume(expression)
60
64#define hi_no_default() hi_unreachable()
65#endif
66
70#define hi_static_no_default() \
71 []<bool Flag = false>() \
72 { \
73 static_assert(Flag); \
74 } \
75 ()
76
80#define hi_not_implemented() [[unlikely]] hi_debug_abort();
81
85#define hi_static_not_implemented() hi_static_no_default()
86
87} // namespace hi::inline v1
This file includes required definitions.
Functions and macros for handling architectural difference between compilers, CPUs and operating syst...