From 529b84cd1e2a334d6b1b7f40d5488dae0a2e9119 Mon Sep 17 00:00:00 2001 From: apio Date: Sat, 25 Feb 2023 17:09:03 +0100 Subject: [PATCH] kernel, luna: Port non-VFS changes over from pull request #22 OwnedPtr, SharedPtr: Add operator bool Option, Result: Make try_move_value() non-const since it modifies the Option kernel: Switch to a stack we control for the main task as soon as we leave early boot Heap: Fix GPF caused when making many small allocations Heap: Avoid accessing a block after it's potentially deleted luna: Skip UBSAN.cpp in CMakeLists as that's not implemented yet luna: Use spinlocks in the heap implementation kernel, luna: Move Spinlock.h to luna Option: Use __builtin_launder to ensure that the compiler doesn't label this as UB SharedPtr: Implement make_shared using adopt_shared SharedPtr: Delete ptr on failure in all adopt_shared* functions --- luna/include/luna/SharedPtr.h | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/luna/include/luna/SharedPtr.h b/luna/include/luna/SharedPtr.h index 8197f4ab..020c37a5 100644 --- a/luna/include/luna/SharedPtr.h +++ b/luna/include/luna/SharedPtr.h @@ -123,20 +123,6 @@ template Result> adopt_shared(T* ptr) return SharedPtr { ptr, ref_count }; } -// NOTE: ptr is deleted if any of the adopt_shared* functions fail to construct a SharedPtr. -template Result> adopt_shared(T* ptr) -{ - using RefCount = __detail::RefCount; - - auto guard = make_scope_guard([ptr] { delete ptr; }); - - RefCount* const ref_count = TRY(make()); - - guard.deactivate(); - - return SharedPtr { ptr, ref_count }; -} - template Result> make_shared(Args... args) { T* raw_ptr = TRY(make(args...));