summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/k_condition_variable.cpp
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2023-03-29 04:28:27 +0200
committerLiam <byteslice@airmail.cc>2023-03-29 04:28:27 +0200
commit9efd95cda50605c52a9652b5ad01e09e6fd86106 (patch)
tree36317a3e924a002f68512bcac044c137e4233fef /src/core/hle/kernel/k_condition_variable.cpp
parentMerge pull request #10003 from german77/disconnect (diff)
downloadyuzu-9efd95cda50605c52a9652b5ad01e09e6fd86106.tar
yuzu-9efd95cda50605c52a9652b5ad01e09e6fd86106.tar.gz
yuzu-9efd95cda50605c52a9652b5ad01e09e6fd86106.tar.bz2
yuzu-9efd95cda50605c52a9652b5ad01e09e6fd86106.tar.lz
yuzu-9efd95cda50605c52a9652b5ad01e09e6fd86106.tar.xz
yuzu-9efd95cda50605c52a9652b5ad01e09e6fd86106.tar.zst
yuzu-9efd95cda50605c52a9652b5ad01e09e6fd86106.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/k_condition_variable.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/core/hle/kernel/k_condition_variable.cpp b/src/core/hle/kernel/k_condition_variable.cpp
index 73017cf99..efbac0e6a 100644
--- a/src/core/hle/kernel/k_condition_variable.cpp
+++ b/src/core/hle/kernel/k_condition_variable.cpp
@@ -33,21 +33,26 @@ bool UpdateLockAtomic(Core::System& system, u32* out, KProcessAddress address, u
auto& monitor = system.Monitor();
const auto current_core = system.Kernel().CurrentPhysicalCoreIndex();
- // Load the value from the address.
- const auto expected = monitor.ExclusiveRead32(current_core, GetInteger(address));
+ u32 expected{};
- // Orr in the new mask.
- u32 value = expected | new_orr_mask;
+ while (true) {
+ // Load the value from the address.
+ expected = monitor.ExclusiveRead32(current_core, GetInteger(address));
- // If the value is zero, use the if_zero value, otherwise use the newly orr'd value.
- if (!expected) {
- value = if_zero;
- }
+ // Orr in the new mask.
+ u32 value = expected | new_orr_mask;
+
+ // If the value is zero, use the if_zero value, otherwise use the newly orr'd value.
+ if (!expected) {
+ value = if_zero;
+ }
+
+ // Try to store.
+ if (monitor.ExclusiveWrite32(current_core, GetInteger(address), value)) {
+ break;
+ }
- // Try to store.
- if (!monitor.ExclusiveWrite32(current_core, GetInteger(address), value)) {
// If we failed to store, try again.
- return UpdateLockAtomic(system, out, address, if_zero, new_orr_mask);
}
// We're done.