From 1908286e7c0545532eb9a094d08027f161c63155 Mon Sep 17 00:00:00 2001 From: Peter Tissen Date: Mon, 24 Feb 2014 00:40:03 +0100 Subject: [PATCH] make things compile under windows again, there's still some ugly ifdefs I'd like to get rid of --- Utilities/BEType.h | 5 +- Utilities/IdManager.h | 6 ++- Utilities/Thread.cpp | 7 ++- rpcs3/Emu/SysCalls/Modules/cellAdec.h | 70 +++++++++++++------------ rpcs3/Emu/SysCalls/Modules/cellDmux.h | 15 +----- rpcs3/Emu/SysCalls/Modules/cellSync.cpp | 24 ++++----- rpcs3/Emu/SysCalls/lv2/SC_Lwcond.cpp | 24 ++++----- rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp | 22 ++++---- rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.h | 14 +++-- rpcs3/Emu/System.cpp | 1 + rpcs3/Emu/System.h | 4 +- 11 files changed, 97 insertions(+), 95 deletions(-) diff --git a/Utilities/BEType.h b/Utilities/BEType.h index 1195693178..17e8e61beb 100644 --- a/Utilities/BEType.h +++ b/Utilities/BEType.h @@ -50,7 +50,10 @@ class be_t public: typedef T type; - be_t() noexcept = default; +#ifdef __GNUG__ + be_t() noexcept = default +#endif + be_t(){} be_t(const T& value) { diff --git a/Utilities/IdManager.h b/Utilities/IdManager.h index a47dd3dcfd..9ceb8ae66e 100644 --- a/Utilities/IdManager.h +++ b/Utilities/IdManager.h @@ -96,7 +96,11 @@ public: m_cur_id = s_first_id; } - template + template ID_TYPE GetNewID(const std::string& name = "", T* data = nullptr, const u32 attr = 0) { std::lock_guard lock(m_mtx_main); diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index f756027ba9..6bd33d6b86 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -1,7 +1,12 @@ #include "stdafx.h" #include "Thread.h" -/*__declspec(thread)*/ thread_local NamedThreadBase* g_tls_this_thread = nullptr; +#ifdef _WIN32 +__declspec(thread) +#else +thread_local +#endif +NamedThreadBase* g_tls_this_thread = nullptr; NamedThreadBase* GetCurrentNamedThread() { diff --git a/rpcs3/Emu/SysCalls/Modules/cellAdec.h b/rpcs3/Emu/SysCalls/Modules/cellAdec.h index e05a394561..2aa17ead21 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAdec.h +++ b/rpcs3/Emu/SysCalls/Modules/cellAdec.h @@ -524,16 +524,16 @@ struct CellAdecParamM4Aac be_t configNumber; union { - struct + struct { struct { be_t adifProgramNumber; // 0 - } adifConfig; + } adifConfig; }; - struct + struct { struct { be_t samplingFreqIndex; be_t profile; // LC profile (1) - } rawDataBlockConfig; + } rawDataBlockConfig; }; } configInfo; be_t enableDownmix; // enable downmix to 2.0 (if (enableDownmix)) @@ -557,36 +557,40 @@ struct CellAdecM4AacInfo be_t pad1; // TODO: check alignment union { - struct - { - be_t copyrightIdPresent; - char copyrightId[9]; - be_t originalCopy; - be_t home; - be_t bitstreamType; - be_t bitrate; - be_t numberOfProgramConfigElements; - be_t bufferFullness; - } adif; + struct { + struct + { + be_t copyrightIdPresent; + char copyrightId[9]; + be_t originalCopy; + be_t home; + be_t bitstreamType; + be_t bitrate; + be_t numberOfProgramConfigElements; + be_t bufferFullness; + } adif; + }; - struct - { - be_t id; - be_t layer; - be_t protectionAbsent; - be_t profile; - be_t samplingFreqIndex; - be_t privateBit; - be_t channelConfiguration; - be_t originalCopy; - be_t home; - be_t copyrightIdBit; - be_t copyrightIdStart; - be_t frameLength; - be_t bufferFullness; - be_t numberOfRawDataBlocks; - be_t crcCheck; - } adts; + struct { + struct + { + be_t id; + be_t layer; + be_t protectionAbsent; + be_t profile; + be_t samplingFreqIndex; + be_t privateBit; + be_t channelConfiguration; + be_t originalCopy; + be_t home; + be_t copyrightIdBit; + be_t copyrightIdStart; + be_t frameLength; + be_t bufferFullness; + be_t numberOfRawDataBlocks; + be_t crcCheck; + } adts; + }; } bsi; be_t pad2; // TODO: check alignment diff --git a/rpcs3/Emu/SysCalls/Modules/cellDmux.h b/rpcs3/Emu/SysCalls/Modules/cellDmux.h index 08616f565c..9fa0067ee0 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellDmux.h +++ b/rpcs3/Emu/SysCalls/Modules/cellDmux.h @@ -96,20 +96,7 @@ struct CellDmuxResource2 be_t memSize; be_t ppuThreadPriority; be_t ppuThreadStackSize; - union cell_info - { - struct spu_info - { - be_t noex_spuThreadPriority; - be_t noex_numOfSpus; - }spu_inf; - struct spurs_info - { - be_t ex_spurs_addr; - u8 ex_priority[8]; - be_t ex_maxContention; - }spurs_inf; - }cell_inf; + be_t shit[4]; }; struct CellDmuxCb diff --git a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp index da3c545199..ba812cb2cb 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp @@ -24,12 +24,12 @@ enum }; #pragma pack(push, 1) -union CellSyncMutex { - struct cell_sync_mutex_info{ - be_t m_freed; +struct CellSyncMutex { + be_t m_freed; be_t m_order; - }parts; - volatile u32 m_data; + volatile u32& m_data(){ + return *reinterpret_cast(this); + }; /* (???) Initialize: set zeros (???) Lock: increase m_order and wait until m_freed == old m_order @@ -59,7 +59,7 @@ int cellSyncMutexInitialize(mem_ptr_t mutex) { reservation.clear(); } - mutex->m_data = 0; + mutex->m_data() = 0; return CELL_OK; } } @@ -85,9 +85,9 @@ int cellSyncMutexLock(mem_ptr_t mutex) { reservation.clear(); } - old_order = mutex->parts.m_order; - mutex->parts.m_order = mutex->parts.m_order + 1; - if (old_order == mutex->parts.m_freed) + old_order = mutex->m_order; + mutex->m_order = mutex->m_order + 1; + if (old_order == mutex->m_freed) { return CELL_OK; } @@ -125,11 +125,11 @@ int cellSyncMutexTryLock(mem_ptr_t mutex) { reservation.clear(); } - if (mutex->parts.m_order != mutex->parts.m_freed) + if (mutex->m_order != mutex->m_freed) { return CELL_SYNC_ERROR_BUSY; } - mutex->parts.m_order = mutex->parts.m_order + 1; + mutex->m_order = mutex->m_order + 1; return CELL_OK; } } @@ -154,7 +154,7 @@ int cellSyncMutexUnlock(mem_ptr_t mutex) { reservation.clear(); } - mutex->parts.m_freed = mutex->parts.m_freed + 1; + mutex->m_freed = mutex->m_freed + 1; return CELL_OK; } } diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Lwcond.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Lwcond.cpp index a07403532a..64539b0002 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Lwcond.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Lwcond.cpp @@ -86,11 +86,11 @@ int sys_lwcond_signal(mem_ptr_t lwcond) if (be_t target = (mutex->attribute.ToBE() == se32(SYS_SYNC_PRIORITY) ? sq->pop_prio() : sq->pop())) { - if (mutex->vars.parts.owner.trylock(target) != SMR_OK) + if (mutex->mutex.owner.trylock(target) != SMR_OK) { - mutex->vars.parts.owner.lock(tid); + mutex->mutex.owner.lock(tid); mutex->recursive_count = 1; - mutex->vars.parts.owner.unlock(tid, target); + mutex->mutex.owner.unlock(tid, target); } } @@ -122,11 +122,11 @@ int sys_lwcond_signal_all(mem_ptr_t lwcond) while (be_t target = (mutex->attribute.ToBE() == se32(SYS_SYNC_PRIORITY) ? sq->pop_prio() : sq->pop())) { - if (mutex->vars.parts.owner.trylock(target) != SMR_OK) + if (mutex->mutex.owner.trylock(target) != SMR_OK) { - mutex->vars.parts.owner.lock(tid); + mutex->mutex.owner.lock(tid); mutex->recursive_count = 1; - mutex->vars.parts.owner.unlock(tid, target); + mutex->mutex.owner.unlock(tid, target); } } @@ -163,11 +163,11 @@ int sys_lwcond_signal_to(mem_ptr_t lwcond, u32 ppu_thread_id) be_t target = ppu_thread_id; - if (mutex->vars.parts.owner.trylock(target) != SMR_OK) + if (mutex->mutex.owner.trylock(target) != SMR_OK) { - mutex->vars.parts.owner.lock(tid); + mutex->mutex.owner.lock(tid); mutex->recursive_count = 1; - mutex->vars.parts.owner.unlock(tid, target); + mutex->mutex.owner.unlock(tid, target); } if (Emu.IsStopped()) @@ -197,7 +197,7 @@ int sys_lwcond_wait(mem_ptr_t lwcond, u64 timeout) u32 tid_le = GetCurrentPPUThread().GetId(); be_t tid = tid_le; - if (mutex->vars.parts.owner.GetOwner() != tid) + if (mutex->mutex.owner.GetOwner() != tid) { return CELL_EPERM; // caller must own this lwmutex } @@ -205,7 +205,7 @@ int sys_lwcond_wait(mem_ptr_t lwcond, u64 timeout) sq->push(tid_le); mutex->recursive_count = 0; - mutex->vars.parts.owner.unlock(tid); + mutex->mutex.owner.unlock(tid); u32 counter = 0; const u32 max_counter = timeout ? (timeout / 1000) : ~0; @@ -216,7 +216,7 @@ int sys_lwcond_wait(mem_ptr_t lwcond, u64 timeout) case SMR_OK: mutex->unlock(tid); break; case SMR_SIGNAL: return CELL_OK; } */ - if (mutex->vars.parts.owner.GetOwner() == tid) + if (mutex->mutex.owner.GetOwner() == tid) { _mm_mfence(); mutex->recursive_count = 1; diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp index 872d2053f1..97de2549d0 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp @@ -28,9 +28,9 @@ int sys_lwmutex_create(mem_ptr_t lwmutex, mem_ptr_tattribute = attr->attr_protocol | attr->attr_recursive; - lwmutex->vars.all_info = 0; - lwmutex->vars.all_info = 0; - lwmutex->vars.parts.owner.initialize(); + lwmutex->mutex.all_info() = 0; + lwmutex->mutex.all_info() = 0; + lwmutex->mutex.owner.initialize(); //lwmutex->waiter = lwmutex->owner.GetOwner(); lwmutex->pad = 0; lwmutex->recursive_count = 0; @@ -54,10 +54,10 @@ int sys_lwmutex_destroy(mem_ptr_t lwmutex) if (!Emu.GetIdManager().CheckID(sq_id)) return CELL_ESRCH; // try to make it unable to lock - switch (int res = lwmutex->trylock(lwmutex->vars.parts.owner.GetDeadValue())) + switch (int res = lwmutex->trylock(lwmutex->mutex.owner.GetDeadValue())) { case CELL_OK: - lwmutex->vars.all_info = 0; + lwmutex->mutex.all_info() = 0; lwmutex->attribute = 0; lwmutex->sleep_queue = 0; Emu.GetIdManager().RemoveID(sq_id); @@ -208,7 +208,7 @@ int sys_lwmutex_t::trylock(be_t tid) { if (!attribute.ToBE()) return CELL_EINVAL; - if (tid == vars.parts.owner.GetOwner()) + if (tid == mutex.owner.GetOwner()) { if (attribute.ToBE() & se32(SYS_SYNC_RECURSIVE)) { @@ -222,7 +222,7 @@ int sys_lwmutex_t::trylock(be_t tid) } } - switch (vars.parts.owner.trylock(tid)) + switch (mutex.owner.trylock(tid)) { case SMR_OK: recursive_count = 1; return CELL_OK; case SMR_FAILED: return CELL_EBUSY; @@ -232,7 +232,7 @@ int sys_lwmutex_t::trylock(be_t tid) int sys_lwmutex_t::unlock(be_t tid) { - if (tid != vars.parts.owner.GetOwner()) + if (tid != mutex.owner.GetOwner()) { return CELL_EPERM; } @@ -251,8 +251,8 @@ int sys_lwmutex_t::unlock(be_t tid) target = attribute.ToBE() & se32(SYS_SYNC_FIFO) ? sq->pop() : sq->pop_prio(); case se32(SYS_SYNC_RETRY): break; } - if (target) vars.parts.owner.unlock(tid, target); - else vars.parts.owner.unlock(tid); + if (target) mutex.owner.unlock(tid, target); + else mutex.owner.unlock(tid); } return CELL_OK; } @@ -277,7 +277,7 @@ int sys_lwmutex_t::lock(be_t tid, u64 timeout) default: break; } - switch (vars.parts.owner.lock(tid, timeout)) + switch (mutex.owner.lock(tid, timeout)) { case SMR_OK: sq->invalidate(tid); diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.h b/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.h index f60a520ed8..24c4f30edb 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.h +++ b/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.h @@ -65,15 +65,13 @@ struct SleepQueue struct sys_lwmutex_t { - union sys_lwmutex_variable_t + struct sys_lwmutex_lock_info_t { - struct sys_lwmutex_lock_info_t - { - /* volatile */ SMutexBase, 0xffffffff, 0> owner; - /* volatile */ be_t waiter; // not used - }parts; - /* volatile */ be_t all_info; - }vars; + /* volatile */ SMutexBase, 0xffffffff, 0> owner; + /* volatile */ be_t waiter; // not used + u64 &all_info(){return *(reinterpret_cast(this)); + } + }mutex; be_t attribute; be_t recursive_count; be_t sleep_queue; diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 33c527fb92..f3ce2765ad 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -28,6 +28,7 @@ Emulator::Emulator() , m_dbg_console(nullptr) , m_rsx_callback(0) , m_ppu_callback_thr(0) + , m_event_manager(new EventManager()) { } diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index 603936d4bf..4887f4ef75 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -91,7 +91,7 @@ class Emulator AudioManager m_audio_manager; CallbackManager m_callback_manager; CPUThread* m_ppu_callback_thr; - EventManager &m_event_manager; + std::unique_ptr m_event_manager; VFS m_vfs; @@ -121,7 +121,7 @@ public: Array& GetBreakPoints() { return m_break_points; } Array& GetMarkedPoints() { return m_marked_points; } CPUThread& GetCallbackThread() { return *m_ppu_callback_thr; } - EventManager& GetEventManager() { return m_event_manager; } + EventManager& GetEventManager() { return *m_event_manager; } void AddModuleInit(ModuleInitializer* m) {