From fe26db4d363aaa4b0ef659d67579c421aaccef5e Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Sat, 4 Feb 2017 18:09:02 +0300 Subject: [PATCH] idm::last_id cleanup --- rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp | 6 +----- rpcs3/Emu/Cell/lv2/sys_fs.cpp | 28 ++++++++++---------------- rpcs3/Emu/Cell/lv2/sys_fs.h | 7 ++----- rpcs3/Emu/Cell/lv2/sys_prx.cpp | 10 ++------- rpcs3/Emu/Cell/lv2/sys_prx.h | 4 ---- 5 files changed, 16 insertions(+), 39 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp b/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp index 753d6dd1c1..aa2763aec7 100644 --- a/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp @@ -22,8 +22,6 @@ struct trophy_context_t static const u32 id_step = 1; static const u32 id_count = 1023; - const u32 id = idm::last_id(); - std::string trp_name; fs::file trp_stream; std::unique_ptr tropusr; @@ -34,8 +32,6 @@ struct trophy_handle_t static const u32 id_base = 1; static const u32 id_step = 1; static const u32 id_count = 1023; - - const u32 id = idm::last_id(); }; // Functions @@ -125,7 +121,7 @@ s32 sceNpTrophyCreateContext(vm::ptr context, vm::cptrtrp_name = std::move(name); ctxt->trp_stream = std::move(stream); - *context = ctxt->id; + *context = idm::last_id(); return CELL_OK; } diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.cpp b/rpcs3/Emu/Cell/lv2/sys_fs.cpp index bbae77629f..51e52a035a 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_fs.cpp @@ -4,6 +4,7 @@ #include #include "Emu/VFS.h" +#include "Emu/IdManager.h" #include "Utilities/StrUtil.h" namespace vm { using namespace ps3; } @@ -143,17 +144,14 @@ error_code sys_fs_open(vm::cptr path, s32 flags, vm::ptr fd, s32 mode return CELL_ENOENT; } - const auto _file = idm::make_ptr(path.get_ptr(), std::move(file), mode, flags); - - if (!_file) + if (const u32 id = idm::make(path.get_ptr(), std::move(file), mode, flags)) { - // out of file descriptors - return CELL_EMFILE; + *fd = id; + return CELL_OK; } - *fd = _file->id; - - return CELL_OK; + // Out of file descriptors + return CELL_EMFILE; } error_code sys_fs_read(u32 fd, vm::ptr buf, u64 nbytes, vm::ptr nread) @@ -245,18 +243,14 @@ error_code sys_fs_opendir(vm::cptr path, vm::ptr fd) return CELL_ENOENT; } - const auto _dir = idm::make_ptr(path.get_ptr(), std::move(dir)); - - if (!_dir) + if (const u32 id = idm::make(path.get_ptr(), std::move(dir))) { - // out of file descriptors - return CELL_EMFILE; + *fd = id; + return CELL_OK; } - *fd = _dir->id; - sys_fs.notice("sys_fs_opendir(%s) -> lv2_fs_id %d", path, _dir->id); - - return CELL_OK; + // Out of file descriptors + return CELL_EMFILE; } error_code sys_fs_readdir(u32 fd, vm::ptr dir, vm::ptr nread) diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.h b/rpcs3/Emu/Cell/lv2/sys_fs.h index 84806fe69d..71a08b913c 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.h +++ b/rpcs3/Emu/Cell/lv2/sys_fs.h @@ -2,7 +2,6 @@ #include "Emu/Memory/Memory.h" #include "Emu/Cell/ErrorCodes.h" -#include "Emu/IdManager.h" // Open Flags enum : s32 @@ -102,14 +101,11 @@ struct lv2_fs_object static const u32 id_step = 1; static const u32 id_count = 255 - id_base; - const u32 id; - // Mount Point const std::add_pointer_t mp; lv2_fs_object(lv2_fs_mount_point* mp) : mp(mp) - , id(idm::last_id()) { } @@ -185,7 +181,8 @@ struct lv2_file_op_rw : lv2_file_op CHECK_SIZE(lv2_file_op_rw, 0x38); -// SysCalls +// Syscalls + error_code sys_fs_test(u32 arg1, u32 arg2, vm::ps3::ptr arg3, u32 arg4, vm::ps3::ptr arg5, u32 arg6); error_code sys_fs_open(vm::ps3::cptr path, s32 flags, vm::ps3::ptr fd, s32 mode, vm::ps3::cptr arg, u64 size); error_code sys_fs_read(u32 fd, vm::ps3::ptr buf, u64 nbytes, vm::ps3::ptr nread); diff --git a/rpcs3/Emu/Cell/lv2/sys_prx.cpp b/rpcs3/Emu/Cell/lv2/sys_prx.cpp index fe86bc5fe8..6baed09041 100644 --- a/rpcs3/Emu/Cell/lv2/sys_prx.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_prx.cpp @@ -32,7 +32,7 @@ s32 prx_load_module(std::string path, u64 flags, vm::ptrid; + return idm::last_id(); } s32 sys_prx_load_module(vm::cptr path, u64 flags, vm::ptr pOpt) @@ -124,7 +124,7 @@ s32 sys_prx_unload_module(s32 id, u64 flags, vm::ptr(id); + const auto prx = idm::withdraw(id); if (!prx) { @@ -134,7 +134,6 @@ s32 sys_prx_unload_module(s32 id, u64 flags, vm::ptraddress); //s32 result = prx->exit ? prx->exit() : CELL_OK; - idm::remove(id); return CELL_OK; } @@ -231,8 +230,3 @@ s32 sys_prx_stop() sys_prx.todo("sys_prx_stop()"); return CELL_OK; } - -lv2_prx::lv2_prx() - : id(idm::last_id()) -{ -} diff --git a/rpcs3/Emu/Cell/lv2/sys_prx.h b/rpcs3/Emu/Cell/lv2/sys_prx.h index 00e2317617..47d04c849d 100644 --- a/rpcs3/Emu/Cell/lv2/sys_prx.h +++ b/rpcs3/Emu/Cell/lv2/sys_prx.h @@ -77,8 +77,6 @@ struct lv2_prx final : lv2_obj { static const u32 id_base = 0x23000000; - const u32 id; - bool is_started = false; std::unordered_map specials; @@ -87,8 +85,6 @@ struct lv2_prx final : lv2_obj vm::ps3::ptr argv)> start = vm::null; vm::ps3::ptr argv)> stop = vm::null; vm::ps3::ptr exit = vm::null; - - lv2_prx(); }; // SysCalls