diff options
| author | Etienne Bergeron <etienneb@google.com> | 2016-07-06 16:33:57 +0000 |
|---|---|---|
| committer | Etienne Bergeron <etienneb@google.com> | 2016-07-06 16:33:57 +0000 |
| commit | 65c00a2b3e123d2fefca72751b9e73b3f245a066 (patch) | |
| tree | d3cd992f2b65f679577140da32b74992fe319459 | |
| parent | 743f7f1aff3b35f787b4b8e2974fd14ce4019926 (diff) | |
| download | bcm5719-llvm-65c00a2b3e123d2fefca72751b9e73b3f245a066.tar.gz bcm5719-llvm-65c00a2b3e123d2fefca72751b9e73b3f245a066.zip | |
[asan Win64] Implement atomic_compare_exchange_strong for 8 bit
Patch by: Wei Wang
Differential Revision: http://reviews.llvm.org/D21950
llvm-svn: 274634
| -rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_atomic_msvc.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_atomic_msvc.h b/compiler-rt/lib/sanitizer_common/sanitizer_atomic_msvc.h index 07aed2a12c3..6d94056d8c6 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_atomic_msvc.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_atomic_msvc.h @@ -33,6 +33,10 @@ extern "C" long _InterlockedExchange( // NOLINT extern "C" long _InterlockedExchangeAdd( // NOLINT long volatile * Addend, long Value); // NOLINT #pragma intrinsic(_InterlockedExchangeAdd) +extern "C" char _InterlockedCompareExchange8( // NOLINT + char volatile *Destination, // NOLINT + char Exchange, char Comparand); // NOLINT +#pragma intrinsic(_InterlockedCompareExchange8) extern "C" short _InterlockedCompareExchange16( // NOLINT short volatile *Destination, // NOLINT short Exchange, short Comparand); // NOLINT @@ -175,15 +179,13 @@ INLINE bool atomic_compare_exchange_strong(volatile atomic_uint8_t *a, u8 *cmp, u8 xchgv, memory_order mo) { -#ifdef _WIN64 - // TODO(wwchrome): Implement same functionality without inline asm. - // Inline asm not supported in Win64. - __debugbreak(); - return false; -#else (void)mo; DCHECK(!((uptr)a % sizeof(*a))); u8 cmpv = *cmp; +#ifdef _WIN64 + u8 prev = (u8)_InterlockedCompareExchange8( + (volatile char*)&a->val_dont_use, (char)xchgv, (char)cmpv); +#else u8 prev; __asm { mov al, cmpv @@ -192,11 +194,11 @@ INLINE bool atomic_compare_exchange_strong(volatile atomic_uint8_t *a, lock cmpxchg [ecx], dl mov prev, al } +#endif if (prev == cmpv) return true; *cmp = prev; return false; -#endif } INLINE bool atomic_compare_exchange_strong(volatile atomic_uintptr_t *a, |

