diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-09-25 21:31:00 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-09-25 21:48:24 +0200 |
commit | 1f7c5c88ca384baa312a0714c6e93174605418a7 (patch) | |
tree | feeef5efadbbc839a35f8f8d0d393c43578d1ad6 /cpukit/score/include/rtems/score/cpustdatomic.h | |
parent | ARMv7M: Improve exception handler routine and add comments on SP selection (diff) | |
download | rtems-1f7c5c88ca384baa312a0714c6e93174605418a7.tar.bz2 |
score: Fix atomic compare exchange
Diffstat (limited to 'cpukit/score/include/rtems/score/cpustdatomic.h')
-rw-r--r-- | cpukit/score/include/rtems/score/cpustdatomic.h | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/cpukit/score/include/rtems/score/cpustdatomic.h b/cpukit/score/include/rtems/score/cpustdatomic.h index 2696e3afbc..c66dd7eb34 100644 --- a/cpukit/score/include/rtems/score/cpustdatomic.h +++ b/cpukit/score/include/rtems/score/cpustdatomic.h @@ -577,13 +577,17 @@ static inline bool _CPU_atomic_Compare_exchange_uint( CPU_atomic_Uint *obj, unsi #else bool success; ISR_Level level; + unsigned int actual; (void) succ; (void) fail; _ISR_Disable( level ); - success = *obj == *expected; + actual = *obj; + success = ( actual == *expected ); if ( success ) { *obj = desired; + } else { + *expected = actual; } _ISR_Enable( level ); @@ -600,13 +604,17 @@ static inline bool _CPU_atomic_Compare_exchange_ulong( CPU_atomic_Ulong *obj, un #else bool success; ISR_Level level; + unsigned long actual; (void) succ; (void) fail; _ISR_Disable( level ); - success = *obj == *expected; + actual = *obj; + success = ( actual == *expected ); if ( success ) { *obj = desired; + } else { + *expected = actual; } _ISR_Enable( level ); @@ -623,13 +631,17 @@ static inline bool _CPU_atomic_Compare_exchange_ptr( CPU_atomic_Pointer *obj, vo #else bool success; ISR_Level level; + uintptr_t actual; (void) succ; (void) fail; _ISR_Disable( level ); - success = *obj == (uintptr_t) *expected; + actual = *obj; + success = ( actual == (uintptr_t) *expected ); if ( success ) { *obj = (uintptr_t) desired; + } else { + *expected = (void *) actual; } _ISR_Enable( level ); |