From 1a7ea2d235e71b7c421c277e7a42e8c04ba204ab Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Sun, 7 Aug 2016 16:59:46 +0300 Subject: [PATCH] fmt_unveil<> fix --- Utilities/BEType.h | 3 +-- Utilities/BitField.h | 6 +++--- Utilities/BitSet.h | 2 +- Utilities/Config.h | 10 ++-------- Utilities/StrFmt.h | 19 +++++++++++++++++++ Utilities/Thread.cpp | 2 +- Utilities/types.h | 2 +- rpcs3/Emu/Memory/vm_ptr.h | 2 +- 8 files changed, 29 insertions(+), 17 deletions(-) diff --git a/Utilities/BEType.h b/Utilities/BEType.h index 56b8ba30ad..1ffe22acd8 100644 --- a/Utilities/BEType.h +++ b/Utilities/BEType.h @@ -944,13 +944,12 @@ template using atomic_be_t = atomic_t>; template using atomic_le_t = atomic_t>; #endif -// Formatting for BE/LE data template struct fmt_unveil, void> { using type = typename fmt_unveil::type; - static inline u64 get(const se_t& arg) + static inline auto get(const se_t& arg) { return fmt_unveil::get(arg); } diff --git a/Utilities/BitField.h b/Utilities/BitField.h index 9a0d096cb1..b592e347c0 100644 --- a/Utilities/BitField.h +++ b/Utilities/BitField.h @@ -248,7 +248,7 @@ struct fmt_unveil, void> { using type = typename fmt_unveil>::type; - static inline u64 get(const bf_t& bf) + static inline auto get(const bf_t& bf) { return fmt_unveil::get(bf); } @@ -259,7 +259,7 @@ struct fmt_unveil, void> { using type = typename fmt_unveil>::type; - static inline u64 get(const cf_t& cf) + static inline auto get(const cf_t& cf) { return fmt_unveil::get(cf); } @@ -270,7 +270,7 @@ struct fmt_unveil, void> { using type = typename fmt_unveil>::type; - static inline u64 get(const ff_t& ff) + static inline auto get(const ff_t& ff) { return fmt_unveil::get(ff); } diff --git a/Utilities/BitSet.h b/Utilities/BitSet.h index 0e207f0b40..e2531b4225 100644 --- a/Utilities/BitSet.h +++ b/Utilities/BitSet.h @@ -262,7 +262,7 @@ struct fmt_unveil, void> { using type = typename bitset_t::raw_type; - static inline u64 get(const bitset_t& value) + static inline auto get(const bitset_t& value) { return fmt_unveil::get(static_cast(value._value())); } diff --git a/Utilities/Config.h b/Utilities/Config.h index ec3cb118fc..3a69e3c75a 100644 --- a/Utilities/Config.h +++ b/Utilities/Config.h @@ -314,14 +314,8 @@ namespace cfg if (try_to_enum_value(&result, &fmt_class_string::format, value)) { - const auto val = static_cast>(result); - - if (static_cast(val) != result) - { - return false; - } - - m_value = static_cast(val); + // No narrowing check, it's hard to do right there + m_value = static_cast(static_cast>(result)); return true; } diff --git a/Utilities/StrFmt.h b/Utilities/StrFmt.h index 710b9494f6..ab430838dd 100644 --- a/Utilities/StrFmt.h +++ b/Utilities/StrFmt.h @@ -2,6 +2,7 @@ #include #include +#include #include "Platform.h" #include "types.h" @@ -23,6 +24,24 @@ struct fmt_unveil { return reinterpret_cast(&arg); } + + // Temporary value container (can possibly be created by other fmt_unveil<> specializations) + struct u64_wrapper + { + T arg; + + // Allow implicit conversion + operator u64() const + { + return reinterpret_cast(&arg); + } + }; + + // This overload resolution takes the precedence + static inline u64_wrapper get(T&& arg) + { + return {std::move(arg)}; + } }; template diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index 4e5824949e..71f8946bc8 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -1026,7 +1026,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) { if (op == X64OP_NONE) { - LOG_ERROR(MEMORY, "decode_x64_reg_op(%016llxh): unsupported opcode found (%016llX%016llX)", code, *(be_t*)(code), *(be_t*)(code + 8)); + LOG_ERROR(MEMORY, "decode_x64_reg_op(%ph): unsupported opcode: %s", code, *(be_t*)(code)); } }; diff --git a/Utilities/types.h b/Utilities/types.h index 1d9c05ba38..f5d24f4fd0 100644 --- a/Utilities/types.h +++ b/Utilities/types.h @@ -529,7 +529,7 @@ struct fmt_unveil> { using type = typename fmt_unveil::type; - static inline u64 get(const id_value& value) + static inline auto get(const id_value& value) { return fmt_unveil::get(value); } diff --git a/rpcs3/Emu/Memory/vm_ptr.h b/rpcs3/Emu/Memory/vm_ptr.h index a64feb981a..24242fbac8 100644 --- a/rpcs3/Emu/Memory/vm_ptr.h +++ b/rpcs3/Emu/Memory/vm_ptr.h @@ -496,7 +496,7 @@ struct fmt_unveil, void> { using type = typename fmt_unveil::type; - static inline u64 get(const vm::_ptr_base& arg) + static inline auto get(const vm::_ptr_base& arg) { return fmt_unveil::get(arg.addr()); }