summaryrefslogtreecommitdiff
path: root/kernel/lib/libcxx/include/algorithm
diff options
context:
space:
mode:
authorArseney300 <Arseney300@gmail.com>2026-04-12 02:01:25 +0700
committerArseney300 <Arseney300@gmail.com>2026-04-12 02:01:25 +0700
commit2496ffd6d97c3ccd3e325687442d31ab035479a1 (patch)
tree5d176669f823182fe74261f076dc11c8e8f88025 /kernel/lib/libcxx/include/algorithm
parent496246c92dabe6757480147016490ea6ae43bb66 (diff)
bastion: add freestanding C++ standard library (libcxx)feature/freestanding-libcxx
Header-only implementation of a C++ standard library subset for the freestanding kernel, using Clang builtins wherever possible. Provides 19 public headers (~35 internal files): type_traits, utility, memory, algorithm, functional, concepts, array, string_view, span, optional, expected, variant, tuple, bit, limits, new, initializer_list, cstdint, cstddef, and source_location. Integration changes: - kernel/Makefile: add -Ilib/libcxx/include to include path - kernel/lib/string.cpp: add memchr and strncmp (needed by string_view) - kernel/lib/cxxabi.cpp: guard placement new against <new> header conflict - kernel/include/kernel/kernel.h: Panic() now uses std::source_location - kernel/core/kernel.cpp: Panic() implementation updated to match Builds cleanly on both x86_64 and aarch64 with zero new warnings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'kernel/lib/libcxx/include/algorithm')
-rw-r--r--kernel/lib/libcxx/include/algorithm42
1 files changed, 42 insertions, 0 deletions
diff --git a/kernel/lib/libcxx/include/algorithm b/kernel/lib/libcxx/include/algorithm
new file mode 100644
index 0000000..56b71a7
--- /dev/null
+++ b/kernel/lib/libcxx/include/algorithm
@@ -0,0 +1,42 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the BastionOS freestanding C++ standard library.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBBASTION_ALGORITHM
+#define _LIBBASTION_ALGORITHM
+
+#include <__config>
+#include <__algorithm/minmax.h>
+#include <__algorithm/find.h>
+#include <__algorithm/copy.h>
+#include <__algorithm/fill.h>
+#include <__algorithm/comparison.h>
+#include <__algorithm/sort.h>
+#include <__algorithm/bound.h>
+#include <__algorithm/for_each.h>
+
+// Also pull in swap (algorithms often need it).
+#include <__utility/swap.h>
+
+_LIBBASTION_BEGIN_NAMESPACE_STD
+
+// swap_ranges
+template<class _ForwardIt1, class _ForwardIt2>
+constexpr _ForwardIt2 swap_ranges(_ForwardIt1 __first1, _ForwardIt1 __last1, _ForwardIt2 __first2) {
+ for (; __first1 != __last1; ++__first1, ++__first2)
+ swap(*__first1, *__first2);
+ return __first2;
+}
+
+// iter_swap
+template<class _ForwardIt1, class _ForwardIt2>
+constexpr void iter_swap(_ForwardIt1 __a, _ForwardIt2 __b) {
+ swap(*__a, *__b);
+}
+
+_LIBBASTION_END_NAMESPACE_STD
+
+#endif // _LIBBASTION_ALGORITHM