diff options
Diffstat (limited to 'kernel/lib/libcxx/include/source_location')
| -rw-r--r-- | kernel/lib/libcxx/include/source_location | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/kernel/lib/libcxx/include/source_location b/kernel/lib/libcxx/include/source_location new file mode 100644 index 0000000..0d5052c --- /dev/null +++ b/kernel/lib/libcxx/include/source_location @@ -0,0 +1,49 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the BastionOS freestanding C++ standard library. +// +// std::source_location (C++20) — wraps compiler builtins. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBBASTION_SOURCE_LOCATION +#define _LIBBASTION_SOURCE_LOCATION + +#include <__config> +#include <cstdint> + +_LIBBASTION_BEGIN_NAMESPACE_STD + +class source_location { +public: + static consteval source_location current( + const char* __file = __builtin_FILE(), + const char* __func = __builtin_FUNCTION(), + unsigned __line = __builtin_LINE(), + unsigned __col = __builtin_COLUMN()) noexcept { + source_location __loc; + __loc.__file_ = __file; + __loc.__func_ = __func; + __loc.__line_ = __line; + __loc.__col_ = __col; + return __loc; + } + + constexpr source_location() noexcept = default; + + _LIBBASTION_NODISCARD constexpr const char* file_name() const noexcept { return __file_; } + _LIBBASTION_NODISCARD constexpr const char* function_name() const noexcept { return __func_; } + _LIBBASTION_NODISCARD constexpr uint_least32_t line() const noexcept { return __line_; } + _LIBBASTION_NODISCARD constexpr uint_least32_t column() const noexcept { return __col_; } + +private: + const char* __file_ = ""; + const char* __func_ = ""; + uint_least32_t __line_ = 0; + uint_least32_t __col_ = 0; +}; + +_LIBBASTION_END_NAMESPACE_STD + +#endif // _LIBBASTION_SOURCE_LOCATION |
