Fix O0 build.

Use builtin for x86 cmpxchg as inline asm defeats O0 register allocator.
Add missing const static field definitions.

Change-Id: I10e41ddea90ce156cdb1ca43f4bf9d6d4b6c4259
diff --git a/src/atomic.cc b/src/atomic.cc
index 4efb061..f2a9982 100644
--- a/src/atomic.cc
+++ b/src/atomic.cc
@@ -130,20 +130,9 @@
   } while (__builtin_expect(status != 0, 0));
   return prev == old_value;
 #elif defined(__i386__)
-  // cmpxchg8b implicitly uses %ebx which is also the PIC register.
-  int8_t status;
-  __asm__ __volatile__ (
-      "pushl          %%ebx\n"
-      "movl           (%3), %%ebx\n"
-      "movl           4(%3), %%ecx\n"
-      "lock cmpxchg8b %1\n"
-      "sete           %0\n"
-      "popl           %%ebx"
-      : "=R" (status), "+m" (*addr)
-      : "A"(old_value), "D" (&new_value)
-      : "%ecx"
-      );
-  return status != 0;
+  // The compiler does the right job and works better than inline assembly, especially with -O0
+  // compilation.
+  return __sync_bool_compare_and_swap(addr, old_value, new_value);
 #else
 #error Unexpected architecture
 #endif
diff --git a/src/dex2oat.cc b/src/dex2oat.cc
index 65b3ddb..235c068 100644
--- a/src/dex2oat.cc
+++ b/src/dex2oat.cc
@@ -640,6 +640,8 @@
   pthread_attr_t attr_;
   pthread_t pthread_;
 };
+const unsigned int WatchDog::kWatchDogWarningSeconds;
+const unsigned int WatchDog::kWatchDogTimeoutSeconds;
 
 static int dex2oat(int argc, char** argv) {
   InitLogging(argv);