From 31b55e0030d35e20f8afd2f27becfbf143d3d169 Mon Sep 17 00:00:00 2001 From: Eladash Date: Sat, 8 May 2021 20:08:25 +0300 Subject: [PATCH] event queue: Structure size efficiency --- rpcs3/Emu/Cell/lv2/sys_event.cpp | 12 ++++++------ rpcs3/Emu/Cell/lv2/sys_event.h | 8 ++++---- rpcs3/Emu/Cell/lv2/sys_event_flag.h | 4 ++-- rpcs3/Emu/Cell/lv2/sys_lwcond.h | 4 ++-- rpcs3/Emu/Cell/lv2/sys_lwmutex.h | 4 ++-- rpcs3/Emu/Cell/lv2/sys_mutex.h | 4 ++-- rpcs3/Emu/Cell/lv2/sys_rwlock.h | 4 ++-- rpcs3/Emu/Cell/lv2/sys_semaphore.h | 4 ++-- rpcs3/Emu/Cell/lv2/sys_sync.h | 2 +- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_event.cpp b/rpcs3/Emu/Cell/lv2/sys_event.cpp index a1457da750..48dfdb8b32 100644 --- a/rpcs3/Emu/Cell/lv2/sys_event.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_event.cpp @@ -11,13 +11,13 @@ LOG_CHANNEL(sys_event); -lv2_event_queue::lv2_event_queue(u32 protocol, s32 type, u64 name, u64 ipc_key, s32 size) noexcept - : protocol{protocol} - , id(idm::last_id()) - , type(type) +lv2_event_queue::lv2_event_queue(u32 protocol, s32 type, s32 size, u64 name, u64 ipc_key) noexcept + : id(idm::last_id()) + , protocol{static_cast(protocol)} + , type(static_cast(type)) + , size(static_cast(size)) , name(name) , key(ipc_key) - , size(size) { } @@ -127,7 +127,7 @@ error_code sys_event_queue_create(cpu_thread& cpu, vm::ptr equeue_id, vm::p if (const auto error = lv2_obj::create(pshared, ipc_key, flags, [&]() { - return std::make_shared(protocol, type, name, ipc_key, size); + return std::make_shared(protocol, type, size, name, ipc_key); })) { return error; diff --git a/rpcs3/Emu/Cell/lv2/sys_event.h b/rpcs3/Emu/Cell/lv2/sys_event.h index c939b08f56..edab584cec 100644 --- a/rpcs3/Emu/Cell/lv2/sys_event.h +++ b/rpcs3/Emu/Cell/lv2/sys_event.h @@ -80,18 +80,18 @@ struct lv2_event_queue final : public lv2_obj { static const u32 id_base = 0x8d000000; - const lv2_protocol protocol; const u32 id; - const s32 type; + const lv2_protocol protocol; + const u8 type; + const u8 size; const u64 name; const u64 key; - const s32 size; shared_mutex mutex; std::deque events; std::deque sq; - lv2_event_queue(u32 protocol, s32 type, u64 name, u64 ipc_key, s32 size) noexcept; + lv2_event_queue(u32 protocol, s32 type, s32 size, u64 name, u64 ipc_key) noexcept; CellError send(lv2_event); diff --git a/rpcs3/Emu/Cell/lv2/sys_event_flag.h b/rpcs3/Emu/Cell/lv2/sys_event_flag.h index b06b7a63f7..2fccc61f43 100644 --- a/rpcs3/Emu/Cell/lv2/sys_event_flag.h +++ b/rpcs3/Emu/Cell/lv2/sys_event_flag.h @@ -45,8 +45,8 @@ struct lv2_event_flag final : lv2_obj atomic_t pattern; std::deque sq; - lv2_event_flag(u32 protocol, u64 key, s32 type, u64 name, u64 pattern) - : protocol{protocol} + lv2_event_flag(u32 protocol, u64 key, s32 type, u64 name, u64 pattern) noexcept + : protocol{static_cast(protocol)} , key(key) , type(type) , name(name) diff --git a/rpcs3/Emu/Cell/lv2/sys_lwcond.h b/rpcs3/Emu/Cell/lv2/sys_lwcond.h index 5193c01946..d4cf18755e 100644 --- a/rpcs3/Emu/Cell/lv2/sys_lwcond.h +++ b/rpcs3/Emu/Cell/lv2/sys_lwcond.h @@ -34,10 +34,10 @@ struct lv2_lwcond final : lv2_obj atomic_t waiters{0}; std::deque sq; - lv2_lwcond(u64 name, u32 lwid, u32 protocol, vm::ptr control) + lv2_lwcond(u64 name, u32 lwid, u32 protocol, vm::ptr control) noexcept : name(std::bit_cast>(name)) , lwid(lwid) - , protocol{protocol} + , protocol{static_cast(protocol)} , control(control) { } diff --git a/rpcs3/Emu/Cell/lv2/sys_lwmutex.h b/rpcs3/Emu/Cell/lv2/sys_lwmutex.h index c7b4fb63ef..0ef7a1da77 100644 --- a/rpcs3/Emu/Cell/lv2/sys_lwmutex.h +++ b/rpcs3/Emu/Cell/lv2/sys_lwmutex.h @@ -64,8 +64,8 @@ struct lv2_lwmutex final : lv2_obj std::deque sq; atomic_t lwcond_waiters{0}; - lv2_lwmutex(u32 protocol, vm::ptr control, u64 name) - : protocol{protocol} + lv2_lwmutex(u32 protocol, vm::ptr control, u64 name) noexcept + : protocol{static_cast(protocol)} , control(control) , name(std::bit_cast>(name)) { diff --git a/rpcs3/Emu/Cell/lv2/sys_mutex.h b/rpcs3/Emu/Cell/lv2/sys_mutex.h index 2eadb0742f..d7b9e5a06a 100644 --- a/rpcs3/Emu/Cell/lv2/sys_mutex.h +++ b/rpcs3/Emu/Cell/lv2/sys_mutex.h @@ -37,8 +37,8 @@ struct lv2_mutex final : lv2_obj atomic_t lock_count{0}; // Recursive Locks std::deque sq; - lv2_mutex(u32 protocol, u32 recursive,u32 adaptive, u64 key, u64 name) - : protocol{protocol} + lv2_mutex(u32 protocol, u32 recursive,u32 adaptive, u64 key, u64 name) noexcept + : protocol{static_cast(protocol)} , recursive(recursive) , adaptive(adaptive) , key(key) diff --git a/rpcs3/Emu/Cell/lv2/sys_rwlock.h b/rpcs3/Emu/Cell/lv2/sys_rwlock.h index 218f1f60fe..97f762c01c 100644 --- a/rpcs3/Emu/Cell/lv2/sys_rwlock.h +++ b/rpcs3/Emu/Cell/lv2/sys_rwlock.h @@ -32,8 +32,8 @@ struct lv2_rwlock final : lv2_obj std::deque rq; std::deque wq; - lv2_rwlock(u32 protocol, u64 key, u64 name) - : protocol{protocol} + lv2_rwlock(u32 protocol, u64 key, u64 name) noexcept + : protocol{static_cast(protocol)} , key(key) , name(name) { diff --git a/rpcs3/Emu/Cell/lv2/sys_semaphore.h b/rpcs3/Emu/Cell/lv2/sys_semaphore.h index 3f3fa76b15..78dc0643a5 100644 --- a/rpcs3/Emu/Cell/lv2/sys_semaphore.h +++ b/rpcs3/Emu/Cell/lv2/sys_semaphore.h @@ -32,8 +32,8 @@ struct lv2_sema final : lv2_obj atomic_t val; std::deque sq; - lv2_sema(u32 protocol, u64 key, u64 name, s32 max, s32 value) - : protocol{protocol} + lv2_sema(u32 protocol, u64 key, u64 name, s32 max, s32 value) noexcept + : protocol{static_cast(protocol)} , key(key) , name(name) , max(max) diff --git a/rpcs3/Emu/Cell/lv2/sys_sync.h b/rpcs3/Emu/Cell/lv2/sys_sync.h index 997af54ad9..2b72b3f6e9 100644 --- a/rpcs3/Emu/Cell/lv2/sys_sync.h +++ b/rpcs3/Emu/Cell/lv2/sys_sync.h @@ -14,7 +14,7 @@ #include // attr_protocol (waiting scheduling policy) -enum lv2_protocol : u32 +enum lv2_protocol : u8 { SYS_SYNC_FIFO = 0x1, // First In, First Out Order SYS_SYNC_PRIORITY = 0x2, // Priority Order