64-bit emulator

Patch to allow emulator searches for emulator64-${ARCH} first on
64-bit OS.  If none is found, the original behavior which searchs
for 32-bit emulator-${ARCH} is performed as usual.

64-bit emulator (which still emulates Android built in 32-bit) offers
up to 20% speedup compared to its 32-bit counterpart.

Details:

android/main-emulator.c
 1) search emulator64 based on the OS
 2) dlopen lib64OpenglRender in 64-bit

Makefile.*
 1) Rules to build 64-bit executable emulator64-{x86,arm} and libraries
    emulator64-{libui,libqemu,target-i386,target-arm,libelff,common}
 2) remove -Wa,-32
 3) Changes prebuit toolchain path

android-configure.h
android/build/common.h
 1) no longer force 32-bit build (because now prebuilts/tools/gcc-sdk/gcc
    can now handle 64-bit
 2) set ANDROID_PREBUILTS to correctly locate ccache

android/config/*/config-host.h
 1) Detect HOST_X86_64 and HOST_X86_64/HOST_I386

Misc 64-bit porting clean-up
 1) use %zx to print variable of type size_t in hex
 2) use %zu to print variable of type size_t in dec
 3) Initialize query_parm to NULL
 4) use PRIu64 to replace PDUd64
 5) use PRId64/PRIu64/PRIX64 to print 64-bit
 6) drop PRUx64 because PRIx64 does the same
 7) cast pointer arith to intptr_t before casting to int
 8) fixed 1ULL<<63

Change-Id: Ife62a20063a6ec38d4a9b23977e840af1fce149a
diff --git a/android-configure.sh b/android-configure.sh
index 6d25d20..5620e0e 100755
--- a/android-configure.sh
+++ b/android-configure.sh
@@ -116,12 +116,12 @@
     exit 1
 fi
 
-# On Linux, try to use our 32-bit prebuilt toolchain to generate binaries
+# On Linux, try to use our prebuilt toolchain to generate binaries
 # that are compatible with Ubuntu 8.04
-if [ -z "$CC" -a -z "$OPTION_CC" -a "$HOST_OS" = linux -a "$OPTION_TRY_64" != "yes" ] ; then
-    HOST_CC=`dirname $0`/../../prebuilt/linux-x86/toolchain/i686-linux-glibc2.7-4.4.3/bin/i686-linux-gcc
+if [ -z "$CC" -a -z "$OPTION_CC" -a "$HOST_OS" = linux ] ; then
+    HOST_CC=`dirname $0`/../../prebuilts/tools/gcc-sdk/gcc
     if [ -f "$HOST_CC" ] ; then
-        echo "Using prebuilt 32-bit toolchain: $HOST_CC"
+        echo "Using prebuilt toolchain: $HOST_CC"
         CC="$HOST_CC"
     fi
 fi
@@ -132,6 +132,10 @@
     CC="$OPTION_CC"
 fi
 
+if [ -z "$CC" ]; then
+  CC=$HOST_CC
+fi
+
 # we only support generating 32-bit binaris on 64-bit systems.
 # And we may need to add a -Wa,--32 to CFLAGS to let the assembler
 # generate 32-bit binaries on Linux x86_64.
@@ -180,7 +184,11 @@
 # platform build tree and copy them into objs/lib/ automatically, unless
 # you use --gles-libs to point explicitely to a different directory.
 #
-GLES_SHARED_LIBRARIES="libOpenglRender libGLES_CM_translator libGLES_V2_translator libEGL_translator"
+if [ "$OPTION_TRY_64" != "yes" ] ; then
+    GLES_SHARED_LIBRARIES="libOpenglRender libGLES_CM_translator libGLES_V2_translator libEGL_translator"
+else
+    GLES_SHARED_LIBRARIES="lib64OpenglRender lib64GLES_CM_translator lib64GLES_V2_translator lib64EGL_translator"
+fi
 
 if [ "$IN_ANDROID_BUILD" = "yes" ] ; then
     locate_android_prebuilt
@@ -196,10 +204,15 @@
         if [ ! -f $CCACHE ] ; then
             CCACHE="$ANDROID_PREBUILT/ccache$EXE"
         fi
+        if [ ! -f $CCACHE ] ; then
+            CCACHE="$ANDROID_PREBUILTS/ccache/ccache$EXE"
+        fi
         if [ -f $CCACHE ] ; then
             CC="$CCACHE $CC"
+            log "Prebuilt   : CCACHE=$CCACHE"
+	else
+            log "Prebuilt   : CCACHE can't be found"
         fi
-        log "Prebuilt   : CCACHE=$CCACHE"
     fi
 
     # finally ensure that our new binary is copied to the 'out'
@@ -511,6 +524,7 @@
 echo "HOST_PREBUILT_TAG := $TARGET_OS" >> $config_mk
 echo "HOST_EXEEXT       := $TARGET_EXEEXT" >> $config_mk
 echo "PREBUILT          := $ANDROID_PREBUILT" >> $config_mk
+echo "PREBUILTS         := $ANDROID_PREBUILTS" >> $config_mk
 
 PWD=`pwd`
 echo "SRC_PATH          := $PWD" >> $config_mk