diff --git a/rpcs3/Emu/Cell/Modules/cellCamera.cpp b/rpcs3/Emu/Cell/Modules/cellCamera.cpp index f8d87e2d85..b7df2efd28 100644 --- a/rpcs3/Emu/Cell/Modules/cellCamera.cpp +++ b/rpcs3/Emu/Cell/Modules/cellCamera.cpp @@ -639,7 +639,7 @@ s32 cellCameraIsOpen(s32 dev_num) std::lock_guard lock(g_camera->mutex); - return g_camera->is_open; + return g_camera->is_open.load(); } s32 cellCameraIsStarted(s32 dev_num) @@ -665,7 +665,7 @@ s32 cellCameraIsStarted(s32 dev_num) std::lock_guard lock(g_camera->mutex); - return g_camera->is_streaming; + return g_camera->is_streaming.load(); } error_code cellCameraGetAttribute(s32 dev_num, s32 attrib, vm::ptr arg1, vm::ptr arg2) diff --git a/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp b/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp index cf1c892b34..2a816d9839 100644 --- a/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp +++ b/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp @@ -192,7 +192,7 @@ error_code cellOskDialogLoadAsync(u32 container, vm::ptr dia }); // wait for check callback - while (done == false) + while (!done) { std::this_thread::yield(); } diff --git a/rpcs3/Emu/RSX/GL/GLPipelineCompiler.cpp b/rpcs3/Emu/RSX/GL/GLPipelineCompiler.cpp index 73f7bdb454..b70803dbe3 100644 --- a/rpcs3/Emu/RSX/GL/GLPipelineCompiler.cpp +++ b/rpcs3/Emu/RSX/GL/GLPipelineCompiler.cpp @@ -40,7 +40,7 @@ namespace gl { for (auto&& job : m_work_queue.pop_all()) { - if (m_context_ready.compare_and_swap_test(false, true)) + if (!m_context_ready.test_and_set()) { // Bind context on first use m_context_bind_func(m_context); diff --git a/rpcs3/Emu/RSX/GL/GLPresent.cpp b/rpcs3/Emu/RSX/GL/GLPresent.cpp index 97b8854b7f..53998b548f 100644 --- a/rpcs3/Emu/RSX/GL/GLPresent.cpp +++ b/rpcs3/Emu/RSX/GL/GLPresent.cpp @@ -212,7 +212,7 @@ void GLGSRender::flip(const rsx::display_flip_info_t& info) if (image_to_flip) { - if (m_frame->screenshot_toggle == true) + if (m_frame->screenshot_toggle) { m_frame->screenshot_toggle = false; diff --git a/rpcs3/Emu/RSX/VK/VKPresent.cpp b/rpcs3/Emu/RSX/VK/VKPresent.cpp index 8d3bdd6268..4e455bb53e 100644 --- a/rpcs3/Emu/RSX/VK/VKPresent.cpp +++ b/rpcs3/Emu/RSX/VK/VKPresent.cpp @@ -645,7 +645,7 @@ void VKGSRender::flip(const rsx::display_flip_info_t& info) direct_fbo->release(); } - if (m_frame->screenshot_toggle == true) + if (m_frame->screenshot_toggle) { m_frame->screenshot_toggle = false; diff --git a/rpcs3/util/atomic.hpp b/rpcs3/util/atomic.hpp index d412f60498..dbb372de47 100644 --- a/rpcs3/util/atomic.hpp +++ b/rpcs3/util/atomic.hpp @@ -1629,3 +1629,93 @@ public: } } }; + +template +class atomic_t : private atomic_t +{ + using base = atomic_t; + +public: + static constexpr std::size_t align = Align; + + using simple_type = bool; + + atomic_t() noexcept = default; + + atomic_t(const atomic_t&) = delete; + + atomic_t& operator =(const atomic_t&) = delete; + + constexpr atomic_t(bool value) noexcept + : base(value) + { + } + + bool load() const noexcept + { + return base::load() != 0; + } + + operator bool() const noexcept + { + return base::load() != 0; + } + + bool observe() const noexcept + { + return base::observe() != 0; + } + + void store(bool value) + { + base::store(value); + } + + bool operator =(bool value) + { + base::store(value); + return value; + } + + void release(bool value) + { + base::release(value); + } + + bool exchange(bool value) + { + return base::exchange(value) != 0; + } + + bool test_and_set() + { + return base::exchange(1) != 0; + } + + bool test_and_reset() + { + return base::exchange(0) != 0; + } + + bool test_and_invert() + { + return base::fetch_xor(1) != 0; + } + + // Timeout is discouraged + template + void wait(bool old_value, atomic_wait_timeout timeout = atomic_wait_timeout::inf) const noexcept + { + base::template wait(old_value, 1, timeout); + } + + void notify_one() noexcept + { + base::notify_one(1); + } + + void notify_all() noexcept + { + base::notify_all(1); + } +};