tsan/asan: second attemp on msvc atomics


git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@159447 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/sanitizer_common/sanitizer_atomic_msvc.h b/lib/sanitizer_common/sanitizer_atomic_msvc.h
index 6bad94e..cf49631 100644
--- a/lib/sanitizer_common/sanitizer_atomic_msvc.h
+++ b/lib/sanitizer_common/sanitizer_atomic_msvc.h
@@ -15,7 +15,14 @@
 #ifndef SANITIZER_ATOMIC_MSVC_H
 #define SANITIZER_ATOMIC_MSVC_H
 
-#include <intrin.h>
+void _ReadWriteBarrier();
+#pragma intrinsic(_ReadWriteBarrier)
+void _mm_mfence();
+#pragma intrinsic(_mm_mfence)
+void _mm_pause();
+#pragma intrinsic(_mm_pause)
+long _InterlockedExchangeAdd(long volatile * Addend, long Value);  // NOLINT
+#pragma intrinsic(_InterlockedExchangeAdd)
 
 namespace __sanitizer {
 
@@ -79,9 +86,9 @@
   DCHECK(!((uptr)a % sizeof(*a)));
   __asm {
     mov eax, a
-    mov cx, v
-    xchg [eax], cx  // NOLINT
-    mov v, cx
+    mov cl, v
+    xchg [eax], cl  // NOLINT
+    mov v, cl
   }
   return v;
 }
@@ -92,9 +99,9 @@
   DCHECK(!((uptr)a % sizeof(*a)));
   __asm {
     mov eax, a
-    mov cl, v
-    xchg [eax], cl  // NOLINT
-    mov v, cl
+    mov cx, v
+    xchg [eax], cx  // NOLINT
+    mov v, cx
   }
   return v;
 }