2020-01-18 09:38:21 +01:00
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
|
2020-01-18 09:38:21 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
|
2018-10-10 11:53:07 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2025-05-04 17:33:39 +02:00
|
|
|
extern "C" void dump_backtrace();
|
2024-11-30 16:29:25 +01:00
|
|
|
extern "C" bool ak_colorize_output(void);
|
|
|
|
|
extern "C" __attribute__((noreturn)) void ak_trap(void);
|
|
|
|
|
|
2023-02-05 08:15:55 -07:00
|
|
|
extern "C" __attribute__((noreturn)) void ak_verification_failed(char const*);
|
2024-06-17 23:12:53 +01:00
|
|
|
#define __stringify_helper(x) #x
|
|
|
|
|
#define __stringify(x) __stringify_helper(x)
|
2024-11-17 15:20:23 +01:00
|
|
|
#define VERIFY(...) \
|
|
|
|
|
(__builtin_expect(/* NOLINT(readability-simplify-boolean-expr) */ !(__VA_ARGS__), 0) \
|
|
|
|
|
? ak_verification_failed(#__VA_ARGS__ " at " __FILE__ ":" __stringify(__LINE__)) \
|
2024-06-17 23:12:53 +01:00
|
|
|
: (void)0)
|
|
|
|
|
#define VERIFY_NOT_REACHED() VERIFY(false) /* NOLINT(cert-dcl03-c,misc-static-assert) No, this can't be static_assert, it's a runtime check */
|
2021-08-03 20:02:19 +00:00
|
|
|
static constexpr bool TODO = false;
|
2024-06-17 23:12:53 +01:00
|
|
|
#define TODO() VERIFY(TODO) /* NOLINT(cert-dcl03-c,misc-static-assert) No, this can't be static_assert, it's a runtime check */
|
|
|
|
|
#define TODO_AARCH64() VERIFY(TODO) /* NOLINT(cert-dcl03-c,misc-static-assert) No, this can't be static_assert, it's a runtime check */
|
|
|
|
|
#define TODO_RISCV64() VERIFY(TODO) /* NOLINT(cert-dcl03-c,misc-static-assert) No, this can't be static_assert, it's a runtime check */
|
2024-07-04 20:24:56 +02:00
|
|
|
#define TODO_PPC64() VERIFY(TODO) /* NOLINT(cert-dcl03-c,misc-static-assert) No, this can't be static_assert, it's a runtime check */
|
|
|
|
|
#define TODO_PPC() VERIFY(TODO) /* NOLINT(cert-dcl03-c,misc-static-assert) No, this can't be static_assert, it's a runtime check */
|
2024-07-09 14:21:34 +02:00
|
|
|
|
|
|
|
|
extern "C" __attribute__((noreturn)) void ak_assertion_failed(char const*);
|
2024-07-14 18:29:33 +02:00
|
|
|
#ifndef NDEBUG
|
2024-11-17 15:20:23 +01:00
|
|
|
# define ASSERT(...) \
|
|
|
|
|
(__builtin_expect(/* NOLINT(readability-simplify-boolean-expr) */ !(__VA_ARGS__), 0) \
|
|
|
|
|
? ak_assertion_failed(#__VA_ARGS__ " at " __FILE__ ":" __stringify(__LINE__)) \
|
2024-07-09 14:21:34 +02:00
|
|
|
: (void)0)
|
2024-11-15 16:48:56 +01:00
|
|
|
# define ASSERT_NOT_REACHED() ASSERT(false) /* NOLINT(cert-dcl03-c,misc-static-assert) No, this can't be static_assert, it's a runtime check */
|
2024-07-09 14:21:34 +02:00
|
|
|
#else
|
2024-11-17 15:20:23 +01:00
|
|
|
# define ASSERT(...)
|
2024-07-09 14:21:34 +02:00
|
|
|
# define ASSERT_NOT_REACHED() __builtin_unreachable()
|
|
|
|
|
#endif
|