From 8f80ccc6353f929c9861586b27f165b7ac66273b Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Mon, 14 Apr 2014 17:43:49 +0000 Subject: [PATCH] sanitizer_atomic_msvc.h: add atomic_fetch_{add,sub} overloads for uintptr_t This should hopefully unbreak the MSVC build after r206178. llvm-svn: 206200 --- .../sanitizer_common/sanitizer_atomic_msvc.h | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_atomic_msvc.h b/compiler-rt/lib/sanitizer_common/sanitizer_atomic_msvc.h index 5fe469092461..4afde489e4a7 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_atomic_msvc.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_atomic_msvc.h @@ -26,6 +26,9 @@ extern "C" long _InterlockedExchangeAdd( // NOLINT #pragma intrinsic(_InterlockedExchangeAdd) #ifdef _WIN64 +extern "C" long long _InterlockedExchangeAdd64( // NOLINT + long long volatile * Addend, long long Value); // NOLINT +#pragma intrinsic(_InterlockedExchangeAdd64) extern "C" void *_InterlockedCompareExchangePointer( void *volatile *Destination, void *Exchange, void *Comparand); @@ -108,6 +111,19 @@ INLINE u32 atomic_fetch_add(volatile atomic_uint32_t *a, (volatile long*)&a->val_dont_use, (long)v); // NOLINT } +INLINE uptr atomic_fetch_add(volatile atomic_uintptr_t *a, + uptr v, memory_order mo) { + (void)mo; + DCHECK(!((uptr)a % sizeof(*a))); +#ifdef _WIN64 + return (uptr)_InterlockedExchangeAdd64( + (volatile long long*)&a->val_dont_use, (long long)v); // NOLINT +#else + return (uptr)_InterlockedExchangeAdd( + (volatile long*)&a->val_dont_use, (long)v); // NOLINT +#endif +} + INLINE u32 atomic_fetch_sub(volatile atomic_uint32_t *a, u32 v, memory_order mo) { (void)mo; @@ -116,6 +132,19 @@ INLINE u32 atomic_fetch_sub(volatile atomic_uint32_t *a, (volatile long*)&a->val_dont_use, -(long)v); // NOLINT } +INLINE uptr atomic_fetch_sub(volatile atomic_uintptr_t *a, + uptr v, memory_order mo) { + (void)mo; + DCHECK(!((uptr)a % sizeof(*a))); +#ifdef _WIN64 + return (uptr)_InterlockedExchangeAdd64( + (volatile long long*)&a->val_dont_use, -(long long)v); // NOLINT +#else + return (uptr)_InterlockedExchangeAdd( + (volatile long*)&a->val_dont_use, -(long)v); // NOLINT +#endif +} + INLINE u8 atomic_exchange(volatile atomic_uint8_t *a, u8 v, memory_order mo) { (void)mo;