mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-04 14:08:37 +00:00
Enable -Wstrict-aliasing=1 (GCC)
Fixed partially.
This commit is contained in:
parent
3990e2d3e6
commit
a4fdbf0a88
34 changed files with 141 additions and 81 deletions
|
|
@ -1301,7 +1301,9 @@ fs::file::file(const std::string& path, bs_t<open_mode> mode)
|
|||
static_assert(sizeof(iovec) == sizeof(iovec_clone), "Weird iovec size");
|
||||
static_assert(offsetof(iovec, iov_len) == offsetof(iovec_clone, iov_len), "Weird iovec::iov_len offset");
|
||||
|
||||
const auto result = ::writev(m_fd, reinterpret_cast<const iovec*>(buffers), buf_count);
|
||||
iovec arg;
|
||||
std::memcpy(&arg, buffers, sizeof(arg));
|
||||
const auto result = ::writev(m_fd, &arg, buf_count);
|
||||
ensure(result != -1); // "file::write_gather"
|
||||
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -282,6 +282,7 @@ asmjit::Runtime& asmjit::get_global_runtime()
|
|||
#pragma GCC diagnostic ignored "-Wextra"
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
#endif
|
||||
#include "llvm/Support/TargetSelect.h"
|
||||
#include "llvm/Support/FormattedStream.h"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
#pragma GCC diagnostic ignored "-Wextra"
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
#include <asmjit/asmjit.h>
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
|
@ -180,6 +181,7 @@ inline FT build_function_asm(F&& builder)
|
|||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#pragma GCC diagnostic ignored "-Wsuggest-override"
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic ignored "-Winconsistent-missing-override"
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -344,7 +344,9 @@ struct fmt::cfmt_src
|
|||
template <typename T>
|
||||
T get(usz index) const
|
||||
{
|
||||
return *reinterpret_cast<const T*>(reinterpret_cast<const u8*>(args + index));
|
||||
T res{};
|
||||
std::memcpy(&res, reinterpret_cast<const u8*>(args + index), sizeof(res));
|
||||
return res;
|
||||
}
|
||||
|
||||
void skip(usz extra)
|
||||
|
|
|
|||
|
|
@ -1261,7 +1261,9 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) no
|
|||
{
|
||||
if (op == X64OP_NONE)
|
||||
{
|
||||
sig_log.error("decode_x64_reg_op(%p): unsupported opcode: %s", code, *reinterpret_cast<const be_t<v128, 1>*>(code));
|
||||
be_t<v128> dump;
|
||||
std::memcpy(&dump, code, sizeof(dump));
|
||||
sig_log.error("decode_x64_reg_op(%p): unsupported opcode: %s", code, dump);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -547,58 +547,70 @@ static std::basic_string<u32> apply_modification(const patch_engine::patch_info&
|
|||
}
|
||||
case patch_type::le16:
|
||||
{
|
||||
*reinterpret_cast<le_t<u16, 1>*>(ptr) = static_cast<u16>(p.value.long_value);
|
||||
le_t<u16> val = static_cast<u16>(p.value.long_value);
|
||||
std::memcpy(ptr, &val, sizeof(val));
|
||||
break;
|
||||
}
|
||||
case patch_type::le32:
|
||||
{
|
||||
*reinterpret_cast<le_t<u32, 1>*>(ptr) = static_cast<u32>(p.value.long_value);
|
||||
le_t<u32> val = static_cast<u32>(p.value.long_value);
|
||||
std::memcpy(ptr, &val, sizeof(val));
|
||||
break;
|
||||
}
|
||||
case patch_type::lef32:
|
||||
{
|
||||
*reinterpret_cast<le_t<u32, 1>*>(ptr) = std::bit_cast<u32, f32>(static_cast<f32>(p.value.double_value));
|
||||
le_t<f32> val = static_cast<f32>(p.value.double_value);
|
||||
std::memcpy(ptr, &val, sizeof(val));
|
||||
break;
|
||||
}
|
||||
case patch_type::le64:
|
||||
{
|
||||
*reinterpret_cast<le_t<u64, 1>*>(ptr) = static_cast<u64>(p.value.long_value);
|
||||
le_t<u64> val = static_cast<u64>(p.value.long_value);
|
||||
std::memcpy(ptr, &val, sizeof(val));
|
||||
break;
|
||||
}
|
||||
case patch_type::lef64:
|
||||
{
|
||||
*reinterpret_cast<le_t<u64, 1>*>(ptr) = std::bit_cast<u64, f64>(p.value.double_value);
|
||||
le_t<f64> val = p.value.double_value;
|
||||
std::memcpy(ptr, &val, sizeof(val));
|
||||
break;
|
||||
}
|
||||
case patch_type::be16:
|
||||
{
|
||||
*reinterpret_cast<be_t<u16, 1>*>(ptr) = static_cast<u16>(p.value.long_value);
|
||||
be_t<u16> val = static_cast<u16>(p.value.long_value);
|
||||
std::memcpy(ptr, &val, sizeof(val));
|
||||
break;
|
||||
}
|
||||
case patch_type::bd32:
|
||||
{
|
||||
*reinterpret_cast<be_t<u32, 1>*>(ptr) = static_cast<u32>(p.value.long_value);
|
||||
be_t<u32> val = static_cast<u32>(p.value.long_value);
|
||||
std::memcpy(ptr, &val, sizeof(val));
|
||||
break;
|
||||
}
|
||||
case patch_type::be32:
|
||||
{
|
||||
*reinterpret_cast<be_t<u32, 1>*>(ptr) = static_cast<u32>(p.value.long_value);
|
||||
if (offset % 4 == 0) resval = offset;
|
||||
be_t<u32> val = static_cast<u32>(p.value.long_value);
|
||||
std::memcpy(ptr, &val, sizeof(val));
|
||||
if (offset % 4 == 0)
|
||||
resval = offset;
|
||||
break;
|
||||
}
|
||||
case patch_type::bef32:
|
||||
{
|
||||
*reinterpret_cast<be_t<u32, 1>*>(ptr) = std::bit_cast<u32, f32>(static_cast<f32>(p.value.double_value));
|
||||
be_t<f32> val = static_cast<f32>(p.value.double_value);
|
||||
std::memcpy(ptr, &val, sizeof(val));
|
||||
break;
|
||||
}
|
||||
case patch_type::bd64:
|
||||
{
|
||||
*reinterpret_cast<be_t<u64, 1>*>(ptr) = static_cast<u64>(p.value.long_value);
|
||||
be_t<u64> val = static_cast<u64>(p.value.long_value);
|
||||
std::memcpy(ptr, &val, sizeof(val));
|
||||
break;
|
||||
}
|
||||
case patch_type::be64:
|
||||
{
|
||||
*reinterpret_cast<be_t<u64, 1>*>(ptr) = static_cast<u64>(p.value.long_value);
|
||||
be_t<u64> val = static_cast<u64>(p.value.long_value);
|
||||
std::memcpy(ptr, &val, sizeof(val));
|
||||
|
||||
if (offset % 4)
|
||||
{
|
||||
|
|
@ -611,7 +623,8 @@ static std::basic_string<u32> apply_modification(const patch_engine::patch_info&
|
|||
}
|
||||
case patch_type::bef64:
|
||||
{
|
||||
*reinterpret_cast<be_t<u64, 1>*>(ptr) = std::bit_cast<u64, f64>(p.value.double_value);
|
||||
be_t<f64> val = p.value.double_value;
|
||||
std::memcpy(ptr, &val, sizeof(val));
|
||||
break;
|
||||
}
|
||||
case patch_type::utf8:
|
||||
|
|
|
|||
|
|
@ -1,61 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "util/types.hpp"
|
||||
|
||||
namespace rpcs3
|
||||
{
|
||||
constexpr usz fnv_seed = 14695981039346656037ull;
|
||||
constexpr usz fnv_prime = 1099511628211ull;
|
||||
|
||||
template<typename T>
|
||||
static usz hash_base(T value)
|
||||
{
|
||||
return static_cast<usz>(value);
|
||||
}
|
||||
|
||||
template<typename T, typename = std::enable_if_t<std::is_integral<T>::value, bool>>
|
||||
static inline usz hash64(usz hash_value, const T data)
|
||||
{
|
||||
hash_value ^= data;
|
||||
hash_value *= fnv_prime;
|
||||
return hash_value;
|
||||
}
|
||||
|
||||
template<typename T, typename U>
|
||||
static usz hash_struct_base(const T& value)
|
||||
{
|
||||
// FNV 64-bit
|
||||
usz result = fnv_seed;
|
||||
const U *bits = reinterpret_cast<const U*>(&value);
|
||||
|
||||
for (usz n = 0; n < (sizeof(T) / sizeof(U)); ++n)
|
||||
{
|
||||
result = hash64(result, bits[n]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static usz hash_struct(const T& value)
|
||||
{
|
||||
static constexpr auto block_sz = sizeof(T);
|
||||
|
||||
if constexpr ((block_sz & 0x7) == 0)
|
||||
{
|
||||
return hash_struct_base<T, u64>(value);
|
||||
}
|
||||
|
||||
if constexpr ((block_sz & 0x3) == 0)
|
||||
{
|
||||
return hash_struct_base<T, u32>(value);
|
||||
}
|
||||
|
||||
if constexpr ((block_sz & 0x1) == 0)
|
||||
{
|
||||
return hash_struct_base<T, u16>(value);
|
||||
}
|
||||
|
||||
return hash_struct_base<T, u8>(value);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue