aboutsummaryrefslogtreecommitdiff
path: root/include/apos/assert.h
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2023-04-30 17:06:02 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2023-04-30 17:06:02 +0300
commitea5ebe0809fb31b9f125ac0689f706cc5f3f078f (patch)
tree17081bd689709a9bfe48467c458425dea876bddd /include/apos/assert.h
parent8a5e4cf53d981e793fca90d9b51bd395265cf4db (diff)
downloadkmi-ea5ebe0809fb31b9f125ac0689f706cc5f3f078f.tar.gz
kmi-ea5ebe0809fb31b9f125ac0689f706cc5f3f078f.zip
rename to kmi
Diffstat (limited to 'include/apos/assert.h')
-rw-r--r--include/apos/assert.h85
1 files changed, 0 insertions, 85 deletions
diff --git a/include/apos/assert.h b/include/apos/assert.h
deleted file mode 100644
index 09b9f13..0000000
--- a/include/apos/assert.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
-/* Copyright 2021 - 2022, Kim Kuparinen < kimi.h.kuparinen@gmail.com > */
-
-#ifndef APOS_ASSERT_H
-#define APOS_ASSERT_H
-
-/**
- * @file assert.h
- * Assertions. Note that contrary to how assertios usually function, apos has
- * three different levels of assertions: Catastrophic, hard and soft.
- *
- * Soft assertions merely warn about something that might cause issues, but let
- * the execution continue normally.
- *
- * Hard assertions warn about the assertion not holding and returns from the
- * function.
- *
- * Catastrophic assertions warn about the assertion and crash the kernel.
- */
-
-#include <apos/debug.h>
-#include <apos/utils.h>
-
-/** \todo should this exit or do something explosive like that? */
-#if !defined(DNDEBUG)
-
-/**
- * The kernel is in an irrepairable state, just give up.
- *
- * @param x Condition to check for.
- */
-#define catastrophic_assert(x) \
- do { \
- if (unlikely(!(x))) { \
- error("catastrophic assertion failed: " QUOTE(x) "\n"); \
- while (1) { \
- } \
- } \
- } while (0);
-
-/**
- * The function cannot continue without this assertion, but doesn't necessarily
- * mean that the kernel is borked.
- *
- * @warning Implicit return.
- *
- * @param x Condition to check for.
- * @param r Return value on failed check.
- */
-#define hard_assert(x, r) \
- { \
- if (unlikely(!(x))) { \
- warn("hard assertion failed: " QUOTE(x) "\n"); \
- return r; \
- } \
- }
-
-/**
- * Unexpected case, but not likely to cause problems, likely a bug.
- *
- * @param x Condition to check for.
- */
-#define soft_assert(x) \
- do { \
- if (unlikely(!(x))) { \
- info("soft assertion failed: " QUOTE(x) "\n"); \
- } \
- } while (0);
-#else
-#define catastrophic_assert(x)
-#define hard_assert(x, r)
-#define soft_assert(x)
-#endif
-
-/**
- * Use when return value doesn't exist.
- *
- * Example:
- * @code{.c}
- * void func() { hard_assert(x, RETURN_VOID); }
- * @endcode
- */
-#define RETURN_VOID
-
-#endif /* APOS_ASSERT_H */