summaryrefslogtreecommitdiff
path: root/kernel/lib/libcxx/include/__config
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/lib/libcxx/include/__config')
-rw-r--r--kernel/lib/libcxx/include/__config63
1 files changed, 63 insertions, 0 deletions
diff --git a/kernel/lib/libcxx/include/__config b/kernel/lib/libcxx/include/__config
new file mode 100644
index 0000000..f40c971
--- /dev/null
+++ b/kernel/lib/libcxx/include/__config
@@ -0,0 +1,63 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the BastionOS freestanding C++ standard library.
+// Modeled after libc++.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBBASTION_CONFIG
+#define _LIBBASTION_CONFIG
+
+// Require Clang >= 16 for the builtin set we depend on.
+#if !defined(__clang__) || __clang_major__ < 16
+#error "BastionOS libcxx requires Clang >= 16"
+#endif
+
+// C++ standard version detection.
+#if __cplusplus >= 202302L
+#define _LIBBASTION_STD_VER 23
+#elif __cplusplus >= 202002L
+#define _LIBBASTION_STD_VER 20
+#elif __cplusplus >= 201703L
+#define _LIBBASTION_STD_VER 17
+#else
+#error "BastionOS libcxx requires C++17 or later"
+#endif
+
+// Builtin detection.
+#define _LIBBASTION_HAS_BUILTIN(x) __has_builtin(x)
+
+// Namespace macros.
+#define _LIBBASTION_BEGIN_NAMESPACE_STD namespace std {
+#define _LIBBASTION_END_NAMESPACE_STD }
+
+// All functions are effectively noexcept (no exception support).
+#define _LIBBASTION_NOEXCEPT noexcept
+
+// Attributes.
+#define _LIBBASTION_NODISCARD [[nodiscard]]
+#define _LIBBASTION_NORETURN [[noreturn]]
+#define _LIBBASTION_MAYBE_UNUSED [[maybe_unused]]
+#define _LIBBASTION_DEPRECATED [[deprecated]]
+
+// Inline visibility — encourage inlining for small helpers.
+#define _LIBBASTION_INLINE_VISIBILITY __attribute__((__always_inline__))
+#define _LIBBASTION_HIDE_FROM_ABI __attribute__((__visibility__("hidden"))) __attribute__((__always_inline__))
+
+// Unreachable / trap.
+#define _LIBBASTION_UNREACHABLE() __builtin_unreachable()
+#define _LIBBASTION_TRAP() __builtin_trap()
+#define _LIBBASTION_ASSERT(cond, msg) \
+ do { if (!(cond)) __builtin_trap(); } while (0)
+
+// constexpr annotations for features added in specific standards.
+#define _LIBBASTION_CONSTEXPR constexpr
+#define _LIBBASTION_CONSTEXPR_SINCE_CXX20 constexpr
+#if _LIBBASTION_STD_VER >= 23
+#define _LIBBASTION_CONSTEXPR_SINCE_CXX23 constexpr
+#else
+#define _LIBBASTION_CONSTEXPR_SINCE_CXX23
+#endif
+
+#endif // _LIBBASTION_CONFIG