diff --git a/Common/LogManager.cpp b/Common/LogManager.cpp index 373a76040..5d7d5da98 100644 --- a/Common/LogManager.cpp +++ b/Common/LogManager.cpp @@ -187,7 +187,7 @@ void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const if (level > log->GetLevel() || !log->IsEnabled() || !log->HasListeners()) return; - std::lock_guard lk(log_lock_); + lock_guard lk(log_lock_); static const char level_to_char[8] = "-NEWIDV"; char formattedTime[13]; Common::Timer::GetTimeFormatted(formattedTime); @@ -266,13 +266,13 @@ LogChannel::LogChannel(const char* shortName, const char* fullName, bool enable) // LogContainer void LogChannel::AddListener(LogListener *listener) { - std::lock_guard lk(m_listeners_lock); + lock_guard lk(m_listeners_lock); m_listeners.insert(listener); m_hasListeners = true; } void LogChannel::RemoveListener(LogListener *listener) { - std::lock_guard lk(m_listeners_lock); + lock_guard lk(m_listeners_lock); m_listeners.erase(listener); m_hasListeners = !m_listeners.empty(); } @@ -281,7 +281,7 @@ void LogChannel::Trigger(LogTypes::LOG_LEVELS level, const char *msg) { #ifdef __SYMBIAN32__ RDebug::Printf("%s",msg); #else - std::lock_guard lk(m_listeners_lock); + lock_guard lk(m_listeners_lock); std::set::const_iterator i; for (i = m_listeners.begin(); i != m_listeners.end(); ++i) { @@ -303,7 +303,7 @@ void FileLogListener::Log(LogTypes::LOG_LEVELS, const char *msg) { if (!IsEnabled() || !IsValid()) return; - std::lock_guard lk(m_log_lock); + lock_guard lk(m_log_lock); m_logfile << msg << std::flush; } diff --git a/Common/LogManager.h b/Common/LogManager.h index 452ffdf86..d6a078571 100644 --- a/Common/LogManager.h +++ b/Common/LogManager.h @@ -17,13 +17,12 @@ #pragma once +#include +#include "base/mutex.h" +#include "file/ini_file.h" #include "Log.h" #include "StringUtils.h" #include "FileUtil.h" -#include "file/ini_file.h" - -#include -#include "StdMutex.h" #define MAX_MESSAGES 8000 #define MAX_MSGLEN 1024 @@ -51,7 +50,7 @@ public: const char* GetName() const { return "file"; } private: - std::mutex m_log_lock; + recursive_mutex m_log_lock; std::ofstream m_logfile; bool m_enable; }; @@ -113,7 +112,7 @@ public: private: char m_fullName[128]; char m_shortName[32]; - std::mutex m_listeners_lock; + recursive_mutex m_listeners_lock; std::set m_listeners; bool m_hasListeners; }; @@ -128,7 +127,7 @@ private: DebuggerLogListener *debuggerLog_; RingbufferLogListener *ringLog_; static LogManager *logManager_; // Singleton. Ugh. - std::mutex log_lock_; + recursive_mutex log_lock_; LogManager(); ~LogManager(); diff --git a/Core/CoreTiming.cpp b/Core/CoreTiming.cpp index 7b25787fd..42da031ba 100644 --- a/Core/CoreTiming.cpp +++ b/Core/CoreTiming.cpp @@ -20,10 +20,10 @@ #include #include "base/logging.h" +#include "base/mutex.h" #include "profiler/profiler.h" #include "Common/MsgHandler.h" -#include "Common/StdMutex.h" #include "Common/Atomics.h" #include "Core/CoreTiming.h" #include "Core/Core.h" @@ -86,7 +86,7 @@ s64 idledCycles; s64 lastGlobalTimeTicks; s64 lastGlobalTimeUs; -static std::recursive_mutex externalEventSection; +static recursive_mutex externalEventSection; // Warning: not included in save state. void (*advanceCallback)(int cyclesExecuted) = NULL; @@ -228,7 +228,7 @@ void Shutdown() delete ev; } - std::lock_guard lk(externalEventSection); + lock_guard lk(externalEventSection); while(eventTsPool) { Event *ev = eventTsPool; @@ -252,7 +252,7 @@ u64 GetIdleTicks() // schedule things to be executed on the main thread. void ScheduleEvent_Threadsafe(s64 cyclesIntoFuture, int event_type, u64 userdata) { - std::lock_guard lk(externalEventSection); + lock_guard lk(externalEventSection); Event *ne = GetNewTsEvent(); ne->time = GetTicks() + cyclesIntoFuture; ne->type = event_type; @@ -273,7 +273,7 @@ void ScheduleEvent_Threadsafe_Immediate(int event_type, u64 userdata) { if(false) //Core::IsCPUThread()) { - std::lock_guard lk(externalEventSection); + lock_guard lk(externalEventSection); event_types[event_type].callback(userdata, 0); } else @@ -368,7 +368,7 @@ s64 UnscheduleEvent(int event_type, u64 userdata) s64 UnscheduleThreadsafeEvent(int event_type, u64 userdata) { s64 result = 0; - std::lock_guard lk(externalEventSection); + lock_guard lk(externalEventSection); if (!tsFirst) return result; while(tsFirst) @@ -478,7 +478,7 @@ void RemoveEvent(int event_type) void RemoveThreadsafeEvent(int event_type) { - std::lock_guard lk(externalEventSection); + lock_guard lk(externalEventSection); if (!tsFirst) { return; @@ -552,7 +552,7 @@ void MoveEvents() { Common::AtomicStoreRelease(hasTsEvents, 0); - std::lock_guard lk(externalEventSection); + lock_guard lk(externalEventSection); // Move events from async queue into main queue while (tsFirst) { @@ -692,7 +692,7 @@ void Event_DoStateOld(PointerWrap &p, BaseEvent *ev) void DoState(PointerWrap &p) { - std::lock_guard lk(externalEventSection); + lock_guard lk(externalEventSection); auto s = p.Section("CoreTiming", 1, 3); if (!s) diff --git a/Core/HLE/sceCtrl.cpp b/Core/HLE/sceCtrl.cpp index 75116abd8..298ada31a 100644 --- a/Core/HLE/sceCtrl.cpp +++ b/Core/HLE/sceCtrl.cpp @@ -17,6 +17,7 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include +#include "base/mutex.h" #include "Globals.h" #include "Core/HLE/HLE.h" #include "Core/HLE/FunctionWrappers.h" @@ -24,7 +25,6 @@ #include "Core/CoreTiming.h" #include "Core/MemMapHelpers.h" #include "Common/ChunkFile.h" -#include "Common/StdMutex.h" #include "Core/HLE/sceCtrl.h" #include "Core/HLE/sceDisplay.h" #include "Core/HLE/sceKernel.h" @@ -84,7 +84,7 @@ static int ctrlIdleBack = -1; static int ctrlCycle = 0; static std::vector waitingThreads; -static std::recursive_mutex ctrlMutex; +static recursive_mutex ctrlMutex; static int ctrlTimer = -1; @@ -101,7 +101,7 @@ const u32 CTRL_EMU_RAPIDFIRE_MASK = CTRL_UP | CTRL_DOWN | CTRL_LEFT | CTRL_RIGHT static void __CtrlUpdateLatch() { - std::lock_guard guard(ctrlMutex); + lock_guard guard(ctrlMutex); // Copy in the current data to the current buffer. ctrlBufs[ctrlBuf] = ctrlCurrent; @@ -144,14 +144,14 @@ static int __CtrlResetLatch() u32 __CtrlPeekButtons() { - std::lock_guard guard(ctrlMutex); + lock_guard guard(ctrlMutex); return ctrlCurrent.buttons; } void __CtrlPeekAnalog(int stick, float *x, float *y) { - std::lock_guard guard(ctrlMutex); + lock_guard guard(ctrlMutex); *x = (ctrlCurrent.analog[stick][CTRL_ANALOG_X] - 127.5f) / 127.5f; *y = -(ctrlCurrent.analog[stick][CTRL_ANALOG_Y] - 127.5f) / 127.5f; @@ -170,27 +170,27 @@ u32 __CtrlReadLatch() void __CtrlButtonDown(u32 buttonBit) { - std::lock_guard guard(ctrlMutex); + lock_guard guard(ctrlMutex); ctrlCurrent.buttons |= buttonBit; } void __CtrlButtonUp(u32 buttonBit) { - std::lock_guard guard(ctrlMutex); + lock_guard guard(ctrlMutex); ctrlCurrent.buttons &= ~buttonBit; } void __CtrlSetAnalogX(float x, int stick) { u8 scaled = clamp_u8((int)ceilf(x * 127.5f + 127.5f)); - std::lock_guard guard(ctrlMutex); + lock_guard guard(ctrlMutex); ctrlCurrent.analog[stick][CTRL_ANALOG_X] = scaled; } void __CtrlSetAnalogY(float y, int stick) { u8 scaled = clamp_u8((int)ceilf(-y * 127.5f + 127.5f)); - std::lock_guard guard(ctrlMutex); + lock_guard guard(ctrlMutex); ctrlCurrent.analog[stick][CTRL_ANALOG_Y] = scaled; } @@ -304,7 +304,7 @@ void __CtrlInit() ctrlIdleBack = -1; ctrlCycle = 0; - std::lock_guard guard(ctrlMutex); + lock_guard guard(ctrlMutex); ctrlBuf = 1; ctrlBufRead = 0; @@ -326,7 +326,7 @@ void __CtrlInit() void __CtrlDoState(PointerWrap &p) { - std::lock_guard guard(ctrlMutex); + lock_guard guard(ctrlMutex); auto s = p.Section("sceCtrl", 1, 3); if (!s) diff --git a/Core/SaveState.cpp b/Core/SaveState.cpp index b9a0321ba..ee8f3d1aa 100644 --- a/Core/SaveState.cpp +++ b/Core/SaveState.cpp @@ -15,13 +15,14 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include #include +#include "base/mutex.h" #include "base/timeutil.h" #include "base/NativeApp.h" #include "i18n/i18n.h" -#include "Common/StdMutex.h" #include "Common/FileUtil.h" #include "Common/ChunkFile.h" @@ -206,7 +207,7 @@ namespace SaveState static bool needsProcess = false; static std::vector pending; - static std::recursive_mutex mutex; + static recursive_mutex mutex; static bool hasLoadedState = false; // TODO: Should this be configurable? @@ -250,7 +251,7 @@ namespace SaveState void Enqueue(SaveState::Operation op) { - std::lock_guard guard(mutex); + lock_guard guard(mutex); pending.push_back(op); // Don't actually run it until next frame. @@ -486,7 +487,7 @@ namespace SaveState std::vector Flush() { - std::lock_guard guard(mutex); + lock_guard guard(mutex); std::vector copy = pending; pending.clear(); @@ -670,7 +671,7 @@ namespace SaveState // Make sure there's a directory for save slots pspFileSystem.MkDir("ms0:/PSP/PPSSPP_STATE"); - std::lock_guard guard(mutex); + lock_guard guard(mutex); rewindStates.Clear(); hasLoadedState = false; diff --git a/UI/OnScreenDisplay.cpp b/UI/OnScreenDisplay.cpp index 58bae2806..eb4646e5a 100644 --- a/UI/OnScreenDisplay.cpp +++ b/UI/OnScreenDisplay.cpp @@ -55,7 +55,7 @@ restart: void OnScreenMessages::Show(const std::string &text, float duration_s, uint32_t color, int icon, bool checkUnique, const char *id) { double now = time_now_d(); - std::lock_guard guard(mutex_); + lock_guard guard(mutex_); if (checkUnique) { for (auto iter = messages_.begin(); iter != messages_.end(); ++iter) { if (iter->text == text || (id && iter->id && !strcmp(iter->id, id))) { diff --git a/UI/OnScreenDisplay.h b/UI/OnScreenDisplay.h index 208f27d27..8a0c6c17e 100644 --- a/UI/OnScreenDisplay.h +++ b/UI/OnScreenDisplay.h @@ -3,9 +3,9 @@ #include #include +#include "base/mutex.h" #include "base/basictypes.h" #include "math/geom2d.h" -#include "Common/StdMutex.h" #include "ui/view.h" @@ -39,7 +39,7 @@ public: private: std::list messages_; - std::recursive_mutex mutex_; + recursive_mutex mutex_; }; class OnScreenMessagesView : public UI::InertView { diff --git a/ext/native/base/mutex.h b/ext/native/base/mutex.h index f1f9a3cd4..765bd8482 100644 --- a/ext/native/base/mutex.h +++ b/ext/native/base/mutex.h @@ -19,6 +19,8 @@ #undef p #undef DrawText #undef itoa +#undef min +#undef max #else #include