Fix sdk_x86 build

(cherry picked from commit 26b8c9d432adc2fc71438050377cb6106dffde1a)
(cherry picked from commit 2fc2bd6aaa1c9a743f2d2bb9d81ab1570e510923)

Change-Id: I20a705cb83279ff6b6fdc4a543853e020eb34a04
diff --git a/src/common_test.h b/src/common_test.h
index a3e530b..ea5e96b 100644
--- a/src/common_test.h
+++ b/src/common_test.h
@@ -80,10 +80,12 @@
       c = 0;
       // prevent g < 0 which would potentially allow an overflow later
       if (--g < 0) {
+        *dst_size = 0;
         return NULL;
       }
     } else if (g != 3) {
       // we only allow = to be at the end
+      *dst_size = 0;
       return NULL;
     }
     t = (t << 6) | c;
@@ -99,11 +101,14 @@
     }
   }
   if (y != 0) {
+    *dst_size = 0;
     return NULL;
   }
   UniquePtr<byte[]> dst(new byte[tmp.size()]);
   if (dst_size != NULL) {
     *dst_size = tmp.size();
+  } else {
+    *dst_size = 0;
   }
   std::copy(tmp.begin(), tmp.end(), dst.get());
   return dst.release();
diff --git a/src/jni_internal.cc b/src/jni_internal.cc
index 56589a1..714ca96 100644
--- a/src/jni_internal.cc
+++ b/src/jni_internal.cc
@@ -115,6 +115,12 @@
 
   return reinterpret_cast<T>(ref);
 }
+// Explicit instantiations
+template jclass AddLocalReference<jclass>(JNIEnv* public_env, const Object* const_obj);
+template jobject AddLocalReference<jobject>(JNIEnv* public_env, const Object* const_obj);
+template jobjectArray AddLocalReference<jobjectArray>(JNIEnv* public_env, const Object* const_obj);
+template jstring AddLocalReference<jstring>(JNIEnv* public_env, const Object* const_obj);
+template jthrowable AddLocalReference<jthrowable>(JNIEnv* public_env, const Object* const_obj);
 
 // For external use.
 template<typename T>
diff --git a/src/thread_x86.cc b/src/thread_x86.cc
index 85da1f3..30caaec 100644
--- a/src/thread_x86.cc
+++ b/src/thread_x86.cc
@@ -30,6 +30,11 @@
 #include <asm/ldt.h>
 #endif
 
+// TODO: add SYS_modify_ldt definition to bionic
+#ifndef SYS_modify_ldt
+#define SYS_modify_ldt __NR_modify_ldt
+#endif
+
 namespace art {
 
 void Thread::InitCpu() {