From c88e0a0eb91079c98f24ea622b174485c74daeb7 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Fri, 13 Mar 2015 04:09:53 +0300 Subject: [PATCH] Small cleanup --- Utilities/Thread.h | 6 ++--- rpcs3/Emu/Cell/SPUThread.cpp | 28 ++++++++++---------- rpcs3/Emu/Cell/SPUThread.h | 25 ++++++++--------- rpcs3/Emu/SysCalls/Modules/cellSync.cpp | 16 +++++------ rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp | 4 +-- rpcs3/Emu/SysCalls/lv2/sys_fs.cpp | 2 +- rpcs3/Emu/SysCalls/lv2/sys_fs.h | 6 ++--- rpcs3/Emu/SysCalls/lv2/sys_lwmutex.cpp | 2 +- rpcs3/Emu/SysCalls/lv2/sys_spu.cpp | 5 ++-- 9 files changed, 46 insertions(+), 48 deletions(-) diff --git a/Utilities/Thread.h b/Utilities/Thread.h index e1fdec7cb8..d41900a621 100644 --- a/Utilities/Thread.h +++ b/Utilities/Thread.h @@ -193,8 +193,8 @@ class squeue_t public: squeue_t() + : m_sync({}) { - m_sync.write_relaxed({}); } u32 get_max_size() const @@ -202,9 +202,9 @@ public: return sq_size; } - bool is_full() const + bool is_full() const volatile { - return m_sync.read_relaxed().count == sq_size; + return m_sync.data.count == sq_size; } bool push(const T& data, const std::function& test_exit) diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index b529b6276f..81c7b6dc8d 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -78,29 +78,29 @@ void SPUThread::InitRegs() ch_mfc_args = {}; mfc_queue.clear(); - ch_tag_mask = 0; - ch_tag_stat.data = {}; - ch_stall_stat.data = {}; - ch_atomic_stat.data = {}; + ch_tag_mask = {}; + ch_tag_stat = {}; + ch_stall_stat = {}; + ch_atomic_stat = {}; ch_in_mbox.clear(); - ch_out_mbox.data = {}; - ch_out_intr_mbox.data = {}; + ch_out_mbox = {}; + ch_out_intr_mbox = {}; - snr_config = 0; + snr_config = {}; - ch_snr1.data = {}; - ch_snr2.data = {}; + ch_snr1 = {}; + ch_snr2 = {}; - ch_event_mask = 0; - ch_event_stat.write_relaxed(0); + ch_event_mask = {}; + ch_event_stat = {}; ch_dec_start_timestamp = get_time(); // ??? - ch_dec_value = 0; + ch_dec_value = {}; - run_ctrl.write_relaxed(0); - status.write_relaxed(0); + run_ctrl = {}; + status = {}; int0.clear(); int2.clear(); diff --git a/rpcs3/Emu/Cell/SPUThread.h b/rpcs3/Emu/Cell/SPUThread.h index db395bb770..bee08966ab 100644 --- a/rpcs3/Emu/Cell/SPUThread.h +++ b/rpcs3/Emu/Cell/SPUThread.h @@ -139,10 +139,7 @@ union spu_channel_t atomic_t sync_var; // atomic variable - sync_var_t data; // unsafe direct access - public: - bool push(u32 value) { bool out_result; @@ -205,14 +202,14 @@ public: sync_var.write_relaxed({ count, value }); } - u32 get_value() + u32 get_value() volatile { - return sync_var.read_relaxed().value; + return sync_var.data.value; } - u32 get_count() + u32 get_count() volatile { - return sync_var.read_relaxed().count; + return sync_var.data.count; } }; @@ -232,8 +229,8 @@ struct spu_channel_4_t public: void clear() { - sync_var.write_relaxed({}); - value3.write_relaxed({}); + sync_var = {}; + value3 = {}; } void push_uncond(u32 value) @@ -275,9 +272,9 @@ public: return out_result; } - u32 get_count() + u32 get_count() volatile { - return sync_var.read_relaxed().count; + return sync_var.data.count; } }; @@ -311,10 +308,10 @@ public: void clear() { - mask.write_relaxed(0); - stat.write_relaxed(0); + mask = {}; + stat = {}; - assigned.write_relaxed(-1); + assigned = { -1 }; } }; diff --git a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp index 56f5f43c81..6bf4e90285 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp @@ -882,28 +882,28 @@ void syncLFQueueInit(vm::ptr queue, vm::ptr buffer, u32 siz if (direction == CELL_SYNC_QUEUE_ANY2ANY) { - queue->pop1.write_relaxed({}); - queue->push1.write_relaxed({}); + queue->pop1 = {}; + queue->push1 = {}; queue->m_buffer.set(queue->m_buffer.addr() | 1); queue->m_bs[0] = -1; queue->m_bs[1] = -1; //m_bs[2] //m_bs[3] queue->m_v1 = -1; - queue->push2.write_relaxed({ be_t::make(-1) }); - queue->pop2.write_relaxed({ be_t::make(-1) }); + queue->push2 = { { be_t::make(-1) } }; + queue->pop2 = { { be_t::make(-1) } }; } else { - queue->pop1.write_relaxed({ be_t::make(0), be_t::make(0), queue->pop1.read_relaxed().m_h3, be_t::make(0) }); - queue->push1.write_relaxed({ be_t::make(0), be_t::make(0), queue->push1.read_relaxed().m_h7, be_t::make(0) }); + queue->pop1 = { { be_t::make(0), be_t::make(0), queue->pop1.read_relaxed().m_h3, be_t::make(0) } }; + queue->push1 = { { be_t::make(0), be_t::make(0), queue->push1.read_relaxed().m_h7, be_t::make(0) } }; queue->m_bs[0] = -1; // written as u32 queue->m_bs[1] = -1; queue->m_bs[2] = -1; queue->m_bs[3] = -1; queue->m_v1 = 0; - queue->push2.write_relaxed({}); - queue->pop2.write_relaxed({}); + queue->push2 = {}; + queue->pop2 = {}; } queue->m_v2 = 0; diff --git a/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp b/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp index 54ab1e2bb4..9f31519d78 100644 --- a/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp @@ -114,7 +114,7 @@ s32 sys_lwmutex_create(vm::ptr lwmutex, vm::ptr lw(new lwmutex_t(protocol, attr->name_u64)); - lwmutex->lock_var.write_relaxed({ lwmutex::free, lwmutex::zero }); + lwmutex->lock_var = { { lwmutex::free, lwmutex::zero } }; lwmutex->attribute = attr->recursive | attr->protocol; lwmutex->recursive_count = 0; lwmutex->sleep_queue = Emu.GetIdManager().GetNewID(lw); @@ -575,7 +575,7 @@ s32 sys_lwcond_wait(PPUThread& CPU, vm::ptr lwcond, u64 timeout) const be_t recursive_value = lwmutex->recursive_count; // set special value - lwmutex->owner.write_relaxed(lwmutex::reserved); + lwmutex->owner = { lwmutex::reserved }; lwmutex->recursive_count = 0; // call the syscall diff --git a/rpcs3/Emu/SysCalls/lv2/sys_fs.cpp b/rpcs3/Emu/SysCalls/lv2/sys_fs.cpp index 9050aa0f85..99c0c58914 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_fs.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_fs.cpp @@ -20,7 +20,7 @@ SysCallBase sys_fs("sys_fs"); -s32 sys_fs_open(vm::ptr path, s32 flags, vm::ptr fd, u64 mode, vm::ptr arg, u64 size) +s32 sys_fs_open(vm::ptr path, s32 flags, vm::ptr fd, u32 mode, vm::ptr arg, u64 size) { sys_fs.Warning("sys_fs_open(path=*0x%x, flags=0x%x, fd=*0x%x, arg=*0x%x, size=0x%llx)", path, flags, fd, arg, size); sys_fs.Warning("*** path = '%s'", path.get_ptr()); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_fs.h b/rpcs3/Emu/SysCalls/lv2/sys_fs.h index 6ae94e60db..f54eeeb047 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_fs.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_fs.h @@ -89,7 +89,7 @@ enum : s32 enum CellFsMode : s32 { - CELL_FS_S_IFMT = 0170000, + CELL_FS_S_IFMT = 0170000, CELL_FS_S_IFDIR = 0040000, // directory CELL_FS_S_IFREG = 0100000, // regular CELL_FS_S_IFLNK = 0120000, // symbolic link @@ -126,7 +126,7 @@ struct CellFsDirent struct CellFsStat { - be_t mode; + be_t mode; be_t uid; be_t gid; be_t atime; @@ -145,7 +145,7 @@ struct CellFsUtimbuf #pragma pack(pop) // SysCalls -s32 sys_fs_open(vm::ptr path, s32 flags, vm::ptr fd, u64 mode, vm::ptr arg, u64 size); +s32 sys_fs_open(vm::ptr path, s32 flags, vm::ptr fd, u32 mode, vm::ptr arg, u64 size); s32 sys_fs_read(u32 fd, vm::ptr buf, u64 nbytes, vm::ptr nread); s32 sys_fs_write(u32 fd, vm::ptr buf, u64 nbytes, vm::ptr nwrite); s32 sys_fs_close(u32 fd); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_lwmutex.cpp b/rpcs3/Emu/SysCalls/lv2/sys_lwmutex.cpp index 5b8f99e1c3..4568c84aee 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_lwmutex.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_lwmutex.cpp @@ -16,7 +16,7 @@ void lwmutex_create(sys_lwmutex_t& lwmutex, bool recursive, u32 protocol, u64 na { std::shared_ptr mutex(new lwmutex_t(protocol, name)); - lwmutex.lock_var.write_relaxed({ lwmutex::free, lwmutex::zero }); + lwmutex.lock_var = { { lwmutex::free, lwmutex::zero } }; lwmutex.attribute = protocol | (recursive ? SYS_SYNC_RECURSIVE : SYS_SYNC_NOT_RECURSIVE); lwmutex.recursive_count = 0; lwmutex.sleep_queue = Emu.GetIdManager().GetNewID(mutex, TYPE_LWMUTEX); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_spu.cpp b/rpcs3/Emu/SysCalls/lv2/sys_spu.cpp index f2f98e2338..f4eb597754 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_spu.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_spu.cpp @@ -315,11 +315,12 @@ s32 sys_spu_thread_group_start(u32 id) spu.SetEntry(image->entry_point); spu.Run(); - spu.status.write_relaxed(SPU_STATUS_RUNNING); spu.GPR[3] = u128::from64(0, args.arg1); spu.GPR[4] = u128::from64(0, args.arg2); spu.GPR[5] = u128::from64(0, args.arg3); spu.GPR[6] = u128::from64(0, args.arg4); + + spu.status.exchange(SPU_STATUS_RUNNING); } } @@ -518,7 +519,7 @@ s32 sys_spu_thread_group_terminate(u32 id, s32 value) { auto& spu = static_cast(*t); - spu.status.write_relaxed(SPU_STATUS_STOPPED); + spu.status.exchange(SPU_STATUS_STOPPED); spu.FastStop(); } }