Permalink
Browse files

2012-05-30 Jeff Rogers <jrogers@rim.com>

        Fix CompareAndSwap and AtomicExchange operations on QNX.
        Was using incorrect logic which could cause infinite loop.
        Found when running tests.

        * src/atomicops_internals_arm_qnx.h:
        (v8::internal::NoBarrier_CompareAndSwap):
        (v8::internal::NoBarrier_AtomicExchange):
  • Loading branch information...
1 parent 123e1e2 commit 4e68d27b4b0f37f60f6e1e1eb6196bc3c163d3ff Jeff Rogers committed May 31, 2012
Showing with 2 additions and 7 deletions.
  1. +2 −7 src/atomicops_internals_arm_qnx.h
@@ -40,12 +40,7 @@ inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
Atomic32 old_value,
Atomic32 new_value) {
Atomic32 prev_value = *ptr;
- do {
- if (!_smp_cmpxchg(reinterpret_cast<volatile unsigned*>(ptr), old_value, new_value)) {
- return old_value;
- }
- prev_value = *ptr;
- } while (prev_value == old_value);
+ _smp_cmpxchg(reinterpret_cast<volatile unsigned*>(ptr), old_value, new_value);
return prev_value;
}
@@ -54,7 +49,7 @@ inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
Atomic32 old_value;
do {
old_value = *ptr;
- } while (_smp_cmpxchg(reinterpret_cast<volatile unsigned*>(ptr), old_value, new_value));
+ } while (!_smp_cmpxchg(reinterpret_cast<volatile unsigned*>(ptr), old_value, new_value));
return old_value;
}

0 comments on commit 4e68d27

Please sign in to comment.