diff --git a/Utilities/Log.cpp b/Utilities/Log.cpp index 4359b5ea85..78a087be4b 100644 --- a/Utilities/Log.cpp +++ b/Utilities/Log.cpp @@ -420,9 +420,13 @@ logs::file_writer::file_writer(const std::string& name) m_fout.open(log_name, fs::rewrite); // Compressed log, make it inaccessible (foolproof) - if (!m_fout2.open(log_name + ".gz", fs::rewrite + fs::unread) || deflateInit2(&m_zs, 9, Z_DEFLATED, 16 + 15, 9, Z_DEFAULT_STRATEGY) != Z_OK) + if (m_fout2.open(log_name + ".gz", fs::rewrite + fs::unread)) { - m_fout2.close(); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wold-style-cast" + if (deflateInit2(&m_zs, 9, Z_DEFLATED, 16 + 15, 9, Z_DEFAULT_STRATEGY) != Z_OK) +#pragma GCC diagnostic pop + m_fout2.close(); } #ifdef _WIN32 @@ -666,14 +670,14 @@ void logs::file_listener::log(u64 stamp, const logs::message& msg, const std::st // Used character: U+00B7 (Middle Dot) switch (msg.sev) { - case level::always: text = u8"·A "; break; - case level::fatal: text = u8"·F "; break; - case level::error: text = u8"·E "; break; - case level::todo: text = u8"·U "; break; - case level::success: text = u8"·S "; break; - case level::warning: text = u8"·W "; break; - case level::notice: text = u8"·! "; break; - case level::trace: text = u8"·T "; break; + case level::always: text = reinterpret_cast(u8"·A "); break; + case level::fatal: text = reinterpret_cast(u8"·F "); break; + case level::error: text = reinterpret_cast(u8"·E "); break; + case level::todo: text = reinterpret_cast(u8"·U "); break; + case level::success: text = reinterpret_cast(u8"·S "); break; + case level::warning: text = reinterpret_cast(u8"·W "); break; + case level::notice: text = reinterpret_cast(u8"·! "); break; + case level::trace: text = reinterpret_cast(u8"·T "); break; } // Print µs timestamp diff --git a/Utilities/Log.h b/Utilities/Log.h index 5284864634..55e581ba81 100644 --- a/Utilities/Log.h +++ b/Utilities/Log.h @@ -68,6 +68,13 @@ namespace logs { } + private: +#if __cpp_char8_t >= 201811 + using char2 = char8_t; +#else + using char2 = uchar; +#endif + #define GEN_LOG_METHOD(_sev)\ const message msg_##_sev{this, level::_sev};\ template \ @@ -78,8 +85,18 @@ namespace logs static constexpr fmt_type_info type_list[sizeof...(Args) + 1]{fmt_type_info::make>()...};\ msg_##_sev.broadcast(fmt, type_list, u64{fmt_unveil::get(args)}...);\ }\ - } + }\ + template \ + void _sev(const char2(&fmt)[N], const Args&... args)\ + {\ + if (UNLIKELY(level::_sev <= enabled.load(std::memory_order_relaxed)))\ + {\ + static constexpr fmt_type_info type_list[sizeof...(Args) + 1]{fmt_type_info::make>()...};\ + msg_##_sev.broadcast(reinterpret_cast(+fmt), type_list, u64{fmt_unveil::get(args)}...);\ + }\ + }\ + public: GEN_LOG_METHOD(fatal) GEN_LOG_METHOD(error) GEN_LOG_METHOD(todo) diff --git a/Utilities/StrFmt.h b/Utilities/StrFmt.h index 205a9398df..62cc732f52 100644 --- a/Utilities/StrFmt.h +++ b/Utilities/StrFmt.h @@ -8,8 +8,8 @@ namespace fmt { - template - static std::string format(const char*, const Args&...); + template + static std::string format(const CharT(&)[N], const Args&...); } template @@ -274,19 +274,19 @@ namespace fmt void raw_append(std::string& out, const char*, const fmt_type_info*, const u64*) noexcept; // Formatting function - template - SAFE_BUFFERS FORCE_INLINE void append(std::string& out, const char* fmt, const Args&... args) + template + SAFE_BUFFERS FORCE_INLINE void append(std::string& out, const CharT(&fmt)[N], const Args&... args) { static constexpr fmt_type_info type_list[sizeof...(Args) + 1]{fmt_type_info::make>()...}; - raw_append(out, fmt, type_list, fmt_args_t{fmt_unveil::get(args)...}); + raw_append(out, reinterpret_cast(fmt), type_list, fmt_args_t{fmt_unveil::get(args)...}); } // Formatting function - template - SAFE_BUFFERS FORCE_INLINE std::string format(const char* fmt, const Args&... args) + template + SAFE_BUFFERS FORCE_INLINE std::string format(const CharT(&fmt)[N], const Args&... args) { std::string result; - append(result, fmt, args...); + append(result, fmt, args...); return result; } diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index e0b006ff9c..4e762e5ee1 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -2203,7 +2203,10 @@ void thread_ctrl::set_thread_affinity_mask(u64 mask) if (shifted & 1) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wold-style-cast" CPU_SET(core, &cs); +#pragma GCC diagnostic pop } if (shifted <= 1) diff --git a/rpcs3/Crypto/unself.cpp b/rpcs3/Crypto/unself.cpp index 396ee17d6a..0ecce45fc9 100644 --- a/rpcs3/Crypto/unself.cpp +++ b/rpcs3/Crypto/unself.cpp @@ -832,7 +832,10 @@ std::vector SCEDecrypter::MakeFile() strm.avail_out = BUFSIZE; strm.next_in = data_buf.get()+data_buf_offset; strm.next_out = tempbuf; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wold-style-cast" int ret = inflateInit(&strm); +#pragma GCC diagnostic pop while (strm.avail_in) { diff --git a/rpcs3/Emu/Memory/vm.cpp b/rpcs3/Emu/Memory/vm.cpp index 60c0a36746..eb27db35de 100644 --- a/rpcs3/Emu/Memory/vm.cpp +++ b/rpcs3/Emu/Memory/vm.cpp @@ -1159,22 +1159,22 @@ void fmt_class_string>::format(std::string& out, // Special case (may be allowed for some arguments) if (arg == 0) { - out += u8"«NULL»"; + out += reinterpret_cast(u8"«NULL»"); return; } // Filter certainly invalid addresses (TODO) if (arg < 0x10000 || arg >= 0xf0000000) { - out += u8"«INVALID_ADDRESS:"; + out += reinterpret_cast(u8"«INVALID_ADDRESS:"); fmt_class_string::format(out, arg); - out += u8"»"; + out += reinterpret_cast(u8"»"); return; } const auto start = out.size(); - out += u8"“"; + out += reinterpret_cast(u8"“"); for (vm::_ptr_base ptr = vm::cast(arg);; ptr++) { @@ -1182,9 +1182,9 @@ void fmt_class_string>::format(std::string& out, { // TODO: optimize checks out.resize(start); - out += u8"«INVALID_ADDRESS:"; + out += reinterpret_cast(u8"«INVALID_ADDRESS:"); fmt_class_string::format(out, arg); - out += u8"»"; + out += reinterpret_cast(u8"»"); return; } @@ -1198,5 +1198,5 @@ void fmt_class_string>::format(std::string& out, } } - out += u8"”"; + out += reinterpret_cast(u8"”"); } diff --git a/rpcs3/Emu/RSX/Common/texture_cache.h b/rpcs3/Emu/RSX/Common/texture_cache.h index ab65f97b01..c917a0380d 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.h +++ b/rpcs3/Emu/RSX/Common/texture_cache.h @@ -346,8 +346,8 @@ namespace rsx m_cache_update_tag = rsx::get_shared_tag(); } - template - void emit_once(bool error, const char* fmt, const Args&... params) + template + void emit_once(bool error, const CharT(&fmt)[N], const Args&... params) { const auto result = m_once_only_messages_set.emplace(fmt::format(fmt, params...)); if (!result.second) @@ -359,14 +359,14 @@ namespace rsx rsx_log.warning("%s", *result.first); } - template - void err_once(const char* fmt, const Args&... params) + template + void err_once(const CharT(&fmt)[N], const Args&... params) { emit_once(true, fmt, params...); } - template - void warn_once(const char* fmt, const Args&... params) + template + void warn_once(const CharT(&fmt)[N], const Args&... params) { emit_once(false, fmt, params...); } diff --git a/rpcs3/Emu/RSX/rsx_cache.h b/rpcs3/Emu/RSX/rsx_cache.h index aa04facf78..bf650a8d1e 100644 --- a/rpcs3/Emu/RSX/rsx_cache.h +++ b/rpcs3/Emu/RSX/rsx_cache.h @@ -427,8 +427,7 @@ namespace rsx std::string get_message(u32 index, u32 processed, u32 entry_count) { - const char* text = index == 0 ? "Loading pipeline object %u of %u" : "Compiling pipeline object %u of %u"; - return fmt::format(text, processed, entry_count); + return fmt::format("%s pipeline object %u of %u", index == 0 ? "Loading" : "Compiling", processed, entry_count); }; void load_shaders(uint nb_workers, unpacked_type& unpacked, std::string& directory_path, std::vector& entries, u32 entry_count, diff --git a/rpcs3/Emu/VFS.cpp b/rpcs3/Emu/VFS.cpp index 81bc2db9a7..ea09c7b1e3 100644 --- a/rpcs3/Emu/VFS.cpp +++ b/rpcs3/Emu/VFS.cpp @@ -274,6 +274,12 @@ std::string vfs::get(std::string_view vpath, std::vector* out_dir, return std::string{result_base} + vfs::escape(fmt::merge(result, "/")); } +#if __cpp_char8_t >= 201811 +using char2 = char8_t; +#else +using char2 = char; +#endif + std::string vfs::escape(std::string_view path, bool escape_slash) { std::string result; @@ -281,7 +287,7 @@ std::string vfs::escape(std::string_view path, bool escape_slash) for (std::size_t i = 0, s = path.size(); i < s; i++) { - switch (char c = path[i]) + switch (char2 c = path[i]) { case 0: case 1: @@ -294,7 +300,7 @@ std::string vfs::escape(std::string_view path, bool escape_slash) case 8: case 9: { - result += u8"0"; + result += reinterpret_cast(u8"0"); result.back() += c; break; } @@ -321,85 +327,85 @@ std::string vfs::escape(std::string_view path, bool escape_slash) case 30: case 31: { - result += u8"A"; + result += reinterpret_cast(u8"A"); result.back() += c; result.back() -= 10; break; } case '<': { - result += u8"<"; + result += reinterpret_cast(u8"<"); break; } case '>': { - result += u8">"; + result += reinterpret_cast(u8">"); break; } case ':': { - result += u8":"; + result += reinterpret_cast(u8":"); break; } case '"': { - result += u8"""; + result += reinterpret_cast(u8"""); break; } case '\\': { - result += u8"\"; + result += reinterpret_cast(u8"\"); break; } case '|': { - result += u8"|"; + result += reinterpret_cast(u8"|"); break; } case '?': { - result += u8"?"; + result += reinterpret_cast(u8"?"); break; } case '*': { - result += u8"*"; + result += reinterpret_cast(u8"*"); break; } case '/': { if (escape_slash) { - result += u8"/"; + result += reinterpret_cast(u8"/"); break; } result += c; break; } - case char{u8"!"[0]}: + case char2{u8"!"[0]}: { // Escape full-width characters 0xFF01..0xFF5e with ! (0xFF01) - switch (path[i + 1]) + switch (char2 c2 = path[i + 1]) { - case char{u8"!"[1]}: + case char2{u8"!"[1]}: { - const uchar c3 = reinterpret_cast(path[i + 2]); + const uchar c3 = path[i + 2]; if (c3 >= 0x81 && c3 <= 0xbf) { - result += u8"!"; + result += reinterpret_cast(u8"!"); } break; } - case char{u8"`"[1]}: + case char2{u8"`"[1]}: { - const uchar c3 = reinterpret_cast(path[i + 2]); + const uchar c3 = path[i + 2]; if (c3 >= 0x80 && c3 <= 0x9e) { - result += u8"!"; + result += reinterpret_cast(u8"!"); } break; @@ -427,105 +433,105 @@ std::string vfs::unescape(std::string_view path) for (std::size_t i = 0, s = path.size(); i < s; i++) { - switch (char c = path[i]) + switch (char2 c = path[i]) { - case char{u8"!"[0]}: + case char2{u8"!"[0]}: { - switch (path[i + 1]) + switch (char2 c2 = path[i + 1]) { - case char{u8"!"[1]}: + case char2{u8"!"[1]}: { - const uchar c3 = reinterpret_cast(path[i + 2]); + const uchar c3 = path[i + 2]; if (c3 >= 0x81 && c3 <= 0xbf) { - switch (path[i + 2]) + switch (static_cast(c3)) { - case char{u8"0"[2]}: - case char{u8"1"[2]}: - case char{u8"2"[2]}: - case char{u8"3"[2]}: - case char{u8"4"[2]}: - case char{u8"5"[2]}: - case char{u8"6"[2]}: - case char{u8"7"[2]}: - case char{u8"8"[2]}: - case char{u8"9"[2]}: + case char2{u8"0"[2]}: + case char2{u8"1"[2]}: + case char2{u8"2"[2]}: + case char2{u8"3"[2]}: + case char2{u8"4"[2]}: + case char2{u8"5"[2]}: + case char2{u8"6"[2]}: + case char2{u8"7"[2]}: + case char2{u8"8"[2]}: + case char2{u8"9"[2]}: { result += path[i + 2]; result.back() -= u8"0"[2]; continue; } - case char{u8"A"[2]}: - case char{u8"B"[2]}: - case char{u8"C"[2]}: - case char{u8"D"[2]}: - case char{u8"E"[2]}: - case char{u8"F"[2]}: - case char{u8"G"[2]}: - case char{u8"H"[2]}: - case char{u8"I"[2]}: - case char{u8"J"[2]}: - case char{u8"K"[2]}: - case char{u8"L"[2]}: - case char{u8"M"[2]}: - case char{u8"N"[2]}: - case char{u8"O"[2]}: - case char{u8"P"[2]}: - case char{u8"Q"[2]}: - case char{u8"R"[2]}: - case char{u8"S"[2]}: - case char{u8"T"[2]}: - case char{u8"U"[2]}: - case char{u8"V"[2]}: + case char2{u8"A"[2]}: + case char2{u8"B"[2]}: + case char2{u8"C"[2]}: + case char2{u8"D"[2]}: + case char2{u8"E"[2]}: + case char2{u8"F"[2]}: + case char2{u8"G"[2]}: + case char2{u8"H"[2]}: + case char2{u8"I"[2]}: + case char2{u8"J"[2]}: + case char2{u8"K"[2]}: + case char2{u8"L"[2]}: + case char2{u8"M"[2]}: + case char2{u8"N"[2]}: + case char2{u8"O"[2]}: + case char2{u8"P"[2]}: + case char2{u8"Q"[2]}: + case char2{u8"R"[2]}: + case char2{u8"S"[2]}: + case char2{u8"T"[2]}: + case char2{u8"U"[2]}: + case char2{u8"V"[2]}: { result += path[i + 2]; result.back() -= u8"A"[2]; result.back() += 10; continue; } - case char{u8"!"[2]}: + case char2{u8"!"[2]}: { i += 3; result += c; continue; } - case char{u8"<"[2]}: + case char2{u8"<"[2]}: { result += '<'; break; } - case char{u8">"[2]}: + case char2{u8">"[2]}: { result += '>'; break; } - case char{u8":"[2]}: + case char2{u8":"[2]}: { result += ':'; break; } - case char{u8"""[2]}: + case char2{u8"""[2]}: { result += '"'; break; } - case char{u8"\"[2]}: + case char2{u8"\"[2]}: { result += '\\'; break; } - case char{u8"?"[2]}: + case char2{u8"?"[2]}: { result += '?'; break; } - case char{u8"*"[2]}: + case char2{u8"*"[2]}: { result += '*'; break; } - case char{u8"$"[2]}: + case char2{u8"$"[2]}: { if (i == 0) { @@ -552,15 +558,15 @@ std::string vfs::unescape(std::string_view path) break; } - case char{u8"`"[1]}: + case char2{u8"`"[1]}: { - const uchar c3 = reinterpret_cast(path[i + 2]); + const uchar c3 = path[i + 2]; if (c3 >= 0x80 && c3 <= 0x9e) { - switch (path[i + 2]) + switch (static_cast(c3)) { - case char{u8"|"[2]}: + case char2{u8"|"[2]}: { result += '|'; break; diff --git a/rpcs3/rpcs3qt/rsx_debugger.cpp b/rpcs3/rpcs3qt/rsx_debugger.cpp index c684cb87ff..f575fb2c57 100644 --- a/rpcs3/rpcs3qt/rsx_debugger.cpp +++ b/rpcs3/rpcs3qt/rsx_debugger.cpp @@ -868,7 +868,7 @@ QString rsx_debugger::DisAsmCommand(u32 cmd, u32 count, u32 ioAddr) break; case NV4097_SET_DEPTH_BOUNDS_TEST_ENABLE: - DISASM(args[0] ? "Depth bounds test: Enable" : "Depth bounds test: Disable"); + DISASM("Depth bounds test: %s", args[0] ? "Enable" : "Disable"); break; default: { diff --git a/rpcs3/rpcs3qt/settings_dialog.cpp b/rpcs3/rpcs3qt/settings_dialog.cpp index c0c8e50a18..65253ba6f2 100644 --- a/rpcs3/rpcs3qt/settings_dialog.cpp +++ b/rpcs3/rpcs3qt/settings_dialog.cpp @@ -951,7 +951,7 @@ settings_dialog::settings_dialog(std::shared_ptr guiSettings, std: // Sliders - EnhanceSlider(emu_settings::DriverWakeUpDelay, ui->wakeupDelay, ui->wakeupText, tr(u8"%0 µs")); + EnhanceSlider(emu_settings::DriverWakeUpDelay, ui->wakeupDelay, ui->wakeupText, tr(reinterpret_cast(u8"%0 µs"))); SnapSlider(ui->wakeupDelay, 200); ui->wakeupDelay->setMaximum(7000); // Very large values must be entered with config.yml changes ui->wakeupDelay->setPageStep(200); diff --git a/rpcs3/util/shared_cptr.hpp b/rpcs3/util/shared_cptr.hpp index 6f75abc1ba..8defb45b8a 100644 --- a/rpcs3/util/shared_cptr.hpp +++ b/rpcs3/util/shared_cptr.hpp @@ -330,7 +330,7 @@ namespace stx { // Return data if reference count became zero pdata->m_ref_count = cb::c_ref_init; - return unique_data(pdata); + return unique_data(pdata); } } diff --git a/rpcs3_default.props b/rpcs3_default.props index 127f956c74..d0e8ec4df1 100644 --- a/rpcs3_default.props +++ b/rpcs3_default.props @@ -19,7 +19,7 @@ false true NotUsing - /Zc:throwingNew -d2FH4- %(AdditionalOptions) + /std:c++latest /Zc:throwingNew -d2FH4- %(AdditionalOptions) xxhash.lib;ws2_32.lib;Bcrypt.lib;avcodec.lib;avformat.lib;avutil.lib;swresample.lib;swscale.lib