diff options
author | liamwhite <liamwhite@users.noreply.github.com> | 2024-02-04 15:48:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-04 15:48:33 +0100 |
commit | 4cccbe7989a6a2571ffb1a21790f3884786c557a (patch) | |
tree | e0cebe568f7bc8597a019b75ecc6d4b3b653e206 /src | |
parent | Merge pull request #12901 from Kelebek1/timezone_firmware_fix (diff) | |
parent | cmif_serialization: enforce const for references (diff) | |
download | yuzu-4cccbe7989a6a2571ffb1a21790f3884786c557a.tar yuzu-4cccbe7989a6a2571ffb1a21790f3884786c557a.tar.gz yuzu-4cccbe7989a6a2571ffb1a21790f3884786c557a.tar.bz2 yuzu-4cccbe7989a6a2571ffb1a21790f3884786c557a.tar.lz yuzu-4cccbe7989a6a2571ffb1a21790f3884786c557a.tar.xz yuzu-4cccbe7989a6a2571ffb1a21790f3884786c557a.tar.zst yuzu-4cccbe7989a6a2571ffb1a21790f3884786c557a.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/core/hle/service/cmif_serialization.h | 6 | ||||
-rw-r--r-- | src/core/hle/service/cmif_types.h | 27 |
2 files changed, 31 insertions, 2 deletions
diff --git a/src/core/hle/service/cmif_serialization.h b/src/core/hle/service/cmif_serialization.h index 315475e71..e985fe317 100644 --- a/src/core/hle/service/cmif_serialization.h +++ b/src/core/hle/service/cmif_serialization.h @@ -115,6 +115,11 @@ struct ArgumentTraits { static constexpr ArgumentType Type = ArgumentType::InData; }; +template <typename... Ts> +consteval bool ConstIfReference() { + return ((!std::is_reference_v<Ts> || std::is_const_v<std::remove_reference_t<Ts>>) && ... && true); +} + struct RequestLayout { u32 copy_handle_count; u32 move_handle_count; @@ -435,6 +440,7 @@ void CmifReplyWrapImpl(HLERequestContext& ctx, T& t, Result (T::*f)(A...)) { } const bool is_domain = Domain ? ctx.GetManager()->IsDomain() : false; + static_assert(ConstIfReference<A...>(), "Arguments taken by reference must be const"); using MethodArguments = std::tuple<std::remove_cvref_t<A>...>; OutTemporaryBuffers buffers{}; diff --git a/src/core/hle/service/cmif_types.h b/src/core/hle/service/cmif_types.h index dc06169f4..84f4c2456 100644 --- a/src/core/hle/service/cmif_types.h +++ b/src/core/hle/service/cmif_types.h @@ -4,10 +4,9 @@ #pragma once #include <memory> +#include <span> -#include "common/common_funcs.h" #include "common/common_types.h" -#include "core/hle/service/hle_ipc.h" namespace Service { @@ -22,8 +21,10 @@ class Out { public: using Type = T; + /* implicit */ Out(const Out& t) : raw(t.raw) {} /* implicit */ Out(AutoOut<Type>& t) : raw(&t.raw) {} /* implicit */ Out(Type* t) : raw(t) {} + Out& operator=(const Out&) = delete; Type* Get() const { return raw; @@ -37,6 +38,10 @@ public: return raw; } + operator Type*() const { + return raw; + } + private: Type* raw; }; @@ -113,8 +118,10 @@ class OutCopyHandle { public: using Type = T*; + /* implicit */ OutCopyHandle(const OutCopyHandle& t) : raw(t.raw) {} /* implicit */ OutCopyHandle(AutoOut<Type>& t) : raw(&t.raw) {} /* implicit */ OutCopyHandle(Type* t) : raw(t) {} + OutCopyHandle& operator=(const OutCopyHandle&) = delete; Type* Get() const { return raw; @@ -128,6 +135,10 @@ public: return raw; } + operator Type*() const { + return raw; + } + private: Type* raw; }; @@ -137,8 +148,10 @@ class OutMoveHandle { public: using Type = T*; + /* implicit */ OutMoveHandle(const OutMoveHandle& t) : raw(t.raw) {} /* implicit */ OutMoveHandle(AutoOut<Type>& t) : raw(&t.raw) {} /* implicit */ OutMoveHandle(Type* t) : raw(t) {} + OutMoveHandle& operator=(const OutMoveHandle&) = delete; Type* Get() const { return raw; @@ -152,6 +165,10 @@ public: return raw; } + operator Type*() const { + return raw; + } + private: Type* raw; }; @@ -248,8 +265,10 @@ public: static constexpr BufferAttr Attr = static_cast<BufferAttr>(A | BufferAttr_In | BufferAttr_FixedSize); using Type = T; + /* implicit */ OutLargeData(const OutLargeData& t) : raw(t.raw) {} /* implicit */ OutLargeData(Type* t) : raw(t) {} /* implicit */ OutLargeData(AutoOut<T>& t) : raw(&t.raw) {} + OutLargeData& operator=(const OutLargeData&) = delete; Type* Get() const { return raw; @@ -263,6 +282,10 @@ public: return raw; } + operator Type*() const { + return raw; + } + private: Type* raw; }; |