From f33eb0d32ffd854eb1bc6181190307f7a37a93a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Tue, 26 Jul 2022 17:31:25 +0200 Subject: [PATCH] Revert "Replaced unique_ptrs with simple pointers, as Genode's stdcxx does not provide the former." This reverts commit cb25f9d5bb5f979f919b3b8c7f6851f7f387593f. --- src/mx/tasking/runtime.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/mx/tasking/runtime.h b/src/mx/tasking/runtime.h index 03ba742..b7ab389 100644 --- a/src/mx/tasking/runtime.h +++ b/src/mx/tasking/runtime.h @@ -2,7 +2,7 @@ #include "scheduler.h" #include "task.h" #include /* TODO: Find Genode replacement, IO streams crash on Genode */ -#include /* DOne: Deos this work with Genode? */ +#include /* TODO: Deos this work with Genode? */ #include #include #include @@ -39,8 +39,8 @@ public: // Create a new resource allocator. if (_resource_allocator == nullptr) { - _resource_allocator = new (memory::GlobalHeap::allocate_cache_line_aligned( - sizeof(memory::dynamic::Allocator))) memory::dynamic::Allocator(); + _resource_allocator.reset(new (memory::GlobalHeap::allocate_cache_line_aligned( + sizeof(memory::dynamic::Allocator))) memory::dynamic::Allocator()); } else if (_resource_allocator->is_free()) { @@ -55,32 +55,32 @@ public: // Create a new task allocator. if (use_system_allocator) { - _task_allocator = new (memory::GlobalHeap::allocate_cache_line_aligned(sizeof( - memory::SystemTaskAllocator))) memory::SystemTaskAllocator(); + _task_allocator.reset(new (memory::GlobalHeap::allocate_cache_line_aligned(sizeof( + memory::SystemTaskAllocator))) memory::SystemTaskAllocator()); } else { - _task_allocator = new ( + _task_allocator.reset(new ( memory::GlobalHeap::allocate_cache_line_aligned(sizeof(memory::fixed::Allocator))) - memory::fixed::Allocator(core_set); + memory::fixed::Allocator(core_set)); } // Create a new scheduler. const auto need_new_scheduler = _scheduler == nullptr || *_scheduler != core_set; if (need_new_scheduler) { - _scheduler = new (memory::GlobalHeap::allocate_cache_line_aligned(sizeof(Scheduler))) - Scheduler(core_set, prefetch_distance, *_resource_allocator); + _scheduler.reset(new (memory::GlobalHeap::allocate_cache_line_aligned(sizeof(Scheduler))) + Scheduler(core_set, prefetch_distance, *_resource_allocator)); } else { - _scheduler = nullptr; + _scheduler->reset(); } // Create a new resource builder. if (_resource_builder == nullptr || need_new_scheduler) { - _resource_builder = new(memory::GlobalHeap::heap()) resource::Builder(*_scheduler, *_resource_allocator); + _resource_builder = std::make_unique(*_scheduler, *_resource_allocator); } return true; @@ -234,16 +234,16 @@ public: private: // Scheduler to spawn tasks. - inline static Scheduler *_scheduler = nullptr; + inline static std::unique_ptr _scheduler = {nullptr}; // Allocator to allocate tasks (could be systems malloc or our Multi-level allocator). - inline static memory::TaskAllocatorInterface *_task_allocator = nullptr; + inline static std::unique_ptr _task_allocator = {nullptr}; // Allocator to allocate resources. - inline static memory::dynamic::Allocator *_resource_allocator = nullptr; + inline static std::unique_ptr _resource_allocator = {nullptr}; // Allocator to allocate data objects. - inline static resource::Builder *_resource_builder = nullptr; + inline static std::unique_ptr _resource_builder = {nullptr}; }; /**