From 6edb297e0e3be79bdf91f841879d3358454a6601 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Tue, 22 Sep 2009 16:56:18 -0400 Subject: [PATCH] update x86_64 cmpxchg Signed-off-by: Mathieu Desnoyers --- arch_atomic_x86.h | 2 +- tests/test_atomic.c | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/arch_atomic_x86.h b/arch_atomic_x86.h index 97a7cdd..6b33d45 100644 --- a/arch_atomic_x86.h +++ b/arch_atomic_x86.h @@ -75,7 +75,7 @@ unsigned long _atomic_cmpxchg(volatile void *addr, unsigned long old, #if (BITS_PER_LONG == 64) case 8: { - unsigned int result = old; + unsigned long result = old; __asm__ __volatile__( "lock; cmpxchgq %2, %1" : "+a"(result), "+m"(*__hp(addr)) diff --git a/tests/test_atomic.c b/tests/test_atomic.c index bf84757..3d2b64e 100644 --- a/tests/test_atomic.c +++ b/tests/test_atomic.c @@ -13,20 +13,20 @@ static struct testvals vals; #define do_test(ptr) \ do { \ - __typeof__(*ptr) v; \ + __typeof__(*(ptr)) v; \ \ atomic_add(ptr, 10); \ - assert(*ptr == 10); \ - atomic_add(ptr, -11); \ - assert(*ptr == (__typeof__(*ptr))-1U); \ - v = cmpxchg(ptr, -1, 22); \ - assert(*ptr == 22); \ - assert(v == (__typeof__(*ptr))-1U); \ + assert(*(ptr) == 10); \ + atomic_add(ptr, -11UL); \ + assert(*(ptr) == (__typeof__(*(ptr)))-1UL); \ + v = cmpxchg(ptr, -1UL, 22); \ + assert(*(ptr) == 22); \ + assert(v == (__typeof__(*(ptr)))-1UL); \ v = cmpxchg(ptr, 33, 44); \ - assert(*ptr == 22); \ + assert(*(ptr) == 22); \ assert(v == 22); \ v = xchg(ptr, 55); \ - assert(*ptr == 55); \ + assert(*(ptr) == 55); \ assert(v == 22); \ } while (0) -- 2.34.1