diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h index ba3081efb4..6e15e85f57 100644 --- a/src/common/common_funcs.h +++ b/src/common/common_funcs.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -129,19 +132,4 @@ namespace Common { u64(g) << 48 | u64(h) << 56; } -// std::size() does not support zero-size C arrays. We're fixing that. -template -constexpr auto Size(const C& c) -> decltype(c.size()) { - return std::size(c); -} - -template -constexpr std::size_t Size(const C& c) { - if constexpr (sizeof(C) == 0) { - return 0; - } else { - return std::size(c); - } -} - } // namespace Common diff --git a/src/common/concepts.h b/src/common/concepts.h index 61df1d32a2..4c07443bac 100644 --- a/src/common/concepts.h +++ b/src/common/concepts.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -12,24 +15,4 @@ namespace Common { template concept IsContiguousContainer = std::contiguous_iterator; -// TODO: Replace with std::derived_from when the header -// is available on all supported platforms. -template -concept DerivedFrom = requires { - std::is_base_of_v; - std::is_convertible_v; - }; - -// TODO: Replace with std::convertible_to when libc++ implements it. -template -concept ConvertibleTo = std::is_convertible_v; - -// No equivalents in the stdlib - -template -concept IsArithmetic = std::is_arithmetic_v; - -template -concept IsIntegral = std::is_integral_v; - } // namespace Common diff --git a/src/common/fixed_point.h b/src/common/fixed_point.h index b0f3ae2ccb..c52c870812 100644 --- a/src/common/fixed_point.h +++ b/src/common/fixed_point.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: 2015 Evan Teran // SPDX-License-Identifier: MIT @@ -16,6 +19,10 @@ namespace Common { +// No equivalent for "std::arithmetic" in the stdlib +template +concept IsArithmetic = std::is_arithmetic_v; + template class FixedPoint; @@ -392,13 +399,13 @@ public: // binary math operators, effects underlying bit pattern since these return *this; } - template + template constexpr FixedPoint& operator>>=(Integer n) { data_ >>= n; return *this; } - template + template constexpr FixedPoint& operator<<=(Integer n) { data_ <<= n; return *this; @@ -587,12 +594,12 @@ constexpr FixedPoint operator/(Number lhs, FixedPoint rhs) { } // shift operators -template +template constexpr FixedPoint operator<<(FixedPoint lhs, Integer rhs) { lhs <<= rhs; return lhs; } -template +template constexpr FixedPoint operator>>(FixedPoint lhs, Integer rhs) { lhs >>= rhs; return lhs; diff --git a/src/core/file_sys/fs_path_utility.h b/src/core/file_sys/fs_path_utility.h index d0060c4fc6..f59ce37cb2 100644 --- a/src/core/file_sys/fs_path_utility.h +++ b/src/core/file_sys/fs_path_utility.h @@ -60,15 +60,15 @@ constexpr bool IsInvalidCharacterImpl(char c) { } // namespace impl constexpr bool IsInvalidCharacter(char c) { - return impl::IsInvalidCharacterImpl(c); + return impl::IsInvalidCharacterImpl(c); } constexpr bool IsInvalidCharacterForHostName(char c) { return impl::IsInvalidCharacterImpl(c); + std::size(InvalidCharactersForHostName)>(c); } constexpr bool IsInvalidCharacterForMountName(char c) { return impl::IsInvalidCharacterImpl(c); + std::size(InvalidCharactersForMountName)>(c); } } // namespace StringTraits diff --git a/src/core/hle/kernel/k_priority_queue.h b/src/core/hle/kernel/k_priority_queue.h index 26677ec65c..68a311789f 100644 --- a/src/core/hle/kernel/k_priority_queue.h +++ b/src/core/hle/kernel/k_priority_queue.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -10,7 +13,6 @@ #include "common/assert.h" #include "common/bit_set.h" #include "common/common_types.h" -#include "common/concepts.h" namespace Kernel { @@ -19,7 +21,7 @@ class KThread; template concept KPriorityQueueAffinityMask = ! std::is_reference_v&& requires(T& t) { - { t.GetAffinityMask() } -> Common::ConvertibleTo; + { t.GetAffinityMask() } -> std::convertible_to; { t.SetAffinityMask(0) }; { t.GetAffinity(0) } -> std::same_as; @@ -45,9 +47,9 @@ std::is_reference_v&& requires(T& t) { std::remove_cvref_t() } -> KPriorityQueueAffinityMask; - { t.GetActiveCore() } -> Common::ConvertibleTo; - { t.GetPriority() } -> Common::ConvertibleTo; - { t.IsDummyThread() } -> Common::ConvertibleTo; + { t.GetActiveCore() } -> std::convertible_to; + { t.GetPriority() } -> std::convertible_to; + { t.IsDummyThread() } -> std::convertible_to; }; template diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h index 32c218638d..d5f372b97d 100644 --- a/src/core/hle/service/sm/sm.h +++ b/src/core/hle/service/sm/sm.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -8,8 +11,8 @@ #include #include #include +#include -#include "common/concepts.h" #include "core/hle/kernel/k_port.h" #include "core/hle/kernel/svc.h" #include "core/hle/result.h" @@ -63,7 +66,7 @@ public: Result UnregisterService(const std::string& name); Result GetServicePort(Kernel::KClientPort** out_client_port, const std::string& name); - template T> + template T> std::shared_ptr GetService(const std::string& service_name, bool block = false) const { auto service = registered_services.find(service_name); if (service == registered_services.end() && !block) { diff --git a/src/video_core/gpu_thread.cpp b/src/video_core/gpu_thread.cpp index 9392534e7d..b0cafbf270 100644 --- a/src/video_core/gpu_thread.cpp +++ b/src/video_core/gpu_thread.cpp @@ -23,9 +23,7 @@ namespace VideoCommon::GPUThread { static void RunThread(std::stop_token stop_token, Core::System& system, VideoCore::RendererBase& renderer, Core::Frontend::GraphicsContext& context, Tegra::Control::Scheduler& scheduler, SynchState& state) { - std::string name = "GPU"; - - Common::SetCurrentThreadName(name.c_str()); + Common::SetCurrentThreadName("GPU"); Common::SetCurrentThreadPriority(Common::ThreadPriority::Critical); system.RegisterHostThread();