aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/include
diff options
context:
space:
mode:
authorFabian Imhof <fabian.imhof@ost.ch>2024-10-20 12:18:06 +0000
committerFabian Imhof <fabian.imhof@ost.ch>2024-10-20 12:18:06 +0000
commita706f9732ed9a91854f6245980cdbbca0d220835 (patch)
tree25cf94120a62033cb907e2d16500acecec38b6bd /arch/x86_64/include
parentaa0634589cb7d51f57e3e555bb15ebca99bc162e (diff)
parent2129bdb22bab7dc5a9d23a31c23f38e847511a46 (diff)
downloadteachos-a706f9732ed9a91854f6245980cdbbca0d220835.tar.xz
teachos-a706f9732ed9a91854f6245980cdbbca0d220835.zip
Merge branch 'feat_memory_manager' of ssh://gitlab.ost.ch:45022/teachos/kernel into feat_memory_manager
Diffstat (limited to 'arch/x86_64/include')
-rw-r--r--arch/x86_64/include/arch/exception_handling/assert.hpp44
1 files changed, 3 insertions, 41 deletions
diff --git a/arch/x86_64/include/arch/exception_handling/assert.hpp b/arch/x86_64/include/arch/exception_handling/assert.hpp
index 152e653..bfc205c 100644
--- a/arch/x86_64/include/arch/exception_handling/assert.hpp
+++ b/arch/x86_64/include/arch/exception_handling/assert.hpp
@@ -3,54 +3,16 @@
#include "arch/exception_handling/panic.hpp"
-#include <stdio.h>
-
namespace teachos::arch::exception_handling
{
- namespace
- {
- char constexpr FAILED_MESSAGE[] = "Invalid arguments passed to format specifiers (%) in exception_handling::assert";
- }
-
/**
* @brief Assert a condition to be true, if not do not continue
* execution of the code and print the formatted message to screen.
*
- * @param condition Condition we want to be true.
- * @param format Formatting message that the given arguments will be inserted into.
- * @param ...args Arguments that will be formatted and inserted into the resulting string, replacing their respective
- * specifiers. Uses the printf specifiers see https://cplusplus.com/reference/cstdio/printf/ for more information.
+ * @param condition Condition we want to be true or else halt execution.
+ * @param message Message that should be printed before halting the execution if the condition is not met.
*/
- template<typename... Args>
- auto assert(bool condition, char const * format, Args const &... args) -> void
- {
- if (condition)
- {
- return;
- }
- else if constexpr (sizeof...(args) == 0)
- {
- panic("Assertion Violation: ", format);
- }
-
- // Result is what would have been written if the passed buffer would have been large enough not counting null
- // character, or if an error occured while creating the string a negative number is returned instead. To ensure this
- // will not crash the system when creating an array with negative size we assert beforehand with a clear error
- // message.
- int const size = snprintf(nullptr, 0U, format, args...) + 1U;
- if (size < 0)
- {
- panic("Assertion Violation: ", FAILED_MESSAGE);
- }
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wvla"
- char arguments[size] = {};
-#pragma GCC diagnostic pop
- int const written_characters = snprintf(arguments, size, format, args...);
- // Written characters is expected to be one less, because of the null termination character.
- bool const result = (written_characters == (size - 1));
- panic("Assertion Violation: ", result ? arguments : FAILED_MESSAGE);
- }
+ auto assert(bool condition, char const * message) -> void;
} // namespace teachos::arch::exception_handling
#endif