89 DEFINE_STUB_XCHG(4, int32_t, os::atomic_xchg_func) |
89 DEFINE_STUB_XCHG(4, int32_t, os::atomic_xchg_func) |
90 DEFINE_STUB_XCHG(8, int64_t, os::atomic_xchg_long_func) |
90 DEFINE_STUB_XCHG(8, int64_t, os::atomic_xchg_long_func) |
91 |
91 |
92 #undef DEFINE_STUB_XCHG |
92 #undef DEFINE_STUB_XCHG |
93 |
93 |
94 #define DEFINE_STUB_CMPXCHG(ByteSize, StubType, StubName) \ |
94 #define DEFINE_STUB_CMPXCHG(ByteSize, StubType, StubName) \ |
95 template<> \ |
95 template<> \ |
96 template<typename T> \ |
96 template<typename T> \ |
97 inline T Atomic::PlatformCmpxchg<ByteSize>::operator()(T exchange_value, \ |
97 inline T Atomic::PlatformCmpxchg<ByteSize>::operator()(T volatile* dest, \ |
98 T volatile* dest, \ |
98 T compare_value, \ |
99 T compare_value, \ |
99 T exchange_value, \ |
100 atomic_memory_order order) const { \ |
100 atomic_memory_order order) const { \ |
101 STATIC_ASSERT(ByteSize == sizeof(T)); \ |
101 STATIC_ASSERT(ByteSize == sizeof(T)); \ |
102 return cmpxchg_using_helper<StubType>(StubName, exchange_value, dest, compare_value); \ |
102 return cmpxchg_using_helper<StubType>(StubName, dest, compare_value, exchange_value); \ |
103 } |
103 } |
104 |
104 |
105 DEFINE_STUB_CMPXCHG(1, int8_t, os::atomic_cmpxchg_byte_func) |
105 DEFINE_STUB_CMPXCHG(1, int8_t, os::atomic_cmpxchg_byte_func) |
106 DEFINE_STUB_CMPXCHG(4, int32_t, os::atomic_cmpxchg_func) |
106 DEFINE_STUB_CMPXCHG(4, int32_t, os::atomic_cmpxchg_func) |
107 DEFINE_STUB_CMPXCHG(8, int64_t, os::atomic_cmpxchg_long_func) |
107 DEFINE_STUB_CMPXCHG(8, int64_t, os::atomic_cmpxchg_long_func) |
171 } |
171 } |
172 } |
172 } |
173 |
173 |
174 template<> |
174 template<> |
175 template<typename T> |
175 template<typename T> |
176 inline T Atomic::PlatformCmpxchg<8>::operator()(T exchange_value, |
176 inline T Atomic::PlatformCmpxchg<8>::operator()(T volatile* dest, |
177 T volatile* dest, |
|
178 T compare_value, |
177 T compare_value, |
|
178 T exchange_value, |
179 atomic_memory_order order) const { |
179 atomic_memory_order order) const { |
180 STATIC_ASSERT(8 == sizeof(T)); |
180 STATIC_ASSERT(8 == sizeof(T)); |
181 int32_t ex_lo = (int32_t)exchange_value; |
181 int32_t ex_lo = (int32_t)exchange_value; |
182 int32_t ex_hi = *( ((int32_t*)&exchange_value) + 1 ); |
182 int32_t ex_hi = *( ((int32_t*)&exchange_value) + 1 ); |
183 int32_t cmp_lo = (int32_t)compare_value; |
183 int32_t cmp_lo = (int32_t)compare_value; |