From 8a5d8c4d2826830b8a5bbce207145fc5436119a5 Mon Sep 17 00:00:00 2001 From: Timur Iskhodzhanov Date: Thu, 5 Apr 2012 17:16:32 +0000 Subject: [PATCH] [ASan/Win] Fix build by using inline assembly instead of an unavailable intrinsic function git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@154106 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_win.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/asan/asan_win.cc b/lib/asan/asan_win.cc index baa8268b3..dbc77c34e 100644 --- a/lib/asan/asan_win.cc +++ b/lib/asan/asan_win.cc @@ -235,7 +235,16 @@ int AtomicInc(int *a) { } uint16_t AtomicExchange(uint16_t *a, uint16_t new_val) { - return InterlockedExchange16(a, new_val); + // InterlockedExchange16 seems unavailable on some MSVS installations. + // Everybody stand back, I pretend to know inline assembly! + // FIXME: I assume VC is smart enough to save/restore eax/ecx? + __asm { + mov eax, a + mov cx, new_val + xchg [eax], cx + mov new_val, cx + } + return new_val; } const char* AsanGetEnv(const char* name) { -- 2.11.4.GIT