Skip to content

Commit 9d2e8a0

Browse files
authored
This branch was necessary to avoid races. (#581)
See https://herbsutter.com/2014/02/19/reader-qa-is-stdatomic_compare_exchange_-implementable/ for some related discussion.
1 parent 0b8a259 commit 9d2e8a0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

include/EASTL/internal/atomic/compiler/msvc/compiler_msvc.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,15 @@ struct FixedWidth128
161161
comparandIntegral, EASTL_ATOMIC_TYPE_PUN_CAST(integralType, (desired)), \
162162
MemoryOrder, cmpxchgStrongIntrinsic); \
163163
\
164-
*(expected) = EASTL_ATOMIC_TYPE_PUN_CAST(type, oldIntegral); \
165-
ret = (oldIntegral == comparandIntegral); \
164+
if (oldIntegral == comparandIntegral) \
165+
{ \
166+
ret = true; \
167+
} \
168+
else \
169+
{ \
170+
*(expected) = EASTL_ATOMIC_TYPE_PUN_CAST(type, oldIntegral); \
171+
ret = false; \
172+
} \
166173
}
167174

168175
/**

0 commit comments

Comments
 (0)