2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
2018-10-16 11:01:38 +02:00
|
|
|
#pragma once
|
2019-04-03 12:51:10 +02:00
|
|
|
|
2021-11-30 22:59:05 +00:00
|
|
|
#include <AK/Platform.h>
|
|
|
|
|
2020-06-27 13:42:28 -06:00
|
|
|
#define __STRINGIFY_HELPER(x) #x
|
|
|
|
#define __STRINGIFY(x) __STRINGIFY_HELPER(x)
|
|
|
|
|
2022-04-01 20:58:27 +03:00
|
|
|
[[noreturn]] void __assertion_failed(char const* msg, char const* file, unsigned line, char const* func);
|
2021-06-29 15:46:50 +02:00
|
|
|
#define VERIFY(expr) \
|
|
|
|
do { \
|
|
|
|
if (!static_cast<bool>(expr)) [[unlikely]] \
|
|
|
|
__assertion_failed(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
|
|
|
|
} while (0)
|
|
|
|
|
2022-05-07 17:46:27 +02:00
|
|
|
#define VERIFY_NOT_REACHED() __assertion_failed("not reached", __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
2021-04-18 08:43:10 +02:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
[[noreturn]] void _abort();
|
|
|
|
[[noreturn]] void abort();
|
|
|
|
}
|
2020-06-27 17:06:33 -06:00
|
|
|
|
2022-05-07 17:46:27 +02:00
|
|
|
#define TODO() __assertion_failed("TODO", __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
2021-11-30 22:59:05 +00:00
|
|
|
|
|
|
|
#if ARCH(I386) || ARCH(X86_64)
|
|
|
|
# define VERIFY_INTERRUPTS_DISABLED() VERIFY(!(cpu_flags() & 0x200))
|
|
|
|
# define VERIFY_INTERRUPTS_ENABLED() VERIFY(cpu_flags() & 0x200)
|
|
|
|
#else
|
|
|
|
# define VERIFY_INTERRUPTS_DISABLED() TODO()
|
|
|
|
# define VERIFY_INTERRUPTS_ENABLED() TODO()
|
|
|
|
#endif
|