Fix win_sdk build using android_atomic_*.

Note that GCC built-in such as __sync_add_and_fetch are available on Mac
and Linux, but not on win_sdk. Changing to use __atomic_inc didn't work
earlier either. It will cause silent failures because __atomic_inc will
return the new value, while __sync_fetch_and_add will return the
original value.

Note that android_atomic_inc will return the new value. So this fix
should settle it.

Change-Id: Ia210bf2a491822cc081452bb629e1995e54e0db9
diff --git a/lib/Support/Atomic.cpp b/lib/Support/Atomic.cpp
index 3001f6c..5a62c7f 100644
--- a/lib/Support/Atomic.cpp
+++ b/lib/Support/Atomic.cpp
@@ -13,6 +13,9 @@
 
 #include "llvm/Support/Atomic.h"
 #include "llvm/Config/llvm-config.h"
+#if defined(ANDROID_TARGET_BUILD)
+#include "cutils/atomic.h"
+#endif
 
 using namespace llvm;
 
@@ -43,6 +46,8 @@
   if (result == old_value)
     *ptr = new_value;
   return result;
+#elif defined(ANDROID_TARGET_BUILD)
+  return android_atomic_cas(old_value, new_value, (volatile int32_t*)ptr);
 #elif defined(__GNUC__)
   return __sync_val_compare_and_swap(ptr, old_value, new_value);
 #elif defined(_MSC_VER)
@@ -56,6 +61,8 @@
 #if LLVM_HAS_ATOMICS == 0
   ++(*ptr);
   return *ptr;
+#elif defined(ANDROID_TARGET_BUILD)
+  return android_atomic_inc((volatile int32_t*)ptr);
 #elif defined(__GNUC__)
   return __sync_add_and_fetch(ptr, 1);
 #elif defined(_MSC_VER)
@@ -69,6 +76,8 @@
 #if LLVM_HAS_ATOMICS == 0
   --(*ptr);
   return *ptr;
+#elif defined(ANDROID_TARGET_BUILD)
+  return android_atomic_dec((volatile int32_t*)ptr);
 #elif defined(__GNUC__)
   return __sync_sub_and_fetch(ptr, 1);
 #elif defined(_MSC_VER)
@@ -82,6 +91,8 @@
 #if LLVM_HAS_ATOMICS == 0
   *ptr += val;
   return *ptr;
+#elif defined(ANDROID_TARGET_BUILD)
+  return android_atomic_add((int32_t)val, (volatile int32_t*)ptr);
 #elif defined(__GNUC__)
   return __sync_add_and_fetch(ptr, val);
 #elif defined(_MSC_VER)