Merge "Add kernel version detection to emulator"
diff --git a/Makefile.android b/Makefile.android
index 600be7c..e509206 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -10,9 +10,8 @@
 
 # This defines EMULATOR_BUILD_64BITS to indicate that 64-bit binaries
 # must be generated by the build system. For now, only do it for
-# Linux and Darwin, since we the sources do not compile with Mingw-w64
-# yet due to differing procedure call ABI conventions.
-EMULATOR_BUILD_64BITS := $(strip $(filter linux darwin,$(HOST_OS)))
+# Windows, Linux and Darwin.
+EMULATOR_BUILD_64BITS := $(strip $(filter linux darwin windows,$(HOST_OS)))
 
 # Disable 64-bit build for Darwin platform builds.
 ifeq ($(HOST_OS),darwin)
@@ -78,18 +77,9 @@
 ifeq ($(HOST_OS),windows)
   # we need Win32 features that are available since Windows 2000 Professional/Server (NT 5.0)
   MY_CFLAGS += -DWINVER=0x501
-  MY_CFLAGS += -D_WIN32
   # LARGEADDRESSAWARE gives more address space to 32-bit process
   MY_LDFLAGS32 += -Xlinker --large-address-aware
-  ifneq ($(HOST_IS_64_BIT),)
-    # Microsoft 64-bit compiler define both _WIN32 and _WIN64
-    MY_CFLAGS += -D_WIN64
-    # amd64-mingw32msvc- toolchain still name it vfw32.  May change it once amd64-mingw32msvc-
-    # is stabilized
-    MY_LDLIBS += -lvfw32
-  else
-    MY_LDLIBS += -lvfw32
-  endif
+  MY_LDLIBS += -lvfw32
 endif
 
 ifeq ($(HOST_ARCH),ppc)
diff --git a/android-configure.sh b/android-configure.sh
index 42fe51d..3e13cc2 100755
--- a/android-configure.sh
+++ b/android-configure.sh
@@ -237,9 +237,16 @@
     fi
 fi  # IN_ANDROID_BUILD = no
 
-if [ -n "$CCACHE" -a -f "$CCACHE" ] ; then
-    CC="$CCACHE $CC"
-    log "Prebuilt   : CCACHE=$CCACHE"
+if [ -n "$CCACHE" -a -f "$CCACHE" ]; then
+    if [ "$HOST_OS" == "darwin" -a "$OPTION_DEBUG" == "yes" ]; then
+        # http://llvm.org/bugs/show_bug.cgi?id=20297
+        # ccache works for mingw/gdb, therefore probably works for gcc/gdb
+        log "Prebuilt   : CCACHE disabled for OSX debug builds"
+        CCACHE=
+    else
+        CC="$CCACHE $CC"
+        log "Prebuilt   : CCACHE=$CCACHE"
+    fi
 else
     log "Prebuilt   : CCACHE can't be found"
     CCACHE=
diff --git a/android-rebuild.sh b/android-rebuild.sh
index 8b54f09..8ca2c2a 100755
--- a/android-rebuild.sh
+++ b/android-rebuild.sh
@@ -75,12 +75,9 @@
 run make -j$HOST_NUM_CPUS OBJS_DIR="$OUT_DIR" ||
     panic "Could not build sources, please run 'make' to see why."
 
-RUN_64BIT_TESTS=true
-
 TEST_SHELL=
 EXE_SUFFIX=
 if [ "$MINGW" ]; then
-  RUN_64BIT_TESTS=
   TEST_SHELL=wine
   EXE_SUFFIX=.exe
 
@@ -100,13 +97,11 @@
     run $TEST_SHELL $OUT_DIR/$UNIT_TEST$EXE_SUFFIX || FAILURES="$FAILURES $UNIT_TEST"
     done
 
-    if [ "$RUN_64BIT_TESTS" ]; then
-        echo "Running 64-bit unit test suite."
-        for UNIT_TEST in emulator64_unittests emugl64_common_host_unittests; do
-            echo "   - $UNIT_TEST"
-            run $TEST_SHELL $OUT_DIR/$UNIT_TEST$EXE_SUFFIX || FAILURES="$FAILURES $UNIT_TEST"
-        done
-    fi
+    echo "Running 64-bit unit test suite."
+    for UNIT_TEST in emulator64_unittests emugl64_common_host_unittests; do
+        echo "   - $UNIT_TEST"
+        run $TEST_SHELL $OUT_DIR/$UNIT_TEST$EXE_SUFFIX || FAILURES="$FAILURES $UNIT_TEST"
+    done
 
     if [ "$FAILURES" ]; then
         panic "Unit test failures: $FAILURES"
diff --git a/android/build/common.sh b/android/build/common.sh
index 992b769..b859862 100644
--- a/android/build/common.sh
+++ b/android/build/common.sh
@@ -16,6 +16,7 @@
 # It contains common definitions.
 #
 PROGNAME=`basename $0`
+PROGDIR=`dirname $0`
 
 ## Logging support
 ##
@@ -203,27 +204,25 @@
         echo "Sorry, but mingw compilation is only supported on Linux !"
         exit 1
     fi
-    # Do we have the binaries installed
-    log "Mingw64    : Checking for mingw64 installation"
-    MINGW64_PREFIX=x86_64-w64-mingw32
-    find_program MINGW64_CC $MINGW64_PREFIX-gcc
-    if [ -n "$MINGW64_CC" ]; then
-        MINGW_CC=$MINGW64_CC
-        MINGW_PREFIX=$MINGW64_PREFIX
-    else
-    log "Mingw      : Checking for mingw32 installation"
-    MINGW32_PREFIX=i586-mingw32msvc
-    find_program MINGW32_CC $MINGW32_PREFIX-gcc
-    if [ -z "$MINGW32_CC" ] ; then
-            echo "ERROR: It looks like neither $MINGW64_PREFIX-cc nor $MINGW32_PREFIX-gcc"
-            echo "are in your path. Please install the mingw32 package !"
-        exit 1
-        fi
-        MINGW_CC=$MINGW32_CC
-        MINGW_PREFIX=$MINGW32_PREFIX
-        FORCE_32BIT=no
+    # Do we have our prebuilt mingw64 toolchain?
+    log "Mingw      : Looking for prebuilt mingw64 toolchain."
+    MINGW_DIR=$PROGDIR/../../prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8
+    MINGW_CC=
+    if [ -d "$MINGW_DIR" ]; then
+        MINGW_PREFIX=$MINGW_DIR/bin/x86_64-w64-mingw32
+        find_program MINGW_CC "$MINGW_PREFIX-gcc"
     fi
-    log2 "Mingw      : Found $MINGW32_CC"
+    if [ -z "$MINGW_CC" ]; then
+        log "Mingw      : Looking for mingw64 toolchain."
+        MINGW_PREFIX=x86_64-w64-mingw32
+        find_program MINGW_CC $MINGW_PREFIX-gcc
+    fi
+    if [ -z "$MINGW_CC" ]; then
+        echo "ERROR: It looks like no Mingw64 toolchain is available!"
+        echo "Please install x86_64-w64-mingw32 package !"
+        exit 1
+    fi
+    log2 "Mingw      : Found $MINGW_CC"
     CC=$MINGW_CC
     LD=$MINGW_CC
     AR=$MINGW_PREFIX-ar
diff --git a/target-i386/helper.c b/target-i386/helper.c
index 3e25e3a..388f7a7 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -146,7 +146,7 @@
             CPUID_MTRR | CPUID_CLFLUSH | CPUID_MCA |
         /* this feature is needed for Solaris and isn't fully implemented */
             CPUID_PSE36,
-        .ext_features = CPUID_EXT_SSE3,
+        .ext_features = CPUID_EXT_SSE3 | CPUID_EXT_SSSE3,
         .ext2_features = (PPRO_FEATURES & 0x0183F3FF) |
             CPUID_EXT2_LM | CPUID_EXT2_SYSCALL | CPUID_EXT2_NX |
             CPUID_EXT2_3DNOW | CPUID_EXT2_3DNOWEXT,