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#ifndef ASSERT_HPP
6#define ASSERT_HPP
7
8#pragma once
9
10#include "architecture.hpp"
11#include "debugger.hpp"
12#include "utils.hpp"
13#include <exception>
14
15namespace hi::inline v1 {
16
22#define hi_assert(expression) \
23 do { \
24 if (not(expression)) { \
25 hi_debug_abort(); \
26 } \
27 } while (false)
28
35#define hi_assert_or_return(x, y) \
36 if (!(x)) { \
37 [[unlikely]] return y; \
38 }
39
40#if HI_BUILD_TYPE == HI_BT_DEBUG
47#define hi_axiom(expression) hi_assert(expression)
48
52#define hi_no_default() [[unlikely]] hi_debug_abort()
53
54#else
61#define hi_axiom(expression) hi_assume(expression)
62
66#define hi_no_default() hi_unreachable()
67#endif
68
72#define hi_static_no_default() \
73 []<bool Flag = false>() \
74 { \
75 static_assert(Flag); \
76 } \
77 ()
78
82#define hi_not_implemented() [[unlikely]] hi_debug_abort();
83
87#define hi_static_not_implemented() hi_static_no_default()
88
89} // namespace hi::inline v1
90
91#endif
Functions and macros for handling architectural difference between compilers, CPUs and operating syst...