Skip to content

Commit b379fe5

Browse files
committed
tsan/asan: second attemp on msvc atomics
llvm-svn: 159447
1 parent 3f568c1 commit b379fe5

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_atomic_msvc.h

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@
1515
#ifndef SANITIZER_ATOMIC_MSVC_H
1616
#define SANITIZER_ATOMIC_MSVC_H
1717

18-
#include <intrin.h>
18+
void _ReadWriteBarrier();
19+
#pragma intrinsic(_ReadWriteBarrier)
20+
void _mm_mfence();
21+
#pragma intrinsic(_mm_mfence)
22+
void _mm_pause();
23+
#pragma intrinsic(_mm_pause)
24+
long _InterlockedExchangeAdd(long volatile * Addend, long Value); // NOLINT
25+
#pragma intrinsic(_InterlockedExchangeAdd)
1926

2027
namespace __sanitizer {
2128

@@ -79,9 +86,9 @@ INLINE u8 atomic_exchange(volatile atomic_uint8_t *a,
7986
DCHECK(!((uptr)a % sizeof(*a)));
8087
__asm {
8188
mov eax, a
82-
mov cx, v
83-
xchg [eax], cx // NOLINT
84-
mov v, cx
89+
mov cl, v
90+
xchg [eax], cl // NOLINT
91+
mov v, cl
8592
}
8693
return v;
8794
}
@@ -92,9 +99,9 @@ INLINE u16 atomic_exchange(volatile atomic_uint16_t *a,
9299
DCHECK(!((uptr)a % sizeof(*a)));
93100
__asm {
94101
mov eax, a
95-
mov cl, v
96-
xchg [eax], cl // NOLINT
97-
mov v, cl
102+
mov cx, v
103+
xchg [eax], cx // NOLINT
104+
mov v, cx
98105
}
99106
return v;
100107
}

0 commit comments

Comments
 (0)