From e22c2dcad410504c65d8ccba0ab66d96cf0c61a1 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 19 Dec 2025 11:55:48 +0100 Subject: kstd: clean up OS interface split --- libs/kstd/include/kstd/bits/os.hpp | 34 ------------------------------ libs/kstd/include/kstd/bits/print_sink.hpp | 19 +++++++++++++++++ libs/kstd/include/kstd/os/error.hpp | 34 ++++++++++++++++++++++++++++++ libs/kstd/include/kstd/os/print.hpp | 14 ++++++++++++ libs/kstd/include/kstd/print | 15 +++---------- 5 files changed, 70 insertions(+), 46 deletions(-) delete mode 100644 libs/kstd/include/kstd/bits/os.hpp create mode 100644 libs/kstd/include/kstd/bits/print_sink.hpp create mode 100644 libs/kstd/include/kstd/os/error.hpp create mode 100644 libs/kstd/include/kstd/os/print.hpp (limited to 'libs/kstd/include') diff --git a/libs/kstd/include/kstd/bits/os.hpp b/libs/kstd/include/kstd/bits/os.hpp deleted file mode 100644 index 0474f16..0000000 --- a/libs/kstd/include/kstd/bits/os.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef KSTD_OS_HPP -#define KSTD_OS_HPP - -#include -#include - -namespace kstd::os -{ - /** - * @brief Handle an unrecoverable library error. - * - * The operating system kernel may choose to implement this function in order to try to perform additional cleanup - * before terminating execution. If the kernel does not implement this function, the default implementation will be - * chosen. This default implementation doest nothing. - */ - [[noreturn]] - auto abort() -> void; - - /** - * @brief Terminate execution of the operating system. - * - * The operating system must implement this function. This function must terminate the execution of the operating - * system kernel as is. It may choose to restart the kernel or to halt execution entirely. The implementation must - * guarantee that execution never return from this function. - * - * @param message A message describing the reason for termination of execution. - * @param where The source code location at which the panic was triggered. In general, no argument shall be provided - * for this parameter, thus implicitly capturing the location at which the call originates. - */ - [[noreturn]] - auto panic(std::string_view message, std::source_location where = std::source_location::current()) -> void; -} // namespace kstd::os - -#endif \ No newline at end of file diff --git a/libs/kstd/include/kstd/bits/print_sink.hpp b/libs/kstd/include/kstd/bits/print_sink.hpp new file mode 100644 index 0000000..0e0955c --- /dev/null +++ b/libs/kstd/include/kstd/bits/print_sink.hpp @@ -0,0 +1,19 @@ +#ifndef KSTD_BITS_PRINT_SINK_HPP +#define KSTD_BITS_PRINT_SINK_HPP + +// IWYU pragma: private, include + +#include + +namespace kstd +{ + + enum struct print_sink + { + stdout, + stderr, + }; + +} // namespace kstd + +#endif \ No newline at end of file diff --git a/libs/kstd/include/kstd/os/error.hpp b/libs/kstd/include/kstd/os/error.hpp new file mode 100644 index 0000000..9d43fb1 --- /dev/null +++ b/libs/kstd/include/kstd/os/error.hpp @@ -0,0 +1,34 @@ +#ifndef KSTD_OS_ERROR_HPP +#define KSTD_OS_ERROR_HPP + +#include +#include + +namespace kstd::os +{ + /** + * @brief Handle an unrecoverable library error. + * + * The operating system kernel may choose to implement this function in order to try to perform additional cleanup + * before terminating execution. If the kernel does not implement this function, the default implementation will be + * chosen. This default implementation doest nothing. + */ + [[noreturn]] + auto abort() -> void; + + /** + * @brief Terminate execution of the operating system. + * + * The operating system must implement this function. This function must terminate the execution of the operating + * system kernel as is. It may choose to restart the kernel or to halt execution entirely. The implementation must + * guarantee that execution never return from this function. + * + * @param message A message describing the reason for termination of execution. + * @param where The source code location at which the panic was triggered. In general, no argument shall be provided + * for this parameter, thus implicitly capturing the location at which the call originates. + */ + [[noreturn]] + auto panic(std::string_view message, std::source_location where = std::source_location::current()) -> void; +} // namespace kstd::os + +#endif \ No newline at end of file diff --git a/libs/kstd/include/kstd/os/print.hpp b/libs/kstd/include/kstd/os/print.hpp new file mode 100644 index 0000000..f189042 --- /dev/null +++ b/libs/kstd/include/kstd/os/print.hpp @@ -0,0 +1,14 @@ +#ifndef KSTD_OS_PRINT_HPP +#define KSTD_OS_PRINT_HPP + +#include "kstd/bits/formatter.hpp" +#include "kstd/bits/print_sink.hpp" + +#include + +namespace kstd::os +{ + auto vprint(print_sink sink, std::string_view format, kstd::format_args args) -> void; +} // namespace kstd::os + +#endif \ No newline at end of file diff --git a/libs/kstd/include/kstd/print b/libs/kstd/include/kstd/print index df42997..ffafda9 100644 --- a/libs/kstd/include/kstd/print +++ b/libs/kstd/include/kstd/print @@ -1,26 +1,17 @@ #ifndef KSTD_PRINT #define KSTD_PRINT +#include "bits/print_sink.hpp" // IWYU pragma: export +#include "os/print.hpp" + #include #include -#include #include namespace kstd { - enum struct print_sink - { - stdout, - stderr, - }; - - namespace os - { - auto vprint(print_sink sink, std::string_view format, kstd::format_args args) -> void; - } // namespace os - //! @qualifier kernel-defined //! Format the given string using the given arguments and print it to the currently active output device. //! -- cgit v1.2.3