From 9816ec3aa0da7a98750ec0437f9e1bd9689b6fd7 Mon Sep 17 00:00:00 2001 From: Sacha Date: Sat, 12 Jul 2014 17:02:39 +1000 Subject: [PATCH] Fix conflicts. --- Utilities/GNU.cpp | 29 +++++++++++--------- Utilities/GNU.h | 9 +++--- Utilities/SMutex.cpp | 2 +- Utilities/Thread.h | 4 +-- rpcs3/Emu/CPU/CPUThread.cpp | 7 +++-- rpcs3/Emu/CPU/CPUThread.h | 2 +- rpcs3/Emu/CPU/CPUThreadManager.cpp | 1 + rpcs3/Emu/Cell/RawSPUThread.cpp | 6 ++-- rpcs3/Emu/Cell/SPUThread.cpp | 2 -- rpcs3/Emu/Cell/SPUThread.h | 18 ++++++------ rpcs3/Emu/FS/vfsDir.cpp | 1 - rpcs3/Emu/FS/vfsFile.cpp | 1 - rpcs3/Emu/GS/GL/GLProgram.cpp | 6 ++-- rpcs3/Emu/GS/RSXThread.cpp | 6 ++-- rpcs3/Emu/Memory/Memory.cpp | 1 + rpcs3/Emu/SysCalls/Callback.cpp | 4 +-- rpcs3/Emu/SysCalls/Modules/cellAdec.cpp | 15 +++++----- rpcs3/Emu/SysCalls/Modules/cellAudio.cpp | 8 +++--- rpcs3/Emu/SysCalls/Modules/cellDmux.cpp | 14 +++++----- rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp | 4 +-- rpcs3/Emu/SysCalls/Modules/cellRtc.cpp | 2 -- rpcs3/Emu/SysCalls/Modules/cellSync.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp | 4 +-- rpcs3/Emu/SysCalls/Modules/cellVdec.cpp | 16 +++++------ rpcs3/Emu/SysCalls/Modules/libmixer.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/sys_fs.cpp | 2 +- rpcs3/Emu/SysCalls/lv2/sys_event.cpp | 6 ++-- rpcs3/Emu/SysCalls/lv2/sys_lwcond.cpp | 2 +- rpcs3/Emu/SysCalls/lv2/sys_lwmutex.cpp | 2 +- rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp | 5 ++-- rpcs3/Emu/SysCalls/lv2/sys_rwlock.cpp | 6 ++-- rpcs3/Emu/SysCalls/lv2/sys_spu.cpp | 2 +- rpcs3/Emu/System.cpp | 5 ++-- rpcs3/Emu/System.h | 3 -- rpcs3/Gui/DisAsmFrame.cpp | 3 +- 35 files changed, 99 insertions(+), 103 deletions(-) diff --git a/Utilities/GNU.cpp b/Utilities/GNU.cpp index bb0a784fe7..9f21a344ba 100644 --- a/Utilities/GNU.cpp +++ b/Utilities/GNU.cpp @@ -1,20 +1,23 @@ -#include -#include #include "GNU.h" #ifdef __APPLE__ -void * _aligned_malloc(size_t size, size_t alignment) { - void *buffer; - posix_memalign(&buffer, alignment, size); - return buffer; -} +#include +#include int clock_gettime(int foo, struct timespec *ts) { - struct timeval tv; + struct timeval tv; - gettimeofday(&tv, NULL); - ts->tv_sec = tv.tv_sec; - ts->tv_nsec = tv.tv_usec * 1000; - return(0); + gettimeofday(&tv, NULL); + ts->tv_sec = tv.tv_sec; + ts->tv_nsec = tv.tv_usec * 1000; + return(0); } -#endif /* !__APPLE__ */ +#endif /* __APPLE__ */ +#if defined(__GNUG__) + +void * _aligned_malloc(size_t size, size_t alignment) { + void *buffer; + return (posix_memalign(&buffer, alignment, size) == 0) ? buffer : 0; +} +#endif + diff --git a/Utilities/GNU.h b/Utilities/GNU.h index a79dfbf3d0..c0286b0491 100644 --- a/Utilities/GNU.h +++ b/Utilities/GNU.h @@ -28,7 +28,6 @@ void strcpy_trunc(char (&dst)[size], const std::string& src) #define _byteswap_ushort(x) __builtin_bswap16(x) #define _byteswap_ulong(x) __builtin_bswap32(x) #define _byteswap_uint64(x) __builtin_bswap64(x) -#define Sleep(x) usleep(x * 1000) #define mkdir(x) mkdir(x, 0777) #define INFINITE 0xFFFFFFFF #define _CRT_ALIGN(x) __attribute__((aligned(x))) @@ -61,10 +60,10 @@ inline int64_t __mulh(int64_t a, int64_t b) return result; } -#ifndef __APPLE__ -#define _aligned_malloc(size,alignment) memalign(alignment,size) -#else + void * _aligned_malloc(size_t size, size_t alignment); + +#ifdef __APPLE__ int clock_gettime(int foo, struct timespec *ts); #define wxIsNaN(x) ((x) != (x)) @@ -72,7 +71,7 @@ int clock_gettime(int foo, struct timespec *ts); #define CLOCK_MONOTONIC 0 #endif /* !CLOCK_MONOTONIC */ -#endif /* !__APPLE__ */ +#endif /* __APPLE__ */ #define _aligned_free free diff --git a/Utilities/SMutex.cpp b/Utilities/SMutex.cpp index 157e9103f0..80c8798941 100644 --- a/Utilities/SMutex.cpp +++ b/Utilities/SMutex.cpp @@ -14,7 +14,7 @@ __forceinline void SM_Sleep() } else { - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } } diff --git a/Utilities/Thread.h b/Utilities/Thread.h index 1f27f2a683..f38ff73162 100644 --- a/Utilities/Thread.h +++ b/Utilities/Thread.h @@ -177,7 +177,7 @@ private: Step(); } - while(!TestDestroy()) Sleep(0); + while(!TestDestroy()) std::this_thread::sleep_for(std::chrono::milliseconds(0)); if(m_destroy_sem.TryWait() != wxSEMA_NO_ERROR) m_destroy_sem.Post(); } @@ -198,7 +198,7 @@ public: { if(!IsRunning()) return; - while(m_main_sem.TryWait() != wxSEMA_NO_ERROR) Sleep(0); + while(m_main_sem.TryWait() != wxSEMA_NO_ERROR) std::this_thread::sleep_for(std::chrono::milliseconds(0)); } void Exit(bool wait = false) diff --git a/rpcs3/Emu/CPU/CPUThread.cpp b/rpcs3/Emu/CPU/CPUThread.cpp index df917d11aa..406721651a 100644 --- a/rpcs3/Emu/CPU/CPUThread.cpp +++ b/rpcs3/Emu/CPU/CPUThread.cpp @@ -3,6 +3,7 @@ #include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" +#include "Emu/DbgCommand.h" #include "rpcs3/Ini.h" #include "CPUThread.h" @@ -333,7 +334,7 @@ void CPUThread::Task() if (status == CPUThread_Sleeping) { - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); continue; } @@ -368,7 +369,7 @@ s64 CPUThread::ExecAsCallback(u64 pc, bool wait, u64 a1, u64 a2, u64 a3, u64 a4) LOG_WARNING(PPU, "ExecAsCallback() aborted"); return CELL_ECANCELED; // doesn't mean anything } - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } Stop(); @@ -394,7 +395,7 @@ s64 CPUThread::ExecAsCallback(u64 pc, bool wait, u64 a1, u64 a2, u64 a3, u64 a4) LOG_WARNING(PPU, "ExecAsCallback(wait=%s) aborted", wait ? "true" : "false"); return CELL_EABORT; // doesn't mean anything } - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } return wait * m_exit_status; diff --git a/rpcs3/Emu/CPU/CPUThread.h b/rpcs3/Emu/CPU/CPUThread.h index 87d9b9963d..c7db9d1c0d 100644 --- a/rpcs3/Emu/CPU/CPUThread.h +++ b/rpcs3/Emu/CPU/CPUThread.h @@ -153,7 +153,7 @@ public: { while(func(ThreadStatus())) { - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } } diff --git a/rpcs3/Emu/CPU/CPUThreadManager.cpp b/rpcs3/Emu/CPU/CPUThreadManager.cpp index 245e01875f..01ba798add 100644 --- a/rpcs3/Emu/CPU/CPUThreadManager.cpp +++ b/rpcs3/Emu/CPU/CPUThreadManager.cpp @@ -2,6 +2,7 @@ #include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" +#include "Emu/DbgCommand.h" #include "CPUThreadManager.h" #include "Emu/Cell/PPUThread.h" diff --git a/rpcs3/Emu/Cell/RawSPUThread.cpp b/rpcs3/Emu/Cell/RawSPUThread.cpp index 2b0ab6c68e..4f81ccf513 100644 --- a/rpcs3/Emu/Cell/RawSPUThread.cpp +++ b/rpcs3/Emu/Cell/RawSPUThread.cpp @@ -105,7 +105,8 @@ bool RawSPUThread::Read32(const u64 addr, u32* value) case SPU_In_MBox_offs: { LOG_ERROR(Log::SPU, "RawSPUThread[%d]: Read32(SPU_In_MBox)", m_index); - while (!SPU.In_MBox.Pop(*value) && !Emu.IsStopped()) Sleep(1); + while (!SPU.In_MBox.Pop(*value) && !Emu.IsStopped()) + std::this_thread::sleep_for(std::chrono::milliseconds(1)); break; } @@ -250,7 +251,8 @@ bool RawSPUThread::Write32(const u64 addr, const u32 value) case SPU_Out_MBox_offs: { LOG_WARNING(Log::SPU, "RawSPUThread[%d]: Write32(SPU_Out_MBox, 0x%x)", m_index, value); - while (!SPU.Out_MBox.Push(value) && !Emu.IsStopped()) Sleep(1); + while (!SPU.Out_MBox.Push(value) && !Emu.IsStopped()) + std::this_thread::sleep_for(std::chrono::milliseconds(1)); break; } diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index 502e754c5d..a8355bc296 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -1,11 +1,9 @@ #include "stdafx.h" #include "Utilities/Log.h" -#include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/SysCalls/lv2/sys_lwmutex.h" #include "Emu/SysCalls/lv2/sys_event.h" - #include "Emu/Cell/SPUThread.h" #include "Emu/Cell/SPUDecoder.h" #include "Emu/Cell/SPUInterpreter.h" diff --git a/rpcs3/Emu/Cell/SPUThread.h b/rpcs3/Emu/Cell/SPUThread.h index b082d2c7c7..a5f848ce65 100644 --- a/rpcs3/Emu/Cell/SPUThread.h +++ b/rpcs3/Emu/Cell/SPUThread.h @@ -977,7 +977,7 @@ public: { while (t->IsAlive()) { - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); if (Emu.IsStopped()) { LOG_WARNING(Log::SPU, "%s(%s) aborted", __FUNCTION__, spu_ch_name[ch]); @@ -1108,7 +1108,7 @@ public: case SPU_WrOutMbox: { //ConLog.Warning("%s: %s = 0x%x", __FUNCTION__, spu_ch_name[ch], v); - while (!SPU.Out_MBox.Push(v) && !Emu.IsStopped()) Sleep(1); + while (!SPU.Out_MBox.Push(v) && !Emu.IsStopped()) std::this_thread::sleep_for(std::chrono::milliseconds(1)); break; } @@ -1208,41 +1208,41 @@ public: { case SPU_RdInMbox: { - while (!SPU.In_MBox.Pop(v) && !Emu.IsStopped()) Sleep(1); + while (!SPU.In_MBox.Pop(v) && !Emu.IsStopped()) std::this_thread::sleep_for(std::chrono::milliseconds(1)); //ConLog.Warning("%s: 0x%x = %s", __FUNCTION__, v, spu_ch_name[ch]); break; } case MFC_RdTagStat: { - while (!Prxy.TagStatus.Pop(v) && !Emu.IsStopped()) Sleep(1); + while (!Prxy.TagStatus.Pop(v) && !Emu.IsStopped()) std::this_thread::sleep_for(std::chrono::milliseconds(1)); //ConLog.Warning("%s: 0x%x = %s", __FUNCTION__, v, spu_ch_name[ch]); break; } case SPU_RdSigNotify1: { - while (!SPU.SNR[0].Pop(v) && !Emu.IsStopped()) Sleep(1); + while (!SPU.SNR[0].Pop(v) && !Emu.IsStopped()) std::this_thread::sleep_for(std::chrono::milliseconds(1)); //ConLog.Warning("%s: 0x%x = %s", __FUNCTION__, v, spu_ch_name[ch]); break; } case SPU_RdSigNotify2: { - while (!SPU.SNR[1].Pop(v) && !Emu.IsStopped()) Sleep(1); + while (!SPU.SNR[1].Pop(v) && !Emu.IsStopped()) std::this_thread::sleep_for(std::chrono::milliseconds(1)); //ConLog.Warning("%s: 0x%x = %s", __FUNCTION__, v, spu_ch_name[ch]); break; } case MFC_RdAtomicStat: { - while (!Prxy.AtomicStat.Pop(v) && !Emu.IsStopped()) Sleep(1); + while (!Prxy.AtomicStat.Pop(v) && !Emu.IsStopped()) std::this_thread::sleep_for(std::chrono::milliseconds(1)); break; } case MFC_RdListStallStat: { - while (!StallStat.Pop(v) && !Emu.IsStopped()) Sleep(1); + while (!StallStat.Pop(v) && !Emu.IsStopped()) std::this_thread::sleep_for(std::chrono::milliseconds(1)); break; } @@ -1336,7 +1336,7 @@ public: default: eq->sq.invalidate(tid); SPU.In_MBox.PushUncond(CELL_ECANCELED); return; } - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); if (Emu.IsStopped()) { LOG_WARNING(Log::SPU, "sys_spu_thread_receive_event(spuq=0x%x) aborted", spuq); diff --git a/rpcs3/Emu/FS/vfsDir.cpp b/rpcs3/Emu/FS/vfsDir.cpp index ae32e0b05f..a161183549 100644 --- a/rpcs3/Emu/FS/vfsDir.cpp +++ b/rpcs3/Emu/FS/vfsDir.cpp @@ -1,6 +1,5 @@ #include "stdafx.h" #include "Utilities/Log.h" -#include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "vfsDir.h" diff --git a/rpcs3/Emu/FS/vfsFile.cpp b/rpcs3/Emu/FS/vfsFile.cpp index 1a80009ba7..f30a2de9a5 100644 --- a/rpcs3/Emu/FS/vfsFile.cpp +++ b/rpcs3/Emu/FS/vfsFile.cpp @@ -1,6 +1,5 @@ #include "stdafx.h" #include "Utilities/Log.h" -#include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "vfsFile.h" diff --git a/rpcs3/Emu/GS/GL/GLProgram.cpp b/rpcs3/Emu/GS/GL/GLProgram.cpp index 303f5ccf14..e7e7fdaa0a 100644 --- a/rpcs3/Emu/GS/GL/GLProgram.cpp +++ b/rpcs3/Emu/GS/GL/GLProgram.cpp @@ -51,8 +51,7 @@ void GLProgram::Create(const u32 vp, const u32 fp) if (bufLength) { - char* buf = new char[bufLength+1]; - memset(buf, 0, bufLength+1); + char* buf = new char[bufLength+1](); glGetProgramInfoLog(id, bufLength, NULL, buf); LOG_ERROR(RSX, "Could not link program: %s", buf); delete[] buf; @@ -70,8 +69,7 @@ void GLProgram::Create(const u32 vp, const u32 fp) if (bufLength) { - char* buf = new char[bufLength]; - memset(buf, 0, bufLength); + char* buf = new char[bufLength](); glGetProgramInfoLog(id, bufLength, NULL, buf); LOG_ERROR(RSX, "Could not link program: %s", buf); delete[] buf; diff --git a/rpcs3/Emu/GS/RSXThread.cpp b/rpcs3/Emu/GS/RSXThread.cpp index 1172b627ec..60a464f342 100644 --- a/rpcs3/Emu/GS/RSXThread.cpp +++ b/rpcs3/Emu/GS/RSXThread.cpp @@ -2409,7 +2409,7 @@ void RSXThread::Task() continue; } - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } is_vblank_stopped = true; @@ -2446,7 +2446,7 @@ void RSXThread::Task() m_sem_flush.post_and_wait(); } - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); continue; } @@ -2510,7 +2510,7 @@ void RSXThread::Task() while (!is_vblank_stopped) { - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } LOG_NOTICE(RSX, "RSX thread ended"); diff --git a/rpcs3/Emu/Memory/Memory.cpp b/rpcs3/Emu/Memory/Memory.cpp index 7cc75f4db2..cf1b8a8f9a 100644 --- a/rpcs3/Emu/Memory/Memory.cpp +++ b/rpcs3/Emu/Memory/Memory.cpp @@ -94,6 +94,7 @@ void MemoryBlock::Free() void MemoryBlock::Delete() { Free(); + safe_free(mem); Init(); } diff --git a/rpcs3/Emu/SysCalls/Callback.cpp b/rpcs3/Emu/SysCalls/Callback.cpp index 02fb9dc9cf..378830875f 100644 --- a/rpcs3/Emu/SysCalls/Callback.cpp +++ b/rpcs3/Emu/SysCalls/Callback.cpp @@ -69,7 +69,7 @@ again: LOG_WARNING(HLE, "Callback::Branch() aborted"); return 0; } - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } std::lock_guard lock(cb_mutex); @@ -112,7 +112,7 @@ again: LOG_WARNING(HLE, "Callback::Branch(true) aborted (end)"); return 0; } - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } return thr.GetExitStatus(); diff --git a/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp b/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp index 60b52a6c2c..44a2167f14 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp @@ -39,7 +39,7 @@ next: LOG_WARNING(HLE, "adecRawRead(): aborted"); return 0; } - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } switch (adec.job.Peek().type) @@ -212,13 +212,13 @@ u32 adecOpen(AudioDecoder* data) if (!adec.job.GetCountUnsafe() && adec.is_running) { - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); continue; } /*if (adec.frames.GetCount() >= 50) { - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); continue; }*/ @@ -283,8 +283,7 @@ u32 adecOpen(AudioDecoder* data) if (size) { - data = (u8*)av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); - memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + data = (u8*)av_calloc(1, size + FF_INPUT_BUFFER_PADDING_SIZE); this->size = size + FF_INPUT_BUFFER_PADDING_SIZE; } else @@ -618,7 +617,7 @@ int cellAdecClose(u32 handle) LOG_WARNING(HLE, "cellAdecClose(%d) aborted", handle); break; } - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } if (adec->adecCb) Emu.GetCPU().RemoveThread(adec->adecCb->GetId()); @@ -728,7 +727,7 @@ int cellAdecGetPcm(u32 handle, u32 outBuffer_addr) } // copy data - u8* out = (u8*)malloc(af.size); + u8* out = (u8*)calloc(1, af.size); // reverse byte order, extract data: float* in_f[2]; @@ -774,7 +773,7 @@ int cellAdecGetPcmItem(u32 handle, mem32_t pcmItem_ptr) if (adec->frames.IsEmpty()) { - Sleep(1); // hack + std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack return CELL_ADEC_ERROR_EMPTY; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp b/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp index 8fd2e0b9ac..e3d3555746 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp @@ -157,7 +157,7 @@ int cellAudioInit() // precise time of sleeping: 5,(3) ms (or 256/48000 sec) if (m_config.counter * 256000000 / 48000 >= stamp0 - m_config.start_time) { - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); continue; } @@ -469,7 +469,7 @@ abort: while (!internal_finished) { - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } m_config.m_is_audio_finalized = true; @@ -483,7 +483,7 @@ abort: LOG_WARNING(HLE, "cellAudioInit() aborted"); return CELL_OK; } - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } return CELL_OK; @@ -502,7 +502,7 @@ int cellAudioQuit() while (!m_config.m_is_audio_finalized) { - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); if (Emu.IsStopped()) { LOG_WARNING(HLE, "cellAudioQuit(): aborted"); diff --git a/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp b/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp index 3bde3766ac..254b7352dc 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp @@ -148,14 +148,14 @@ u32 dmuxOpen(Demuxer* data) if (es.isfull()) { stream = backup; - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); continue; } /*if (es.hasunseen()) // hack, probably useless { stream = backup; - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); continue; }*/ @@ -194,7 +194,7 @@ u32 dmuxOpen(Demuxer* data) ElementaryStream& es = *esAVC[ch]; if (es.isfull()) { - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); continue; } @@ -214,7 +214,7 @@ u32 dmuxOpen(Demuxer* data) /*if (es.hasunseen()) // hack, probably useless { stream = backup; - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); continue; }*/ es.finish(stream); @@ -237,7 +237,7 @@ u32 dmuxOpen(Demuxer* data) if (es.isfull()) { stream = backup; - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); continue; } @@ -598,7 +598,7 @@ int cellDmuxClose(u32 demuxerHandle) return CELL_OK; } - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } if (dmux->dmuxCb) Emu.GetCPU().RemoveThread(dmux->dmuxCb->GetId()); @@ -629,7 +629,7 @@ int cellDmuxSetStream(u32 demuxerHandle, const u32 streamAddress, u32 streamSize LOG_WARNING(HLE, "cellDmuxSetStream(%d) aborted (waiting)", demuxerHandle); return CELL_OK; } - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); return CELL_DMUX_ERROR_BUSY; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp b/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp index 7869c80ff5..508f9516cf 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp @@ -185,7 +185,7 @@ int cellMsgDialogOpen2(u32 type, mem_list_ptr_t msgString, mem_func_ptr_t msgString, mem_func_ptr_t mutex) while (old_order != mutex->m_freed) { - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); if (Emu.IsStopped()) { LOG_WARNING(HLE, "cellSyncMutexLock(mutex=0x%x) aborted", mutex.GetAddr()); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp index c1072297c4..94d22486e4 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp @@ -2,9 +2,9 @@ #include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" -#include "Emu/Cell/PPUThread.h" #include "Emu/SysCalls/SC_FUNC.h" #include "Emu/SysCalls/Modules.h" +#include "Emu/DbgCommand.h" #include "Emu/FS/vfsFile.h" #include "Emu/Audio/sysutil_audio.h" @@ -345,7 +345,7 @@ int cellSysutilCheckCallback() while (thr.IsAlive()) { - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); if (Emu.IsStopped()) { LOG_WARNING(HLE, "cellSysutilCheckCallback() aborted"); diff --git a/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp b/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp index d76d846c4d..b80bd8a88e 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp @@ -38,7 +38,7 @@ next: LOG_WARNING(HLE, "vdecRead(): aborted"); return 0; } - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } switch (vdec.job.Peek().type) @@ -150,13 +150,13 @@ u32 vdecOpen(VideoDecoder* data) if (!vdec.job.GetCountUnsafe() && vdec.is_running) { - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); continue; } if (vdec.frames.GetCount() >= 50) { - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); continue; } @@ -509,7 +509,7 @@ int cellVdecClose(u32 handle) LOG_WARNING(HLE, "cellVdecClose(%d) aborted", handle); break; } - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } if (vdec->vdecCb) Emu.GetCPU().RemoveThread(vdec->vdecCb->GetId()); @@ -543,13 +543,13 @@ int cellVdecEndSeq(u32 handle) /*if (!vdec->job.IsEmpty()) { - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); return CELL_VDEC_ERROR_BUSY; // ??? } if (!vdec->frames.IsEmpty()) { - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); return CELL_VDEC_ERROR_BUSY; // ??? }*/ @@ -560,7 +560,7 @@ int cellVdecEndSeq(u32 handle) LOG_WARNING(HLE, "cellVdecEndSeq(%d) aborted", handle); return CELL_OK; } - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } vdec->job.Push(VdecTask(vdecEndSeq)); @@ -680,7 +680,7 @@ int cellVdecGetPicItem(u32 handle, mem32_t picItem_ptr) if (vdec->frames.IsEmpty()) { - Sleep(1); // hack + std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack return CELL_VDEC_ERROR_EMPTY; } diff --git a/rpcs3/Emu/SysCalls/Modules/libmixer.cpp b/rpcs3/Emu/SysCalls/Modules/libmixer.cpp index 09d75fcaa1..d48f5efef2 100644 --- a/rpcs3/Emu/SysCalls/Modules/libmixer.cpp +++ b/rpcs3/Emu/SysCalls/Modules/libmixer.cpp @@ -363,7 +363,7 @@ int cellSurMixerCreate(const mem_ptr_t config) if (mixcount > (port.tag + 14)) // preemptive buffer filling (probably hack) { - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); continue; } diff --git a/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp b/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp index 9b08ead4d7..be6fe5291d 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp @@ -148,7 +148,7 @@ void fsAioRead(u32 fd, mem_ptr_t aio, int xid, mem_func_ptr_tsq.m_mutex.unlock(); while (eq->sq.list.size()) { - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); if (Emu.IsStopped()) { LOG_WARNING(HLE, "sys_event_queue_destroy(equeue=%d) aborted", equeue_id); @@ -222,7 +222,7 @@ s32 sys_event_queue_receive(u32 equeue_id, mem_ptr_t event, u64 default: eq->sq.invalidate(tid); return CELL_ECANCELED; } - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); if (counter++ > timeout || Emu.IsStopped()) { if (Emu.IsStopped()) LOG_WARNING(HLE, "sys_event_queue_receive(equeue=%d) aborted", equeue_id); @@ -569,7 +569,7 @@ s32 sys_event_flag_wait(u32 eflag_id, u64 bitptn, u32 mode, mem64_t result, u64 return CELL_ECANCELED; } - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); if (counter++ > max_counter) { diff --git a/rpcs3/Emu/SysCalls/lv2/sys_lwcond.cpp b/rpcs3/Emu/SysCalls/lv2/sys_lwcond.cpp index 7bc6377c62..ee44e1601b 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_lwcond.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_lwcond.cpp @@ -245,7 +245,7 @@ s32 sys_lwcond_wait(mem_ptr_t lwcond, u64 timeout) return CELL_OK; } - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); if (counter++ > max_counter) { diff --git a/rpcs3/Emu/SysCalls/lv2/sys_lwmutex.cpp b/rpcs3/Emu/SysCalls/lv2/sys_lwmutex.cpp index 1708e2770a..969c39e680 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_lwmutex.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_lwmutex.cpp @@ -253,7 +253,7 @@ int sys_lwmutex_t::trylock(be_t tid) LOG_WARNING(HLE, "(hack) sys_lwmutex_t::(try)lock aborted (waiting for recursive attribute, attr=0x%x)", (u32)attribute); return CELL_ESRCH; } - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); }*/ if (tid == owner_tid) diff --git a/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp b/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp index 4761e13cd2..f42444ee12 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp @@ -32,7 +32,8 @@ void sys_ppu_thread_exit(u64 errorcode) s32 sys_ppu_thread_yield() { sysPrxForUser->Log("sys_ppu_thread_yield()"); - Sleep(1); + // Note: Or do we actually want to yield? + std::this_thread::sleep_for(std::chrono::milliseconds(1)); return CELL_OK; } @@ -50,7 +51,7 @@ s32 sys_ppu_thread_join(u64 thread_id, mem64_t vptr) LOG_WARNING(PPU, "sys_ppu_thread_join(%d) aborted", thread_id); return CELL_OK; } - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } vptr = thr->GetExitStatus(); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_rwlock.cpp b/rpcs3/Emu/SysCalls/lv2/sys_rwlock.cpp index 2ad0524cee..8f3e7750bc 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_rwlock.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_rwlock.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #include "Utilities/Log.h" -#include "Emu/Memory/Memory.h" -#include "Emu/System.h" #include "Emu/Cell/PPUThread.h" #include "Emu/SysCalls/SysCalls.h" #include "sys_rwlock.h" @@ -72,7 +70,7 @@ s32 sys_rwlock_rlock(u32 rw_lock_id, u64 timeout) LOG_WARNING(HLE, "sys_rwlock_rlock(rw_lock_id=%d, ...) aborted", rw_lock_id); return CELL_ETIMEDOUT; } - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); if (rw->rlock_trylock(tid)) return CELL_OK; @@ -135,7 +133,7 @@ s32 sys_rwlock_wlock(u32 rw_lock_id, u64 timeout) LOG_WARNING(HLE, "sys_rwlock_wlock(rw_lock_id=%d, ...) aborted", rw_lock_id); return CELL_ETIMEDOUT; } - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); if (rw->wlock_trylock(tid, true)) return CELL_OK; diff --git a/rpcs3/Emu/SysCalls/lv2/sys_spu.cpp b/rpcs3/Emu/SysCalls/lv2/sys_spu.cpp index 39f39ee591..b7dae66aec 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_spu.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_spu.cpp @@ -370,7 +370,7 @@ s32 sys_spu_thread_group_join(u32 id, mem32_t cause, mem32_t status) LOG_WARNING(Log::SPU, "sys_spu_thread_group_join(id=%d, ...) aborted", id); return CELL_OK; } - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } } diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index b44a4000a4..89a3bb748c 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -2,7 +2,7 @@ #include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" -#include "Ini.h" +//#include "Ini.h" #include "Emu/GameInfo.h" #include "Emu/SysCalls/Static.h" @@ -12,6 +12,7 @@ #include "Emu/Cell/PPUInstrTable.h" #include "Emu/FS/vfsFile.h" #include "Emu/FS/vfsDeviceLocalFile.h" +#include "Emu/DbgCommand.h" #include "Emu/CPU/CPUThreadManager.h" //gui dependency @@ -388,7 +389,7 @@ void Emulator::Stop() LOG_NOTICE(HLE, "All threads stopped..."); break; } - Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); if (counter++ > 3000) { LOG_ERROR(HLE, "%d threads not stopped (timeout)", (u32)(g_thread_count - uncounted)); diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index cc85ecabe8..3b9f992ee4 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -8,10 +8,7 @@ #include "Emu/GS/GSManager.h" #include "Emu/Audio/AudioManager.h" #include "Emu/FS/VFS.h" -#include "Emu/DbgCommand.h" -#include "Emu/SysCalls/Static.h" #include "Loader/Loader.h" -#include "SysCalls/Callback.h" enum Status { diff --git a/rpcs3/Gui/DisAsmFrame.cpp b/rpcs3/Gui/DisAsmFrame.cpp index edc42b0741..66852a2f83 100644 --- a/rpcs3/Gui/DisAsmFrame.cpp +++ b/rpcs3/Gui/DisAsmFrame.cpp @@ -220,7 +220,8 @@ struct WaitDumperThread : public ThreadBase { for(uint i=0; i