1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2025-01-31 12:31:45 +01:00

Fix le_t<> compilation error

Use memcpy for copying
This commit is contained in:
Nekotekina 2019-01-22 22:00:52 +03:00
parent 4f152ad126
commit d5eda98e49

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "types.h" #include "types.h"
#include <cstring>
// 128-bit vector type and also se_storage<> storage type // 128-bit vector type and also se_storage<> storage type
union alignas(16) v128 union alignas(16) v128
@ -361,16 +362,6 @@ struct se_storage
reverse(reinterpret_cast<u8*>(&result), reinterpret_cast<const u8*>(&src)); reverse(reinterpret_cast<u8*>(&result), reinterpret_cast<const u8*>(&src));
return result; return result;
} }
static type copy(const type& src)
{
type result;
for (std::size_t i = 0; i < Size; i++)
{
reinterpret_cast<u8*>(&result)[i] = reinterpret_cast<const u8*>(&src)[i];
}
return result;
}
}; };
template <typename T> template <typename T>
@ -397,11 +388,6 @@ struct se_storage<T, 2, 2>
const u16 result = swap(src); const u16 result = swap(src);
return reinterpret_cast<const T&>(result); return reinterpret_cast<const T&>(result);
} }
static inline T copy(const T& src)
{
return src;
}
}; };
template <typename T> template <typename T>
@ -428,11 +414,6 @@ struct se_storage<T, 4, 4>
const u32 result = swap(src); const u32 result = swap(src);
return reinterpret_cast<const T&>(result); return reinterpret_cast<const T&>(result);
} }
static inline T copy(const T& src)
{
return src;
}
}; };
template <typename T> template <typename T>
@ -459,11 +440,6 @@ struct se_storage<T, 8, 8>
const u64 result = swap(src); const u64 result = swap(src);
return reinterpret_cast<const T&>(result); return reinterpret_cast<const T&>(result);
} }
static inline T copy(const T& src)
{
return src;
}
}; };
template <typename T> template <typename T>
@ -486,11 +462,6 @@ struct se_storage<T, 16, 16>
const v128 result = swap(src); const v128 result = swap(src);
return reinterpret_cast<const T&>(result); return reinterpret_cast<const T&>(result);
} }
static inline T copy(const T& src)
{
return src;
}
}; };
// Switched endianness // Switched endianness
@ -553,31 +524,41 @@ class se_t<T, false, Align>
stype m_data; stype m_data;
static stype init(type value)
{
stype result;
std::memcpy(&result, &value, sizeof(result));
return result;
}
public: public:
se_t() = default; se_t() = default;
se_t(type value) se_t(type value)
: m_data(reinterpret_cast<const stype&>(value)) : m_data(init(value))
{ {
} }
type value() const type value() const
{ {
return storage::copy(reinterpret_cast<const type&>(m_data)); type result;
std::memcpy(&result, &m_data, sizeof(result));
return result;
} }
se_t& operator=(const se_t& value) = default; se_t& operator=(const se_t& value) = default;
se_t& operator=(type value) se_t& operator=(type value)
{ {
return m_data = reinterpret_cast<const stype&>(value), *this; std::memcpy(&m_data, &value, sizeof(m_data));
return *this;
} }
using simple_type = simple_t<T>; using simple_type = simple_t<T>;
operator type() const operator type() const
{ {
return storage::copy(reinterpret_cast<const type&>(m_data)); return value();
} }
}; };