diff --git a/Utilities/JIT.cpp b/Utilities/JIT.cpp index 10d2e635d5..feadadfa81 100644 --- a/Utilities/JIT.cpp +++ b/Utilities/JIT.cpp @@ -252,6 +252,11 @@ void asmjit::build_transaction_abort(asmjit::X86Assembler& c, unsigned char code #ifdef _MSC_VER #pragma warning(push, 0) +#else +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wall" +#pragma GCC diagnostic ignored "-Wextra" +#pragma GCC diagnostic ignored "-Wold-style-cast" #endif #include "llvm/Support/TargetSelect.h" #include "llvm/Support/FormattedStream.h" @@ -261,6 +266,8 @@ void asmjit::build_transaction_abort(asmjit::X86Assembler& c, unsigned char code #include "llvm/ExecutionEngine/ObjectCache.h" #ifdef _MSC_VER #pragma warning(pop) +#else +#pragma GCC diagnostic pop #endif #ifdef _WIN32 diff --git a/Utilities/JIT.h b/Utilities/JIT.h index ac658c7cbb..2243c1e3e9 100644 --- a/Utilities/JIT.h +++ b/Utilities/JIT.h @@ -1,9 +1,22 @@ #pragma once +// Include asmjit with warnings ignored #define ASMJIT_EMBED #define ASMJIT_DEBUG +#ifdef _MSC_VER +#pragma warning(push, 0) #include +#pragma warning(pop) +#else +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wall" +#pragma GCC diagnostic ignored "-Wextra" +#pragma GCC diagnostic ignored "-Wold-style-cast" +#include +#pragma GCC diagnostic pop +#endif + #include #include @@ -100,12 +113,19 @@ FT build_function_asm(F&& builder) #include "restore_new.h" #ifdef _MSC_VER #pragma warning(push, 0) +#else +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wall" +#pragma GCC diagnostic ignored "-Wextra" +#pragma GCC diagnostic ignored "-Wold-style-cast" #endif #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" #ifdef _MSC_VER #pragma warning(pop) +#else +#pragma GCC diagnostic pop #endif #include "define_new_memleakdetect.h" diff --git a/Utilities/address_range.h b/Utilities/address_range.h index c1ae078c9b..1e24fb9d6d 100644 --- a/Utilities/address_range.h +++ b/Utilities/address_range.h @@ -140,12 +140,12 @@ namespace utils // other after this if (other.start > end) { - return (s32)(other.start - end - 1); + return static_cast(other.start - end - 1); } // this after other AUDIT(start > other.end); - return -((s32)(start - other.end - 1)); + return -static_cast(start - other.end - 1); } u32 distance(const address_range &other) const @@ -577,7 +577,8 @@ namespace utils } // namespace utils -namespace std { +namespace std +{ static_assert(sizeof(size_t) >= 2 * sizeof(u32), "size_t must be at least twice the size of u32"); template <> diff --git a/Utilities/geometry.h b/Utilities/geometry.h index 0dd57b3baa..73bb502cd2 100644 --- a/Utilities/geometry.h +++ b/Utilities/geometry.h @@ -114,7 +114,7 @@ struct size2_base template constexpr operator size2_base() const { - return{ (NT)width, (NT)height }; + return{ static_cast(width), static_cast(height) }; } }; @@ -142,11 +142,11 @@ struct position1_base template position1_base operator *(RhsT rhs) const { - return{ T(x * rhs) }; + return{ static_cast(x * rhs) }; } position1_base operator *(const position1_base& rhs) const { - return{ T(x * rhs.x) }; + return{ static_cast(x * rhs.x) }; } template position1_base operator /(RhsT rhs) const @@ -225,7 +225,7 @@ struct position1_base template operator position1_base() const { - return{ (NT)x }; + return{ static_cast(x) }; } double distance(const position1_base& to) @@ -303,11 +303,11 @@ struct position2_base template constexpr position2_base operator *(RhsT rhs) const { - return{ T(x * rhs), T(y * rhs) }; + return{ static_cast(x * rhs), static_cast(y * rhs) }; } constexpr position2_base operator *(const position2_base& rhs) const { - return{ T(x * rhs.x), T(y * rhs.y) }; + return{ static_cast(x * rhs.x), static_cast(y * rhs.y) }; } template constexpr position2_base operator /(RhsT rhs) const @@ -398,12 +398,12 @@ struct position2_base template constexpr operator position2_base() const { - return{ (NT)x, (NT)y }; + return{ static_cast(x), static_cast(y) }; } double distance(const position2_base& to) const { - return std::sqrt(double((x - to.x) * (x - to.x) + (y - to.y) * (y - to.y))); + return std::sqrt((x - to.x) * (x - to.x) + (y - to.y) * (y - to.y)); } }; @@ -490,7 +490,7 @@ struct position3_base template operator position3_base() const { - return{ (NT)x, (NT)y, (NT)z }; + return{ static_cast(x), static_cast(y), static_cast(z) }; } }; @@ -580,7 +580,7 @@ struct position4_base template constexpr operator position4_base() const { - return{ (NT)x, (NT)y, (NT)z, (NT)w }; + return{ static_cast(x), static_cast(y), static_cast(z), static_cast(w) }; } }; @@ -652,7 +652,7 @@ struct coord_base template constexpr operator coord_base() const { - return{ (NT)x, (NT)y, (NT)width, (NT)height }; + return{ static_cast(x), static_cast(y), static_cast(width), static_cast(height) }; } }; @@ -755,13 +755,13 @@ struct area_base } constexpr area_base operator * (const f32& value) const { - return{ (T)(x1 * value), (T)(y1 * value), (T)(x2 * value), (T)(y2 * value) }; + return{ static_cast(x1 * value), static_cast(y1 * value), static_cast(x2 * value), static_cast(y2 * value) }; } template constexpr operator area_base() const { - return{ (NT)x1, (NT)y1, (NT)x2, (NT)y2 }; + return{ static_cast(x1), static_cast(y1), static_cast(x2), static_cast(y2) }; } }; @@ -824,7 +824,7 @@ struct coord3_base template constexpr operator coord3_base() const { - return{ (NT)x, (NT)y, (NT)z, (NT)width, (NT)height, (NT)depth }; + return{ static_cast(x), static_cast(y), static_cast(z), static_cast(width), static_cast(height), static_cast(depth) }; } }; @@ -877,7 +877,7 @@ struct color4_base template constexpr operator color4_base() const { - return{ (NT)x, (NT)y, (NT)z, (NT)w }; + return{ static_cast(x), static_cast(y), static_cast(z), static_cast(w) }; } }; @@ -920,7 +920,7 @@ struct color3_base template constexpr operator color3_base() const { - return{ (NT)x, (NT)y, (NT)z }; + return{ static_cast(x), static_cast(y), static_cast(z) }; } }; @@ -962,7 +962,7 @@ struct color2_base template constexpr operator color2_base() const { - return{ (NT)x, (NT)y }; + return{ static_cast(x), static_cast(y) }; } }; @@ -993,7 +993,7 @@ struct color1_base template constexpr operator color1_base() const { - return{ (NT)x }; + return{ static_cast(x) }; } }; diff --git a/rpcs3/Emu/CPU/CPUTranslator.h b/rpcs3/Emu/CPU/CPUTranslator.h index 4fe43b0a95..dd70045a71 100644 --- a/rpcs3/Emu/CPU/CPUTranslator.h +++ b/rpcs3/Emu/CPU/CPUTranslator.h @@ -5,6 +5,11 @@ #include "restore_new.h" #ifdef _MSC_VER #pragma warning(push, 0) +#else +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wall" +#pragma GCC diagnostic ignored "-Wextra" +#pragma GCC diagnostic ignored "-Wold-style-cast" #endif #include "llvm/IR/LLVMContext.h" #include "llvm/IR/IRBuilder.h" @@ -13,6 +18,8 @@ #include "llvm/Analysis/ConstantFolding.h" #ifdef _MSC_VER #pragma warning(pop) +#else +#pragma GCC diagnostic pop #endif #include "define_new_memleakdetect.h" diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index a1e1bcf59b..f959740a45 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -19,6 +19,11 @@ #include "restore_new.h" #ifdef _MSC_VER #pragma warning(push, 0) +#else +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wall" +#pragma GCC diagnostic ignored "-Wextra" +#pragma GCC diagnostic ignored "-Wold-style-cast" #endif #include "llvm/Support/FormattedStream.h" #include "llvm/Support/MemoryBuffer.h" @@ -44,6 +49,8 @@ #include "llvm/Transforms/Vectorize.h" #ifdef _MSC_VER #pragma warning(pop) +#else +#pragma GCC diagnostic pop #endif #include "define_new_memleakdetect.h" diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp index bdbb1849fa..19231aea15 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.cpp +++ b/rpcs3/Emu/Cell/SPURecompiler.cpp @@ -3187,6 +3187,15 @@ void spu_recompiler_base::dump(const spu_program& result, std::string& out) #ifdef LLVM_AVAILABLE #include "Emu/CPU/CPUTranslator.h" + +#ifdef _MSC_VER +#pragma warning(push, 0) +#else +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wall" +#pragma GCC diagnostic ignored "-Wextra" +#pragma GCC diagnostic ignored "-Wold-style-cast" +#endif #include "llvm/ADT/Triple.h" #include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/Verifier.h" @@ -3196,6 +3205,11 @@ void spu_recompiler_base::dump(const spu_program& result, std::string& out) #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/Vectorize.h" +#ifdef _MSC_VER +#pragma warning(pop) +#else +#pragma GCC diagnostic pop +#endif class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator { diff --git a/rpcs3/Emu/Cell/lv2/sys_rsx.cpp b/rpcs3/Emu/Cell/lv2/sys_rsx.cpp index 22246f10ac..8406d66e1e 100644 --- a/rpcs3/Emu/Cell/lv2/sys_rsx.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_rsx.cpp @@ -135,7 +135,7 @@ error_code sys_rsx_context_allocate(vm::ptr context_id, vm::ptr lpar_d } const auto area = vm::reserve_map(vm::rsx_context, 0, 0x10000000, 0x403); - const u32 context_base = area ? area->alloc(0x300000) : 0; + const u32 context_base = area ? area->alloc(0x300000) : 0; if (!context_base) { @@ -433,7 +433,7 @@ error_code sys_rsx_context_attribute(u32 context_id, u32 package_id, u64 a3, u64 render->display_buffers[id].pitch = pitch; render->display_buffers[id].offset = offset; - render->display_buffers_count = std::max((u32)id + 1, render->display_buffers_count); + render->display_buffers_count = std::max(id + 1, render->display_buffers_count); } break; @@ -536,7 +536,7 @@ error_code sys_rsx_context_attribute(u32 context_id, u32 package_id, u64 a3, u64 // we only ever use head 1 for now driverInfo.head[1].flipFlags |= 0x80000000; driverInfo.head[1].lastFlipTime = rsxTimeStamp(); // should rsxthread set this? - driverInfo.head[1].flipBufferId = (u32)a3; + driverInfo.head[1].flipBufferId = static_cast(a3); // seems gcmSysWaitLabel uses this offset, so lets set it to 0 every flip vm::_ref(render->label_addr + 0x10) = 0; @@ -597,7 +597,7 @@ error_code sys_rsx_device_map(vm::ptr dev_addr, vm::ptr a2, u32 dev_id if (!rsx_cfg->device_addr) { const auto area = vm::reserve_map(vm::rsx_context, 0, 0x10000000, 0x403); - const u32 addr = area ? area->alloc(0x100000) : 0; + const u32 addr = area ? area->alloc(0x100000) : 0; if (!addr) { diff --git a/rpcs3/Emu/RSX/Common/ProgramStateCache.h b/rpcs3/Emu/RSX/Common/ProgramStateCache.h index 03ebe4ac5e..ee5d955998 100644 --- a/rpcs3/Emu/RSX/Common/ProgramStateCache.h +++ b/rpcs3/Emu/RSX/Common/ProgramStateCache.h @@ -532,8 +532,8 @@ public: alignas(16) f32 tmp[4]; for (size_t offset_in_fragment_program : I->second.FragmentConstantOffsetCache) { - char* data = (char*)fragment_program.addr + (u32)offset_in_fragment_program; - const __m128i vector = _mm_loadu_si128((__m128i*)data); + char* data = static_cast(fragment_program.addr) + offset_in_fragment_program; + const __m128i vector = _mm_loadu_si128(reinterpret_cast<__m128i*>(data)); const __m128i shuffled_vector = _mm_or_si128(_mm_slli_epi16(vector, 8), _mm_srli_epi16(vector, 8)); if (!patch_table.is_empty()) diff --git a/rpcs3/Emu/RSX/Overlays/overlay_controls.h b/rpcs3/Emu/RSX/Overlays/overlay_controls.h index b07d10c974..0d4d32b704 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_controls.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_controls.h @@ -74,7 +74,7 @@ namespace rsx vertex(int x, int y, int z, int w) { - vec4((f32)x, (f32)y, (f32)z, (f32)w); + vec4(static_cast(x), static_cast(y), static_cast(z), static_cast(w)); } float& operator[](int index) @@ -165,7 +165,7 @@ namespace rsx return f.get(); } - fonts.push_back(std::make_unique(name, (f32)size)); + fonts.push_back(std::make_unique(name, static_cast(size))); return fonts.back().get(); } @@ -209,12 +209,12 @@ namespace rsx std::vector bytes; fs::file f(filename); f.read(bytes, f.size()); - data = stbi_load_from_memory(bytes.data(), (s32)f.size(), &w, &h, &bpp, STBI_rgb_alpha); + data = stbi_load_from_memory(bytes.data(), ::narrow(f.size()), &w, &h, &bpp, STBI_rgb_alpha); } image_info(const std::vector& bytes) { - data = stbi_load_from_memory(bytes.data(), (s32)bytes.size(), &w, &h, &bpp, STBI_rgb_alpha); + data = stbi_load_from_memory(bytes.data(), ::narrow(bytes.size()), &w, &h, &bpp, STBI_rgb_alpha); } ~image_info() @@ -505,8 +505,8 @@ namespace rsx virtual void translate(s16 _x, s16 _y) { - x = (u16)(x + _x); - y = (u16)(y + _y); + x = static_cast(x + _x); + y = static_cast(y + _y); is_compiled = false; } @@ -515,12 +515,12 @@ namespace rsx { if (origin_scaling) { - x = (u16)(_x * x); - y = (u16)(_y * y); + x = static_cast(_x * x); + y = static_cast(_y * y); } - w = (u16)(_x * w); - h = (u16)(_y * h); + w = static_cast(_x * w); + h = static_cast(_y * h); is_compiled = false; } @@ -626,7 +626,7 @@ namespace rsx // Apply transform. // (0, 0) has text sitting one line off the top left corner (text is outside the rect) hence the offset by text height v.values[0] += x + padding_left; - v.values[1] += y + padding_top + (f32)renderer->size_px; + v.values[1] += y + padding_top + static_cast(renderer->size_px); } if (alignment == center) @@ -711,7 +711,7 @@ namespace rsx cmd_text.config.set_font(font_ref ? font_ref : fontmgr::get("Arial", 12)); cmd_text.config.color = fore_color; - cmd_text.verts = render_text(text.c_str(), (f32)x, (f32)y); + cmd_text.verts = render_text(text.c_str(), static_cast(x), static_cast(y)); if (!cmd_text.verts.empty()) compiled_resources.add(std::move(compiled_resources_temp), margin_left, margin_top); @@ -737,13 +737,13 @@ namespace rsx f32 unused = 0.f; f32 max_w = 0.f; f32 last_word = 0.f; - height = (u16)renderer->size_px; + height = static_cast(renderer->size_px); for (auto c : text) { if (c == '\n') { - height += (u16)renderer->size_px + 2; + height += static_cast(renderer->size_px + 2); max_w = std::max(max_w, text_width); text_width = 0.f; last_word = 0.f; @@ -755,7 +755,7 @@ namespace rsx last_word = text_width; } - if (u8(c) > renderer->char_count) + if (static_cast(c) > renderer->char_count) { // Non-existent glyph text_width += renderer->em_size; @@ -771,13 +771,13 @@ namespace rsx { max_w = std::max(max_w, last_word); text_width -= (last_word + renderer->em_size); - height += (u16)renderer->size_px + 2; + height += static_cast(renderer->size_px + 2); } } } max_w = std::max(max_w, text_width); - width = (u16)ceilf(max_w); + width = static_cast(ceilf(max_w)); } }; @@ -817,8 +817,8 @@ namespace rsx void set_pos(u16 _x, u16 _y) override { - s16 dx = (s16)(_x - x); - s16 dy = (s16)(_y - y); + s16 dx = static_cast(_x - x); + s16 dy = static_cast(_y - y); translate(dx, dy); } @@ -877,12 +877,12 @@ namespace rsx if (!is_compiled) { compiled_resource result = overlay_element::get_compiled(); - const f32 global_y_offset = (f32)-scroll_offset_value; + const f32 global_y_offset = static_cast(-scroll_offset_value); for (auto &item : m_items) { - const s32 item_y_limit = (s32)(item->y + item->h) - scroll_offset_value - y; - const s32 item_y_base = (s32)item->y - scroll_offset_value - y; + const s32 item_y_limit = s32{item->y} + item->h - scroll_offset_value - y; + const s32 item_y_base = s32{item->y} - scroll_offset_value - y; if (item_y_limit < 0 || item_y_base > h) { @@ -892,7 +892,7 @@ namespace rsx else if (item_y_limit > h || item_y_base < 0) { // Partial render - areaf clip_rect = { (f32)x, (f32)y, (f32)(x + w), (f32)(y + h) }; + areaf clip_rect = areai{ x, y, (x + w), (y + h) }; result.add(item->get_compiled(), 0.f, global_y_offset, clip_rect); } else @@ -951,12 +951,12 @@ namespace rsx if (!is_compiled) { compiled_resource result = overlay_element::get_compiled(); - const f32 global_x_offset = (f32)-scroll_offset_value; + const f32 global_x_offset = static_cast(-scroll_offset_value); for (auto &item : m_items) { - const s32 item_x_limit = (s32)(item->x + item->w) - scroll_offset_value - w; - const s32 item_x_base = (s32)item->x - scroll_offset_value - w; + const s32 item_x_limit = s32{item->x} + item->w - scroll_offset_value - w; + const s32 item_x_base = s32{item->x} - scroll_offset_value - w; if (item_x_limit < 0 || item_x_base > h) { @@ -966,7 +966,7 @@ namespace rsx else if (item_x_limit > h || item_x_base < 0) { // Partial render - areaf clip_rect = { (f32)x, (f32)y, (f32)(x + w), (f32)(y + h) }; + areaf clip_rect = areai{ x, y, (x + w), (y + h) }; result.add(item->get_compiled(), global_x_offset, 0.f, clip_rect); } else diff --git a/rpcs3/Emu/RSX/RSXFragmentProgram.h b/rpcs3/Emu/RSX/RSXFragmentProgram.h index 9911c1a4ce..645401ce6d 100644 --- a/rpcs3/Emu/RSX/RSXFragmentProgram.h +++ b/rpcs3/Emu/RSX/RSXFragmentProgram.h @@ -246,18 +246,18 @@ struct RSXFragmentProgram rsx::texture_dimension_extended get_texture_dimension(u8 id) const { - return (rsx::texture_dimension_extended)((texture_dimensions >> (id * 2)) & 0x3); + return rsx::texture_dimension_extended{static_cast((texture_dimensions >> (id * 2)) & 0x3)}; } bool texcoord_is_2d(u8 index) const { - return bool(texcoord_control_mask & (1u << index)); + return !!(texcoord_control_mask & (1u << index)); } bool texcoord_is_point_coord(u8 index) const { index += 16; - return bool(texcoord_control_mask & (1u << index)); + return !!(texcoord_control_mask & (1u << index)); } RSXFragmentProgram() diff --git a/rpcs3/Emu/RSX/RSXVertexProgram.h b/rpcs3/Emu/RSX/RSXVertexProgram.h index 8643cb13df..9dc5f25d9d 100644 --- a/rpcs3/Emu/RSX/RSXVertexProgram.h +++ b/rpcs3/Emu/RSX/RSXVertexProgram.h @@ -245,6 +245,6 @@ struct RSXVertexProgram rsx::texture_dimension_extended get_texture_dimension(u8 id) const { - return (rsx::texture_dimension_extended)((texture_dimensions >> (id * 2)) & 0x3); + return rsx::texture_dimension_extended{static_cast((texture_dimensions >> (id * 2)) & 0x3)}; } }; diff --git a/rpcs3/Emu/RSX/rsx_cache.h b/rpcs3/Emu/RSX/rsx_cache.h index 267abb4210..ddb461f911 100644 --- a/rpcs3/Emu/RSX/rsx_cache.h +++ b/rpcs3/Emu/RSX/rsx_cache.h @@ -564,7 +564,7 @@ namespace rsx entries.push_back(tmp); } - if ((entry_count = (u32)entries.size()) <= 2) + if ((entry_count = ::size32(entries)) <= 2) return; root.rewind(); @@ -611,7 +611,7 @@ namespace rsx } f.read(bytes, f.size()); - auto entry = unpack(*(pipeline_data*)bytes.data()); + auto entry = unpack(*reinterpret_cast(bytes.data())); m_storage.preload_programs(std::get<1>(entry), std::get<2>(entry)); unpacked.push_back(entry); @@ -780,7 +780,7 @@ namespace rsx RSXFragmentProgram fp = {}; fragment_program_data[program_hash] = data; fp.addr = fragment_program_data[program_hash].data(); - fp.ucode_length = (u32)data.size(); + fp.ucode_length = ::size32(data); return fp; } @@ -849,7 +849,7 @@ namespace rsx { for (auto &address : vp.jump_table) { - data_block.vp_jump_table[index++] = (u16)address; + data_block.vp_jump_table[index++] = static_cast(address); } } else diff --git a/rpcs3/Emu/RSX/rsx_methods.h b/rpcs3/Emu/RSX/rsx_methods.h index 6d7e51c124..80ebf8366f 100644 --- a/rpcs3/Emu/RSX/rsx_methods.h +++ b/rpcs3/Emu/RSX/rsx_methods.h @@ -286,7 +286,7 @@ namespace rsx return 1u; } - u32 count = (u32)draw_command_ranges.size(); + u32 count = ::size32(draw_command_ranges); if (draw_command_ranges.back().count == 0) { // Dangling barrier @@ -400,7 +400,7 @@ namespace rsx const u32 count = barrier.address - previous_barrier; ret.push_back({ 0, vertex_counter, count }); - previous_barrier = (u32)barrier.address; + previous_barrier = barrier.address; vertex_counter += count; } @@ -687,7 +687,7 @@ namespace rsx bool restart_index_enabled() const { - if (!restart_index_enabled_raw()) + if (!restart_index_enabled_raw()) { return false; diff --git a/rpcs3/Emu/RSX/rsx_utils.h b/rpcs3/Emu/RSX/rsx_utils.h index 053fb22577..39bea5d103 100644 --- a/rpcs3/Emu/RSX/rsx_utils.h +++ b/rpcs3/Emu/RSX/rsx_utils.h @@ -291,7 +291,7 @@ namespace rsx { for (u32 i = 0; i < size; i++) { - *((Td*)dst + i) = *((Ts*)src - i); + *(static_cast(dst) + i) = *(static_cast(src) - i); } } @@ -463,14 +463,14 @@ namespace rsx * TODO: Variable src/dst and optional se conversion */ template - void shuffle_texel_data_wzyx(void *data, u16 row_pitch_in_bytes, u16 row_length_in_texels, u16 num_rows) + void shuffle_texel_data_wzyx(void* data, u16 row_pitch_in_bytes, u16 row_length_in_texels, u16 num_rows) { - char *raw_src = (char*)data; + char* raw_src = static_cast(data); T tmp[4]; for (u16 n = 0; n < num_rows; ++n) { - T* src = (T*)raw_src; + T* src = reinterpret_cast(raw_src); raw_src += row_pitch_in_bytes; for (u16 m = 0; m < row_length_in_texels; ++m) @@ -511,7 +511,7 @@ namespace rsx else width = parent_width; - x = (T)0; + x = static_cast(0); } else { @@ -531,7 +531,7 @@ namespace rsx else height = parent_height; - y = (T)0; + y = static_cast(0); } else { @@ -581,7 +581,7 @@ namespace rsx static inline const f32 get_resolution_scale() { - return g_cfg.video.strict_rendering_mode? 1.f : ((f32)g_cfg.video.resolution_scale_percent / 100.f); + return g_cfg.video.strict_rendering_mode? 1.f : (g_cfg.video.resolution_scale_percent / 100.f); } static inline const int get_resolution_scale_percent() @@ -598,9 +598,9 @@ namespace rsx return value; else if (clamp) - return (u16)std::max((get_resolution_scale_percent() * value) / 100, 1); + return static_cast(std::max((get_resolution_scale_percent() * value) / 100, 1)); else - return (get_resolution_scale_percent() * value) / 100; + return static_cast((get_resolution_scale_percent() * value) / 100); } static inline const u16 apply_inverse_resolution_scale(u16 value, bool clamp) @@ -608,9 +608,9 @@ namespace rsx u16 result = value; if (clamp) - result = (u16)std::max((value * 100) / get_resolution_scale_percent(), 1); + result = static_cast(std::max((value * 100) / get_resolution_scale_percent(), 1)); else - result = (value * 100) / get_resolution_scale_percent(); + result = static_cast((value * 100) / get_resolution_scale_percent()); if (result <= g_cfg.video.min_scalable_dimension) return value; @@ -721,14 +721,14 @@ namespace rsx // before actually attempting to translate to the internal address. Seen happening heavily in R&C games static inline u32 get_vertex_offset_from_base(u32 vert_data_base_offset, u32 vert_base_offset) { - return ((u64)vert_data_base_offset + vert_base_offset) & 0xFFFFFFF; + return (vert_data_base_offset + vert_base_offset) & 0xFFFFFFF; } // Similar to vertex_offset_base calculation, the rsx internally adds and masks index // before using static inline u32 get_index_from_base(u32 index, u32 index_base) { - return ((u64)index + index_base) & 0x000FFFFF; + return (index + index_base) & 0x000FFFFF; } // Convert color write mask for G8B8 to R8G8 @@ -912,7 +912,7 @@ namespace rsx _size = other._size; const auto size_bytes = sizeof(Ty) * _capacity; - _data = (Ty*)malloc(size_bytes); + _data = static_cast(malloc(size_bytes)); std::memcpy(_data, other._data, size_bytes); } @@ -943,15 +943,7 @@ namespace rsx if (_capacity >= size) return; - if (_data) - { - verify("realloc() failed!" HERE), _data = (Ty*)realloc(_data, sizeof(Ty) * size); - } - else - { - verify("malloc() failed!" HERE), _data = (Ty*)malloc(sizeof(Ty) * size); - } - + verify("realloc() failed!" HERE), _data = static_cast(std::realloc(_data, sizeof(Ty) * size)); _capacity = size; } diff --git a/rpcs3/Emu/RSX/rsx_vertex_data.h b/rpcs3/Emu/RSX/rsx_vertex_data.h index 0f2ef04f5d..1e43634fc9 100644 --- a/rpcs3/Emu/RSX/rsx_vertex_data.h +++ b/rpcs3/Emu/RSX/rsx_vertex_data.h @@ -91,7 +91,7 @@ struct push_buffer_vertex_info case vertex_base_type::s32k: return size / 2; default: - fmt::throw_exception("Unsupported vertex base type %d", (u8)type); + fmt::throw_exception("Unsupported vertex base type %d", static_cast(type)); } } @@ -112,8 +112,8 @@ struct push_buffer_vertex_info attribute_mask |= element_mask; - void* dst = data.data() + ((vertex_count - 1) * vertex_size) + sub_index; - *(u32*)dst = arg; + u32* dst = data.data() + ((vertex_count - 1) * vertex_size) + sub_index; + *dst = arg; } }; diff --git a/rpcs3/stb_image.cpp b/rpcs3/stb_image.cpp index feeee513ba..806b9f8f42 100644 --- a/rpcs3/stb_image.cpp +++ b/rpcs3/stb_image.cpp @@ -13,6 +13,7 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wall" #pragma GCC diagnostic ignored "-Wextra" +#pragma GCC diagnostic ignored "-Wold-style-cast" #include #pragma GCC diagnostic pop diff --git a/rpcs3/util/atomic.hpp b/rpcs3/util/atomic.hpp index 5904222bea..47e38eab95 100644 --- a/rpcs3/util/atomic.hpp +++ b/rpcs3/util/atomic.hpp @@ -365,7 +365,7 @@ struct atomic_storage : atomic_storage static inline bool bts(T& dest, uint bit) { bool result; - ushort _bit = (ushort)bit; + ushort _bit = static_cast(bit); __asm__("lock btsw %2, %0\n" "setc %1" : "+m" (dest), "=r" (result) : "Ir" (_bit) : "cc"); return result; } @@ -373,7 +373,7 @@ struct atomic_storage : atomic_storage static inline bool btr(T& dest, uint bit) { bool result; - ushort _bit = (ushort)bit; + ushort _bit = static_cast(bit); __asm__("lock btrw %2, %0\n" "setc %1" : "+m" (dest), "=r" (result) : "Ir" (_bit) : "cc"); return result; } @@ -381,7 +381,7 @@ struct atomic_storage : atomic_storage static inline bool btc(T& dest, uint bit) { bool result; - ushort _bit = (ushort)bit; + ushort _bit = static_cast(bit); __asm__("lock btcw %2, %0\n" "setc %1" : "+m" (dest), "=r" (result) : "Ir" (_bit) : "cc"); return result; }