Chromium Code Reviews| Index: Source/wtf/Atomics.h |
| diff --git a/Source/wtf/Atomics.h b/Source/wtf/Atomics.h |
| index 6013a8321849c34627727b7387080855f064a685..51e5ddba80af7bacf945d9fc4f66ccc54fbb4802 100644 |
| --- a/Source/wtf/Atomics.h |
| +++ b/Source/wtf/Atomics.h |
| @@ -162,6 +162,24 @@ ALWAYS_INLINE void releaseStore(void* volatile* ptr, void* value) |
| { |
| __tsan_atomic64_store(reinterpret_cast<volatile __tsan_atomic64*>(ptr), reinterpret_cast<__tsan_atomic64>(value), __tsan_memory_order_release); |
| } |
| +ALWAYS_INLINE void releaseStore(volatile float* ptr, float value) |
| +{ |
| + union { |
|
tkent
2015/08/07 01:10:04
should have static_assert for sizeof(int) == sizeo
Raymond Toy
2015/08/07 16:16:37
Done.
|
| + int ivalue; |
| + float fvalue; |
| + } u; |
| + u.fvalue = value; |
| + __tsan_atomic32_store(reinterpret_cast<volatile __tsan_atomic32*>(ptr), u.ivalue, __tsan_memory_order_release); |
| +} |
| +ALWAYS_INLINE void releaseStore(volatile double* ptr, double value) |
| +{ |
| + union { |
| + long ivalue; |
| + double dvalue; |
| + } u; |
| + u.dvalue = value; |
| + __tsan_atomic64_store(reinterpret_cast<volatile __tsan_atomic64*>(ptr), u.ivalue, __tsan_memory_order_release); |
| +} |
| ALWAYS_INLINE int acquireLoad(volatile const int* ptr) |
| { |
| @@ -183,6 +201,24 @@ ALWAYS_INLINE void* acquireLoad(void* volatile const* ptr) |
| { |
| return reinterpret_cast<void*>(__tsan_atomic64_load(reinterpret_cast<volatile const __tsan_atomic64*>(ptr), __tsan_memory_order_acquire)); |
| } |
| +ALWAYS_INLINE float acquireLoad(volatile const float* ptr) |
| +{ |
| + union { |
| + int ivalue; |
| + float fvalue; |
| + } u; |
| + u.ivalue = __tsan_atomic32_load(reinterpret_cast<volatile const int*>(ptr), __tsan_memory_order_acquire); |
| + return u.fvalue; |
| +} |
| +ALWAYS_INLINE double acquireLoad(volatile const double* ptr) |
| +{ |
| + union { |
| + long ivalue; |
| + double dvalue; |
| + } u; |
| + u.ivalue = static_cast<long>(__tsan_atomic64_load(reinterpret_cast<volatile const __tsan_atomic64*>(ptr), __tsan_memory_order_acquire)); |
| + return u.dvalue; |
| +} |
| #endif |
| #else // defined(THREAD_SANITIZER) |
| @@ -243,6 +279,17 @@ ALWAYS_INLINE void releaseStore(void* volatile* ptr, void* value) |
| MEMORY_BARRIER(); |
| *ptr = value; |
| } |
| +ALWAYS_INLINE void releaseStore(volatile float* ptr, float value) |
| +{ |
| + MEMORY_BARRIER(); |
| + *ptr = value; |
| +} |
| +ALWAYS_INLINE void releaseStore(volatile double* ptr, double value) |
| +{ |
| + MEMORY_BARRIER(); |
| + *ptr = value; |
| +} |
| + |
| ALWAYS_INLINE int acquireLoad(volatile const int* ptr) |
| { |
| @@ -280,6 +327,18 @@ ALWAYS_INLINE void* acquireLoad(void* volatile const* ptr) |
| MEMORY_BARRIER(); |
| return value; |
| } |
| +ALWAYS_INLINE float acquireLoad(volatile const float* ptr) |
| +{ |
| + float value = *ptr; |
| + MEMORY_BARRIER(); |
| + return value; |
| +} |
| +ALWAYS_INLINE double acquireLoad(volatile const double* ptr) |
| +{ |
| + double value = *ptr; |
| + MEMORY_BARRIER(); |
| + return value; |
| +} |
| #if defined(ADDRESS_SANITIZER) |