Skip to content

Commit

Permalink
Fix incorrect return values in OSAtomic
Browse files Browse the repository at this point in the history
  • Loading branch information
Exzap committed Jun 15, 2023
1 parent 808d1bb commit 633e5c0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Cafe/OS/libs/coreinit/coreinit_Atomic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ namespace coreinit

uint32 OSAddAtomic(std::atomic<uint32be>* mem, uint32 adder)
{
// used by SDL Wii U port
uint32be knownValue;
while (true)
{
uint32be knownValue = mem->load();
knownValue = mem->load();
uint32be newValue = knownValue + adder;
if (mem->compare_exchange_strong(knownValue, newValue))
break;
Expand Down Expand Up @@ -68,7 +69,7 @@ namespace coreinit
uint64be knownValue;
while (true)
{
uint64be knownValue = mem->load();
knownValue = mem->load();
uint64be newValue = knownValue + adder;
if (mem->compare_exchange_strong(knownValue, newValue))
break;
Expand All @@ -81,7 +82,7 @@ namespace coreinit
uint64be knownValue;
while (true)
{
uint64be knownValue = mem->load();
knownValue = mem->load();
uint64be newValue = knownValue & val;
if (mem->compare_exchange_strong(knownValue, newValue))
break;
Expand All @@ -94,7 +95,7 @@ namespace coreinit
uint64be knownValue;
while (true)
{
uint64be knownValue = mem->load();
knownValue = mem->load();
uint64be newValue = knownValue | val;
if (mem->compare_exchange_strong(knownValue, newValue))
break;
Expand Down

0 comments on commit 633e5c0

Please sign in to comment.