2020-01-18 11:38:21 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 11:38:21 +03:00
|
|
|
*/
|
|
|
|
|
2018-10-16 12:01:38 +03:00
|
|
|
#pragma once
|
2019-04-03 13:51:10 +03:00
|
|
|
|
2020-06-27 22:42:28 +03:00
|
|
|
#define __STRINGIFY_HELPER(x) #x
|
|
|
|
#define __STRINGIFY(x) __STRINGIFY_HELPER(x)
|
|
|
|
|
2019-04-03 13:51:10 +03:00
|
|
|
[[noreturn]] void __assertion_failed(const char* msg, const char* file, unsigned line, const char* func);
|
2021-06-29 16:46:50 +03:00
|
|
|
#define VERIFY(expr) \
|
|
|
|
do { \
|
|
|
|
if (!static_cast<bool>(expr)) [[unlikely]] \
|
|
|
|
__assertion_failed(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
|
|
|
|
} while (0)
|
|
|
|
|
2021-06-11 09:55:52 +03:00
|
|
|
#define VERIFY_NOT_REACHED() VERIFY(false)
|
2021-04-18 09:43:10 +03:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
[[noreturn]] void _abort();
|
|
|
|
[[noreturn]] void abort();
|
|
|
|
}
|
2020-06-28 02:06:33 +03:00
|
|
|
|
2021-02-23 22:42:32 +03:00
|
|
|
#define VERIFY_INTERRUPTS_DISABLED() VERIFY(!(cpu_flags() & 0x200))
|
|
|
|
#define VERIFY_INTERRUPTS_ENABLED() VERIFY(cpu_flags() & 0x200)
|
2021-08-03 23:02:19 +03:00
|
|
|
|
|
|
|
static constexpr bool TODO = false;
|
|
|
|
#define TODO() VERIFY(TODO)
|