diff --git a/Utilities/AutoPause.cpp b/Utilities/AutoPause.cpp index 8ef5af6627..a6c1cabfc6 100644 --- a/Utilities/AutoPause.cpp +++ b/Utilities/AutoPause.cpp @@ -7,17 +7,16 @@ using namespace Debug; -//Even different from those tutorials on webpages, i use the method similiar from Log.h -//TODO:: Question: Does such a Singleton struct get fully deallocated after its pointer? -AutoPause* gAutoPause = nullptr; +std::unique_ptr g_autopause; AutoPause& AutoPause::getInstance(void) { - if (!gAutoPause) + if (!g_autopause) { - gAutoPause = new AutoPause(); + g_autopause.reset(new AutoPause); } - return *gAutoPause; + + return *g_autopause; } //Still use binary format. Default Setting should be "disable all auto pause". diff --git a/Utilities/File.cpp b/Utilities/File.cpp index f922c4e732..b11e115d81 100644 --- a/Utilities/File.cpp +++ b/Utilities/File.cpp @@ -20,6 +20,7 @@ std::unique_ptr ConvertUTF8ToWChar(const std::string& source) if (!MultiByteToWideChar(CP_UTF8, 0, source.c_str(), size, buffer.get(), size)) { LOG_ERROR(GENERAL, "ConvertUTF8ToWChar(source='%s') failed: 0x%llx", source, GET_API_ERROR); + throw __FUNCTION__; } return buffer; @@ -27,17 +28,28 @@ std::unique_ptr ConvertUTF8ToWChar(const std::string& source) std::string ConvertWCharToUTF8(const wchar_t* source) { - const int size = WideCharToMultiByte(CP_UTF8, 0, source, -1 /* NTS */, NULL, 0, NULL, NULL); // size - - if (size < 1) throw std::length_error(__FUNCTION__); // ??? + const int length = lstrlenW(source); // source length std::string result; - result.resize(size - 1); - - if (!WideCharToMultiByte(CP_UTF8, 0, source, -1 /* NTS */, &result.front(), size, NULL, NULL)) + if (length == 0) { - LOG_ERROR(GENERAL, "ConvertWCharToUTF8() failed: 0x%llx", GET_API_ERROR); + return result; + } + + const int size = WideCharToMultiByte(CP_UTF8, 0, source, length, NULL, 0, NULL, NULL); // output size + + if (size <= 0) + { + LOG_ERROR(GENERAL, "ConvertWCharToUTF8(length=%d) failed: 0x%llx", length, GET_API_ERROR); + throw __FUNCTION__; + } + + result.resize(size); + + if (!WideCharToMultiByte(CP_UTF8, 0, source, length, &result.front(), size, NULL, NULL)) + { + throw __FUNCTION__; } return result; diff --git a/rpcs3/Emu/ARMv7/ARMv7Thread.cpp b/rpcs3/Emu/ARMv7/ARMv7Thread.cpp index 564dd59e02..90a56e2187 100644 --- a/rpcs3/Emu/ARMv7/ARMv7Thread.cpp +++ b/rpcs3/Emu/ARMv7/ARMv7Thread.cpp @@ -258,7 +258,7 @@ cpu_thread& armv7_thread::args(std::initializer_list values) for (auto& arg : values) { - const u32 arg_size = vm::cast(arg.size(), "arg.size()"); // get arg size + const u32 arg_size = arg.size(); // get arg size for (char c : arg) { diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index 477001c8ec..6176add701 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -369,7 +369,7 @@ void SPUThread::do_dma_list_cmd(u32 cmd, spu_mfc_arg_t args) if (rec->sb.data() & se16(0x8000)) { - ch_stall_stat.push_logical_or(1 << args.tag); + ch_stall_stat.push_bit_or(1 << args.tag); spu_mfc_arg_t stalled; stalled.ea = (args.ea & ~0xffffffff) | (list_addr + (i + 1) * 8); diff --git a/rpcs3/Emu/Cell/SPUThread.h b/rpcs3/Emu/Cell/SPUThread.h index 0156139f09..15045ebb6c 100644 --- a/rpcs3/Emu/Cell/SPUThread.h +++ b/rpcs3/Emu/Cell/SPUThread.h @@ -156,7 +156,7 @@ public: return out_result; } - void push_logical_or(u32 value) + void push_bit_or(u32 value) { sync_var._or({ 1, value }); } @@ -550,7 +550,7 @@ public: { if (snr_config & 1) { - ch_snr1.push_logical_or(value); + ch_snr1.push_bit_or(value); } else { @@ -561,7 +561,7 @@ public: { if (snr_config & 2) { - ch_snr2.push_logical_or(value); + ch_snr2.push_bit_or(value); } else { diff --git a/rpcs3/Emu/Memory/vm.h b/rpcs3/Emu/Memory/vm.h index 41f0f825b8..3447db2b48 100644 --- a/rpcs3/Emu/Memory/vm.h +++ b/rpcs3/Emu/Memory/vm.h @@ -103,19 +103,6 @@ namespace vm } }; -#ifdef __APPLE__ - template<> - struct cast_ptr - { - static_assert(sizeof(unsigned long) == 8, "Unexpected size of unsigned long"); - - __forceinline static u32 cast(const unsigned long addr, const char* func) - { - return cast_ptr::cast(addr, func); - } - }; -#endif - template<> struct cast_ptr { diff --git a/rpcs3/Emu/RSX/CgBinaryFragmentProgram.cpp b/rpcs3/Emu/RSX/CgBinaryFragmentProgram.cpp index 9dfa408786..c7c82a42e8 100644 --- a/rpcs3/Emu/RSX/CgBinaryFragmentProgram.cpp +++ b/rpcs3/Emu/RSX/CgBinaryFragmentProgram.cpp @@ -138,14 +138,14 @@ std::string CgBinaryDisasm::FormatDisAsm(const std::string& code) { const std::pair> repl_list[] = { - { "$$", []() -> std::string { return "$"; } }, - { "$0", std::bind(std::mem_fn(&CgBinaryDisasm::GetSrcDisAsm), this, src0) }, - { "$1", std::bind(std::mem_fn(&CgBinaryDisasm::GetSrcDisAsm), this, src1) }, - { "$2", std::bind(std::mem_fn(&CgBinaryDisasm::GetSrcDisAsm), this, src2) }, - { "$t", std::bind(std::mem_fn(&CgBinaryDisasm::AddTexDisAsm), this) }, - { "$m", std::bind(std::mem_fn(&CgBinaryDisasm::GetMask), this) }, - { "$cond", std::bind(std::mem_fn(&CgBinaryDisasm::GetCondDisAsm), this) }, - { "$c", std::bind(std::mem_fn(&CgBinaryDisasm::AddConstDisAsm), this) } + { "$$", []() -> std::string { return "$"; } }, + { "$0", [this]{ return GetSrcDisAsm(src0); } }, + { "$1", [this]{ return GetSrcDisAsm(src1); } }, + { "$2", [this]{ return GetSrcDisAsm(src2); } }, + { "$t", [this]{ return AddTexDisAsm(); } }, + { "$m", [this]{ return GetMask(); } }, + { "$cond", [this]{ return GetCondDisAsm(); } }, + { "$c", [this]{ return AddConstDisAsm(); } }, }; return fmt::replace_all(code, repl_list); @@ -241,27 +241,27 @@ void CgBinaryDisasm::TaskFP() while (true) { - for (auto finded = std::find(m_end_offsets.begin(), m_end_offsets.end(), m_size); - finded != m_end_offsets.end(); - finded = std::find(m_end_offsets.begin(), m_end_offsets.end(), m_size)) + for (auto found = std::find(m_end_offsets.begin(), m_end_offsets.end(), m_size); + found != m_end_offsets.end(); + found = std::find(m_end_offsets.begin(), m_end_offsets.end(), m_size)) { - m_end_offsets.erase(finded); + m_end_offsets.erase(found); m_arb_shader += "ENDIF;\n"; } - for (auto finded = std::find(m_loop_end_offsets.begin(), m_loop_end_offsets.end(), m_size); - finded != m_loop_end_offsets.end(); - finded = std::find(m_loop_end_offsets.begin(), m_loop_end_offsets.end(), m_size)) + for (auto found = std::find(m_loop_end_offsets.begin(), m_loop_end_offsets.end(), m_size); + found != m_loop_end_offsets.end(); + found = std::find(m_loop_end_offsets.begin(), m_loop_end_offsets.end(), m_size)) { - m_loop_end_offsets.erase(finded); + m_loop_end_offsets.erase(found); m_arb_shader += "ENDLOOP;\n"; } - for (auto finded = std::find(m_else_offsets.begin(), m_else_offsets.end(), m_size); - finded != m_else_offsets.end(); - finded = std::find(m_else_offsets.begin(), m_else_offsets.end(), m_size)) + for (auto found = std::find(m_else_offsets.begin(), m_else_offsets.end(), m_size); + found != m_else_offsets.end(); + found = std::find(m_else_offsets.begin(), m_else_offsets.end(), m_size)) { - m_else_offsets.erase(finded); + m_else_offsets.erase(found); m_arb_shader += "ELSE;\n"; } diff --git a/rpcs3/Emu/RSX/CgBinaryVertexProgram.cpp b/rpcs3/Emu/RSX/CgBinaryVertexProgram.cpp index db60c95588..cd71979263 100644 --- a/rpcs3/Emu/RSX/CgBinaryVertexProgram.cpp +++ b/rpcs3/Emu/RSX/CgBinaryVertexProgram.cpp @@ -174,23 +174,25 @@ std::string CgBinaryDisasm::FormatDisasm(const std::string& code) { const std::pair> repl_list[] = { - { "$$", []() -> std::string { return "$"; } }, - { "$0", std::bind(std::mem_fn(&CgBinaryDisasm::GetSRCDisasm), this, 0) }, - { "$1", std::bind(std::mem_fn(&CgBinaryDisasm::GetSRCDisasm), this, 1) }, - { "$2", std::bind(std::mem_fn(&CgBinaryDisasm::GetSRCDisasm), this, 2) }, - { "$s", std::bind(std::mem_fn(&CgBinaryDisasm::GetSRCDisasm), this, 2) }, - { "$am", std::bind(std::mem_fn(&CgBinaryDisasm::AddAddrMaskDisasm), this) }, - { "$a", std::bind(std::mem_fn(&CgBinaryDisasm::AddAddrRegDisasm), this) }, - { "$t", std::bind(std::mem_fn(&CgBinaryDisasm::GetTexDisasm), this) }, - { "$fa", [this]()->std::string { return std::to_string(GetAddrDisasm()); } }, - { "$ifcond ", [this]() -> std::string + { "$$", []() -> std::string { return "$"; } }, + { "$0", [this]{ return GetSRCDisasm(0); } }, + { "$1", [this]{ return GetSRCDisasm(1); } }, + { "$2", [this]{ return GetSRCDisasm(2); } }, + { "$s", [this]{ return GetSRCDisasm(2); } }, + { "$am", [this]{ return AddAddrMaskDisasm(); } }, + { "$a", [this]{ return AddAddrRegDisasm(); } }, + { "$t", [this]{ return GetTexDisasm(); } }, + { "$fa", [this]{ return std::to_string(GetAddrDisasm()); } }, + + { "$ifcond ", [this] { - const std::string& cond = GetCondDisasm(); - if (cond == "true") return ""; + std::string cond = GetCondDisasm(); + if (cond == "true") cond.clear(); return cond; } }, - { "$cond", std::bind(std::mem_fn(&CgBinaryDisasm::GetCondDisasm), this) } + + { "$cond", [this]{ return GetCondDisasm(); } }, }; return fmt::replace_all(code, repl_list); diff --git a/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp b/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp index 6802796d3a..ae1ea0b308 100644 --- a/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp +++ b/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp @@ -124,11 +124,12 @@ std::string GLFragmentDecompilerThread::Format(const std::string& code) const std::pair> repl_list[] = { { "$$", []() -> std::string { return "$"; } }, - { "$0", std::bind(std::mem_fn(&GLFragmentDecompilerThread::GetSRC), this, src0) }, - { "$1", std::bind(std::mem_fn(&GLFragmentDecompilerThread::GetSRC), this, src1) }, - { "$2", std::bind(std::mem_fn(&GLFragmentDecompilerThread::GetSRC), this, src2) }, - { "$t", std::bind(std::mem_fn(&GLFragmentDecompilerThread::AddTex), this) }, - { "$m", std::bind(std::mem_fn(&GLFragmentDecompilerThread::GetMask), this) }, + { "$0", [this]{ return GetSRC(src0); } }, + { "$1", [this]{ return GetSRC(src1); } }, + { "$2", [this]{ return GetSRC(src2); } }, + { "$t", [this]{ return AddTex(); } }, + { "$m", [this]{ return GetMask(); } }, + { "$ifcond ", [this]() -> std::string { const std::string& cond = GetCond(); @@ -136,8 +137,9 @@ std::string GLFragmentDecompilerThread::Format(const std::string& code) return "if(" + cond + ") "; } }, - { "$cond", std::bind(std::mem_fn(&GLFragmentDecompilerThread::GetCond), this) }, - { "$c", std::bind(std::mem_fn(&GLFragmentDecompilerThread::AddConst), this) } + + { "$cond", [this]{ return GetCond(); } }, + { "$c", [this]{ return AddConst(); } } }; return fmt::replace_all(code, repl_list); @@ -375,21 +377,21 @@ void GLFragmentDecompilerThread::Task() while (true) { - for (auto finded = std::find(m_end_offsets.begin(), m_end_offsets.end(), m_size); - finded != m_end_offsets.end(); - finded = std::find(m_end_offsets.begin(), m_end_offsets.end(), m_size)) + for (auto found = std::find(m_end_offsets.begin(), m_end_offsets.end(), m_size); + found != m_end_offsets.end(); + found = std::find(m_end_offsets.begin(), m_end_offsets.end(), m_size)) { - m_end_offsets.erase(finded); + m_end_offsets.erase(found); m_code_level--; AddCode("}"); m_loop_count--; } - for (auto finded = std::find(m_else_offsets.begin(), m_else_offsets.end(), m_size); - finded != m_else_offsets.end(); - finded = std::find(m_else_offsets.begin(), m_else_offsets.end(), m_size)) + for (auto found = std::find(m_else_offsets.begin(), m_else_offsets.end(), m_size); + found != m_else_offsets.end(); + found = std::find(m_else_offsets.begin(), m_else_offsets.end(), m_size)) { - m_else_offsets.erase(finded); + m_else_offsets.erase(found); m_code_level--; AddCode("}"); AddCode("else"); diff --git a/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp b/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp index 7f74b7b6cd..ecada28746 100644 --- a/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp +++ b/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp @@ -195,18 +195,17 @@ std::string GLVertexDecompilerThread::Format(const std::string& code) { const std::pair> repl_list[] = { - { "$$", []() -> std::string { return "$"; } }, - { "$0", std::bind(std::mem_fn(&GLVertexDecompilerThread::GetSRC), this, 0) }, - { "$1", std::bind(std::mem_fn(&GLVertexDecompilerThread::GetSRC), this, 1) }, - { "$2", std::bind(std::mem_fn(&GLVertexDecompilerThread::GetSRC), this, 2) }, - { "$s", std::bind(std::mem_fn(&GLVertexDecompilerThread::GetSRC), this, 2) }, - { "$am", std::bind(std::mem_fn(&GLVertexDecompilerThread::AddAddrMask), this) }, - { "$a", std::bind(std::mem_fn(&GLVertexDecompilerThread::AddAddrReg), this) }, + { "$$", []() -> std::string { return "$"; } }, + { "$0", [this]{ return GetSRC(0); } }, + { "$1", [this]{ return GetSRC(1); } }, + { "$2", [this]{ return GetSRC(2); } }, + { "$s", [this]{ return GetSRC(2); } }, + { "$am", [this]{ return AddAddrMask(); } }, + { "$a", [this]{ return AddAddrReg(); } }, + { "$t", [this]{ return GetTex(); } }, + { "$fa", [this]{ return std::to_string(GetAddr()); } }, + { "$f()", [this]{ return GetFunc(); } }, - { "$t", std::bind(std::mem_fn(&GLVertexDecompilerThread::GetTex), this) }, - - { "$fa", [this]()->std::string { return std::to_string(GetAddr()); } }, - { "$f()", std::bind(std::mem_fn(&GLVertexDecompilerThread::GetFunc), this) }, { "$ifcond ", [this]() -> std::string { const std::string& cond = GetCond(); @@ -214,7 +213,8 @@ std::string GLVertexDecompilerThread::Format(const std::string& code) return "if(" + cond + ") "; } }, - { "$cond", std::bind(std::mem_fn(&GLVertexDecompilerThread::GetCond), this) } + + { "$cond", [this]{ return GetCond(); } } }; return fmt::replace_all(code, repl_list); diff --git a/rpcs3/Emu/SysCalls/Modules/cellFs.cpp b/rpcs3/Emu/SysCalls/Modules/cellFs.cpp index 1c628b03d6..daadb68b59 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellFs.cpp @@ -598,10 +598,10 @@ s32 cellFsStRead(u32 fd, vm::ptr buf, u64 size, vm::ptr rsize) const u64 copied = file->st_copied.load(); const u32 position = vm::cast(file->st_buffer + copied % file->st_ringbuf_size); const u64 total_read = file->st_total_read.load(); - const u32 copy_size = vm::cast(*rsize = std::min(size, total_read - copied)); + const u64 copy_size = (*rsize = std::min(size, total_read - copied)); // write rsize // copy data - const u32 first_size = std::min(copy_size, file->st_ringbuf_size - (position - file->st_buffer)); + const u64 first_size = std::min(copy_size, file->st_ringbuf_size - (position - file->st_buffer)); memcpy(buf.get_ptr(), vm::get_ptr(position), first_size); memcpy((buf + first_size).get_ptr(), vm::get_ptr(file->st_buffer), copy_size - first_size); @@ -723,7 +723,7 @@ s32 cellFsStReadWaitCallback(u32 fd, u64 size, fs_st_cb_t func) return CELL_FS_ENXIO; } - if (!file->st_callback.compare_and_swap_test({}, { vm::cast(size, "size"), func })) + if (!file->st_callback.compare_and_swap_test({}, { size, func })) { return CELL_FS_EIO; } @@ -940,7 +940,7 @@ s32 cellFsAioRead(vm::ptr aio, vm::ptr id, fs_aio_cb_t func) const s32 xid = (*id = ++g_fs_aio_id); - thread_t("FS AIO Read Thread", std::bind(fsAio, aio, false, xid, func)).detach(); + thread_t("FS AIO Read Thread", [=]{ fsAio(aio, false, xid, func); }).detach(); return CELL_OK; } @@ -958,7 +958,7 @@ s32 cellFsAioWrite(vm::ptr aio, vm::ptr id, fs_aio_cb_t func) const s32 xid = (*id = ++g_fs_aio_id); - thread_t("FS AIO Write Thread", std::bind(fsAio, aio, true, xid, func)).detach(); + thread_t("FS AIO Write Thread", [=]{ fsAio(aio, true, xid, func); }).detach(); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp b/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp index f65a751ff4..a2f2cd8860 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp @@ -19,51 +19,6 @@ SaveDataDialogInstance::SaveDataDialogInstance() { } -// Auxiliary Classes -class SortSaveDataEntry -{ - const u32 m_type; - const u32 m_order; - -public: - SortSaveDataEntry(u32 type, u32 order) - : m_type(type) - , m_order(order) - { - } - - bool operator()(const SaveDataEntry& entry1, const SaveDataEntry& entry2) const - { - if (m_order == CELL_SAVEDATA_SORTORDER_DESCENT) - { - if (m_type == CELL_SAVEDATA_SORTTYPE_MODIFIEDTIME) - { - return entry1.mtime >= entry2.mtime; - } - - if (m_type == CELL_SAVEDATA_SORTTYPE_SUBTITLE) - { - return entry1.subtitle >= entry2.subtitle; - } - } - - if (m_order == CELL_SAVEDATA_SORTORDER_ASCENT) - { - if (m_type == CELL_SAVEDATA_SORTTYPE_MODIFIEDTIME) - { - return entry1.mtime < entry2.mtime; - } - - if (m_type == CELL_SAVEDATA_SORTTYPE_SUBTITLE) - { - return entry1.subtitle < entry2.subtitle; - } - } - - return true; - } -}; - enum : u32 { SAVEDATA_OP_AUTO_SAVE = 0, @@ -182,7 +137,37 @@ __noinline s32 savedata_op( } // Sort the entries - std::sort(save_entries.begin(), save_entries.end(), SortSaveDataEntry(setList->sortType, setList->sortOrder)); + { + const u32 order = setList->sortOrder; + const u32 type = setList->sortType; + + if (order > CELL_SAVEDATA_SORTORDER_ASCENT || type > CELL_SAVEDATA_SORTTYPE_SUBTITLE) + { + // error + } + + std::sort(save_entries.begin(), save_entries.end(), [=](const SaveDataEntry& entry1, const SaveDataEntry& entry2) + { + if (order == CELL_SAVEDATA_SORTORDER_DESCENT && type == CELL_SAVEDATA_SORTTYPE_MODIFIEDTIME) + { + return entry1.mtime >= entry2.mtime; + } + if (order == CELL_SAVEDATA_SORTORDER_DESCENT && type == CELL_SAVEDATA_SORTTYPE_SUBTITLE) + { + return entry1.subtitle >= entry2.subtitle; + } + if (order == CELL_SAVEDATA_SORTORDER_ASCENT && type == CELL_SAVEDATA_SORTTYPE_MODIFIEDTIME) + { + return entry1.mtime < entry2.mtime; + } + if (order == CELL_SAVEDATA_SORTORDER_ASCENT && type == CELL_SAVEDATA_SORTTYPE_SUBTITLE) + { + return entry1.subtitle < entry2.subtitle; + } + + return true; + }); + } // Fill the listGet->dirList array auto dir_list = listGet->dirList.get_ptr(); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp index ad0fed3b11..f3e233a314 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp @@ -1025,8 +1025,10 @@ s32 syncLFQueueGetPushPointer(vm::ptr queue, s32& pointer, u32 return CELL_SYNC_ERROR_PERM; } + const s32 depth = queue->m_depth; + u32 var1 = 0; - s32 depth = queue->m_depth; + while (true) { while (true) @@ -1149,7 +1151,7 @@ s32 syncLFQueueCompletePushPointer(vm::ptr queue, s32 pointer, return CELL_SYNC_ERROR_PERM; } - s32 depth = (u32)queue->m_depth; + const s32 depth = queue->m_depth; while (true) { @@ -1343,8 +1345,8 @@ s32 _cellSyncLFQueuePushBody(PPUThread& CPU, vm::ptr queue, vm: } } - const s32 depth = (u32)queue->m_depth; - const s32 size = (u32)queue->m_size; + const s32 depth = queue->m_depth; + const s32 size = queue->m_size; const u32 addr = vm::cast((queue->m_buffer.addr() & ~1ull) + size * (position >= depth ? position - depth : position)); memcpy(vm::get_ptr(addr), buffer.get_ptr(), size); @@ -1369,8 +1371,10 @@ s32 syncLFQueueGetPopPointer(vm::ptr queue, s32& pointer, u32 i return CELL_SYNC_ERROR_PERM; } + const s32 depth = queue->m_depth; + u32 var1 = 0; - s32 depth = (u32)queue->m_depth; + while (true) { while (true) @@ -1493,7 +1497,7 @@ s32 syncLFQueueCompletePopPointer(vm::ptr queue, s32 pointer, c return CELL_SYNC_ERROR_PERM; } - s32 depth = (u32)queue->m_depth; + const s32 depth = queue->m_depth; while (true) { @@ -1686,8 +1690,8 @@ s32 _cellSyncLFQueuePopBody(PPUThread& CPU, vm::ptr queue, vm:: } } - const s32 depth = (u32)queue->m_depth; - const s32 size = (u32)queue->m_size; + const s32 depth = queue->m_depth; + const s32 size = queue->m_size; const u32 addr = vm::cast((queue->m_buffer.addr() & ~1) + size * (position >= depth ? position - depth : position)); memcpy(buffer.get_ptr(), vm::get_ptr(addr), size); @@ -1807,9 +1811,9 @@ s32 cellSyncLFQueueDepth(vm::ptr queue, vm::ptr depth) return CELL_OK; } -s32 _cellSyncLFQueueGetSignalAddress(vm::ptr queue, vm::ptr ppSignal) +s32 _cellSyncLFQueueGetSignalAddress(vm::ptr queue, vm::ptr> ppSignal) { - cellSync.Log("_cellSyncLFQueueGetSignalAddress(queue=*0x%x, ppSignal=*0x%x)", queue, ppSignal); + cellSync.Log("_cellSyncLFQueueGetSignalAddress(queue=*0x%x, ppSignal=**0x%x)", queue, ppSignal); if (!queue || !ppSignal) { @@ -1820,7 +1824,8 @@ s32 _cellSyncLFQueueGetSignalAddress(vm::ptr queue, vm::p return CELL_SYNC_ERROR_ALIGN; } - *ppSignal = (u32)queue->m_eaSignal.addr(); + *ppSignal = queue->m_eaSignal; + return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/lv2/sys_cond.cpp b/rpcs3/Emu/SysCalls/lv2/sys_cond.cpp index 6dab5c62b4..ca179cf27e 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_cond.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_cond.cpp @@ -108,7 +108,7 @@ s32 sys_cond_signal_all(u32 cond_id) return CELL_ESRCH; } - if (const u32 count = vm::cast(cond->waiters.size())) + if (const u32 count = cond->waiters.size()) { cond->signaled += count; cond->waiters.clear(); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_lwcond.cpp b/rpcs3/Emu/SysCalls/lv2/sys_lwcond.cpp index 5c20d92f56..91889c9965 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_lwcond.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_lwcond.cpp @@ -135,7 +135,7 @@ s32 _sys_lwcond_signal_all(u32 lwcond_id, u32 lwmutex_id, u32 mode) sys_lwcond.Error("_sys_lwcond_signal_all(%d): invalid mode (%d)", lwcond_id, mode); } - const u32 count = vm::cast(cond->waiters.size()); + const u32 count = cond->waiters.size(); if (count) { diff --git a/rpcs3/Loader/ELF64.cpp b/rpcs3/Loader/ELF64.cpp index cd2e8a2fc2..32fd0706fa 100644 --- a/rpcs3/Loader/ELF64.cpp +++ b/rpcs3/Loader/ELF64.cpp @@ -577,7 +577,7 @@ namespace loader { if (phdr.p_memsz) { - if (!vm::alloc(vm::cast(phdr.p_vaddr.addr()), vm::cast(phdr.p_memsz, "phdr.p_memsz"), vm::main)) + if (!vm::alloc(phdr.p_vaddr.addr(), phdr.p_memsz, vm::main)) { LOG_ERROR(LOADER, "%s(): AllocFixed(0x%llx, 0x%llx) failed", __FUNCTION__, phdr.p_vaddr.addr(), phdr.p_memsz); @@ -606,7 +606,7 @@ namespace loader { m_stream->Seek(handler::get_stream_offset() + phdr.p_offset); m_stream->Read(phdr.p_vaddr.get_ptr(), phdr.p_filesz); - hook_ppu_funcs(vm::ptr::make(phdr.p_vaddr.addr()), vm::cast(phdr.p_filesz) / 4); + hook_ppu_funcs(vm::ptr::make(phdr.p_vaddr.addr()), phdr.p_filesz / 4); } } break; @@ -614,10 +614,7 @@ namespace loader case 0x00000007: //TLS { - Emu.SetTLSData( - vm::cast(phdr.p_vaddr.addr(), "TLS: phdr.p_vaddr"), - vm::cast(phdr.p_filesz.value(), "TLS: phdr.p_filesz"), - vm::cast(phdr.p_memsz.value(), "TLS: phdr.p_memsz")); + Emu.SetTLSData(phdr.p_vaddr.addr(), phdr.p_filesz, phdr.p_memsz); break; }