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
|
|
|
|
2020-06-27 13:42:28 -06:00
|
|
|
#define __STRINGIFY_HELPER(x) #x
|
|
|
|
|
#define __STRINGIFY(x) __STRINGIFY_HELPER(x)
|
|
|
|
|
|
2019-04-23 21:52:02 +02:00
|
|
|
#ifdef DEBUG
|
2019-04-03 12:51:10 +02:00
|
|
|
[[noreturn]] void __assertion_failed(const char* msg, const char* file, unsigned line, const char* func);
|
2021-02-23 20:42:32 +01:00
|
|
|
# define VERIFY(expr) (static_cast<bool>(expr) ? void(0) : __assertion_failed(# expr, __FILE__, __LINE__, __PRETTY_FUNCTION__))
|
|
|
|
|
# define VERIFY_NOT_REACHED() VERIFY(false)
|
2019-04-23 21:52:02 +02:00
|
|
|
#else
|
2021-02-23 20:42:32 +01:00
|
|
|
# define VERIFY(expr)
|
2021-04-18 08:43:10 +02:00
|
|
|
# define VERIFY_NOT_REACHED() _abort()
|
2019-04-23 21:52:02 +02:00
|
|
|
#endif
|
2021-04-18 08:43:10 +02:00
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
[[noreturn]] void _abort();
|
|
|
|
|
[[noreturn]] void abort();
|
|
|
|
|
}
|
2020-06-27 17:06:33 -06:00
|
|
|
|
2021-02-23 20:42:32 +01:00
|
|
|
#define VERIFY_INTERRUPTS_DISABLED() VERIFY(!(cpu_flags() & 0x200))
|
|
|
|
|
#define VERIFY_INTERRUPTS_ENABLED() VERIFY(cpu_flags() & 0x200)
|
|
|
|
|
#define TODO VERIFY_NOT_REACHED
|