From e0aa552faed440db24c584471b502ef835cfcdff Mon Sep 17 00:00:00 2001 From: apio Date: Fri, 14 Oct 2022 19:04:56 +0200 Subject: [PATCH] Kernel: Add a move() function The standard C++ move() function. --- kernel/include/utils/move.h | 6 ++++++ kernel/src/memory/AddressSpace.cpp | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 kernel/include/utils/move.h diff --git a/kernel/include/utils/move.h b/kernel/include/utils/move.h new file mode 100644 index 00000000..9006d68a --- /dev/null +++ b/kernel/include/utils/move.h @@ -0,0 +1,6 @@ +#pragma once + +template inline T&& move(T& lvalue) +{ + return (T &&) lvalue; +} \ No newline at end of file diff --git a/kernel/src/memory/AddressSpace.cpp b/kernel/src/memory/AddressSpace.cpp index c27b3c38..5b45f02a 100644 --- a/kernel/src/memory/AddressSpace.cpp +++ b/kernel/src/memory/AddressSpace.cpp @@ -4,6 +4,7 @@ #include "log/Log.h" #include "memory/PMM.h" #include "memory/VMM.h" +#include "utils/move.h" AddressSpace AddressSpace::create() { @@ -11,7 +12,7 @@ AddressSpace AddressSpace::create() result.m_pml4 = (PageTable*)PMM::request_page(); result.m_cloned = false; VMM::install_kernel_page_directory_into_address_space(result); - return result; + return move(result); } void AddressSpace::destroy()