From dc788042ef90a8f306c1ed7270692cf9d5baf72e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 18 May 2018 15:59:56 -0400 Subject: [PATCH] MMU: Use Common::BitCast where applicable Gets rid of more memcpy boilerplate for properly reinterpreting bits. --- Source/Core/Core/PowerPC/MMU.cpp | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/Source/Core/Core/PowerPC/MMU.cpp b/Source/Core/Core/PowerPC/MMU.cpp index cd8ca73396..1a816e5508 100644 --- a/Source/Core/Core/PowerPC/MMU.cpp +++ b/Source/Core/Core/PowerPC/MMU.cpp @@ -489,20 +489,14 @@ double Read_F64(const u32 address) { const u64 integral = Read_U64(address); - double real; - std::memcpy(&real, &integral, sizeof(double)); - - return real; + return Common::BitCast(integral); } float Read_F32(const u32 address) { const u32 integral = Read_U32(address); - float real; - std::memcpy(&real, &integral, sizeof(float)); - - return real; + return Common::BitCast(integral); } u32 Read_U8_ZX(const u32 address) @@ -556,8 +550,7 @@ void Write_U64_Swap(const u64 var, const u32 address) void Write_F64(const double var, const u32 address) { - u64 integral; - std::memcpy(&integral, &var, sizeof(u64)); + const u64 integral = Common::BitCast(var); Write_U64(integral, address); } @@ -586,20 +579,14 @@ float HostRead_F32(const u32 address) { const u32 integral = HostRead_U32(address); - float real; - std::memcpy(&real, &integral, sizeof(float)); - - return real; + return Common::BitCast(integral); } double HostRead_F64(const u32 address) { const u64 integral = HostRead_U64(address); - double real; - std::memcpy(&real, &integral, sizeof(double)); - - return real; + return Common::BitCast(integral); } void HostWrite_U8(const u8 var, const u32 address) @@ -624,16 +611,14 @@ void HostWrite_U64(const u64 var, const u32 address) void HostWrite_F32(const float var, const u32 address) { - u32 integral; - std::memcpy(&integral, &var, sizeof(u32)); + const u32 integral = Common::BitCast(var); HostWrite_U32(integral, address); } void HostWrite_F64(const double var, const u32 address) { - u64 integral; - std::memcpy(&integral, &var, sizeof(u64)); + const u64 integral = Common::BitCast(var); HostWrite_U64(integral, address); }