equal
deleted
inserted
replaced
43 } |
43 } |
44 }; |
44 }; |
45 |
45 |
46 template<> |
46 template<> |
47 template<typename T> |
47 template<typename T> |
48 inline T Atomic::PlatformXchg<4>::operator()(T exchange_value, |
48 inline T Atomic::PlatformXchg<4>::operator()(T volatile* dest, |
49 T volatile* dest, |
49 T exchange_value, |
50 atomic_memory_order order) const { |
50 atomic_memory_order order) const { |
51 STATIC_ASSERT(4 == sizeof(T)); |
51 STATIC_ASSERT(4 == sizeof(T)); |
52 __asm__ volatile ( "swap [%2],%0" |
52 __asm__ volatile ( "swap [%2],%0" |
53 : "=r" (exchange_value) |
53 : "=r" (exchange_value) |
54 : "0" (exchange_value), "r" (dest) |
54 : "0" (exchange_value), "r" (dest) |
56 return exchange_value; |
56 return exchange_value; |
57 } |
57 } |
58 |
58 |
59 template<> |
59 template<> |
60 template<typename T> |
60 template<typename T> |
61 inline T Atomic::PlatformXchg<8>::operator()(T exchange_value, |
61 inline T Atomic::PlatformXchg<8>::operator()(T volatile* dest, |
62 T volatile* dest, |
62 T exchange_value, |
63 atomic_memory_order order) const { |
63 atomic_memory_order order) const { |
64 STATIC_ASSERT(8 == sizeof(T)); |
64 STATIC_ASSERT(8 == sizeof(T)); |
65 T old_value = *dest; |
65 T old_value = *dest; |
66 while (true) { |
66 while (true) { |
67 T result = cmpxchg(exchange_value, dest, old_value); |
67 T result = cmpxchg(exchange_value, dest, old_value); |