Merge "Added state snapshot support for QemuD service "boot properties"."
diff --git a/android/config/linux-x86_64/SDL_config.h b/android/config/linux-x86_64/SDL_config.h
new file mode 100644
index 0000000..529beb0
--- /dev/null
+++ b/android/config/linux-x86_64/SDL_config.h
@@ -0,0 +1,123 @@
+/* This file was autogenerated by 'android-configure.sh' - do not edit */
+#ifndef _SDL_config_h
+#define _SDL_config_h
+
+#include "SDL_platform.h"
+
+#define SDL_HAS_64BIT_TYPE 1
+#define SDL_BYTEORDER 1234
+
+#define HAVE_LIBC 1
+#if HAVE_LIBC
+
+/* Useful headers */
+#define HAVE_ALLOCA_H 1
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_STDIO_H 1
+#define STDC_HEADERS  1
+#define HAVE_STDLIB_H 1
+#define HAVE_STDARG_H 1
+#define HAVE_MALLOC_H 1
+#define HAVE_MEMORY_H 1
+#define HAVE_STRING_H 1
+#define HAVE_STRINGS_H 1
+#define HAVE_INTTYPES_H 1
+#define HAVE_STDINT_H 1
+#define HAVE_CTYPE_H 1
+#define HAVE_MATH_H 1
+#define HAVE_ICONV_H 1
+#define HAVE_SIGNAL_H 1
+/* #undef HAVE_ALTIVEC_H */
+/* C library functions */
+#define HAVE_MALLOC 1
+#define HAVE_CALLOC 1
+#define HAVE_REALLOC 1
+#define HAVE_FREE 1
+/* #undef HAVE_ALLOC */
+#ifndef _WIN32 /* Don't use on Windows */
+#define HAVE_GETENV 1
+#define HAVE_PUTENV 1
+#define HAVE_UNSETENV 1
+#endif
+#define HAVE_QSORT 1
+#define HAVE_ABS 1
+#define HAVE_BCOPY 1
+#define HAVE_MEMSET 1
+#define HAVE_MEMCPY 1
+#define HAVE_MEMMOVE 1
+#define HAVE_MEMCMP 1
+#define HAVE_STRLEN 1
+/* #undef HAVE_STRLCPY */
+/* #undef HAVE_STRLCAT */
+#define HAVE_STRDUP 1
+/* #undef HAVE__STRREV */
+/* #undef HAVE__STRUPR */
+/* #undef HAVE__STRLWR */
+#define HAVE_INDEX 1
+#define HAVE_RINDEX 1
+#define HAVE_STRCHR 1
+#define HAVE_STRRCHR 1
+/* #undef HAVE_ITOA */
+/* #undef HAVE__LTOA */
+/* #undef HAVE__UITOA */
+/* #undef HAVE__ULTOA */
+#define HAVE_STRTOL 1
+#define HAVE_STRTOUL 1
+/* #undef HAVE__I64TOA */
+/* #undef HAVE__UI64TOA */
+#define HAVE_STRTOLL 1
+#define HAVE_STRTOULL 1
+#define HAVE_STRTOD 1
+#define HAVE_ATOI 1
+#define HAVE_ATOF 1
+#define HAVE_STRCMP 1
+#define HAVE_STRNCMP 1
+/* #undef HAVE__STRICMP */
+#define HAVE_STRCASECMP 1
+/* #undef HAVE__STRNICMP */
+#define HAVE_VSNPRINTF 1
+#define HAVE_ICONV 1
+#define HAVE_SIGACTION 1
+#define HAVE_SETJMP 1
+#define HAVE_NANOSLEEP 1
+#define HAVE_CLOCK_GETTIME 1
+#define HAVE_DLVSYM 1
+#define HAVE_GETPAGESIZE 1
+#else
+/* We may need some replacement for stdarg.h here */
+#include <stdarg.h>
+#endif /* HAVE_LIBC */
+
+/* Allow disabling of core subsystems */
+#define SDL_AUDIO_DISABLED 1
+#define SDL_CDROM_DISABLED 1
+/* #undef SDL_CPUINFO_DISABLED */
+/* #undef SDL_EVENTS_DISABLED */
+#define SDL_FILE_DISABLED 1
+#define SDL_JOYSTICK_DISABLED 1
+/* #undef SDL_LOADSO_DISABLED */
+/* #undef SDL_THREADS_DISABLED */
+/* #undef SDL_TIMERS_DISABLED */
+/* #undef SDL_VIDEO_DISABLED */
+
+/* Enable various shared object loading systems */
+#define SDL_LOADSO_DLOPEN 1
+
+/* Enable various threading systems */
+#define SDL_THREAD_PTHREAD 1
+#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1
+
+/* Enable various timer systems */
+#define SDL_TIMER_UNIX 1
+
+/* Enable various video drivers */
+#define SDL_VIDEO_DRIVER_X11 1
+#define SDL_VIDEO_DRIVER_X11_DPMS 1
+#define SDL_VIDEO_DRIVER_X11_XINERAMA 1
+#define SDL_VIDEO_DRIVER_X11_XME 1
+#define SDL_MAIN_DUMMY 1
+#define SDL_VIDEO_DRIVER_X11_DYNAMIC "libX11.so.6"
+#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "libXext.so.6"
+#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "libXrandr.so.2"
+#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER "libXrender.so.1"
+#endif /* _SDL_config_h */
diff --git a/android/utils/mapfile.c b/android/utils/mapfile.c
index 102dfd8..61b57c4 100644
--- a/android/utils/mapfile.c
+++ b/android/utils/mapfile.c
@@ -88,7 +88,7 @@
     int file_handle = open(path, oflag, share_mode);
 #endif  // WIN32
 
-    return (MapFile*)file_handle;
+    return (MapFile*)(ptrdiff_t)file_handle;
 }
 
 int
@@ -102,7 +102,7 @@
         return -1;
     }
 #else   // WIN32
-    return close((int)handle);
+    return close((int)(ptrdiff_t)handle);
 #endif  // WIN32
 }
 
@@ -122,7 +122,7 @@
 #else   // WIN32
     ssize_t ret;
     do {
-        ret = read((int)handle, buf, nbyte);
+        ret = read((int)(ptrdiff_t)handle, buf, nbyte);
     } while (ret < 0 && errno == EINTR);
     return ret;
 #endif  // WIN32
@@ -142,7 +142,7 @@
     }
     return mapfile_read(handle, buf, nbyte);
 #else   // WIN32
-    ssize_t res = lseek((int)handle, offset, SEEK_SET);
+    ssize_t res = lseek((int)(ptrdiff_t)handle, offset, SEEK_SET);
     return res >= 0 ? mapfile_read(handle, buf, nbyte) : res;
 #endif  // WIN32
 }
@@ -223,7 +223,7 @@
     }
 #else   // WIN32
     mapped_at =
-        mmap(0, map_size, PROT_READ, MAP_SHARED, (int)handle, map_offset);
+        mmap(0, map_size, PROT_READ, MAP_SHARED, (int)(ptrdiff_t)handle, map_offset);
     if (mapped_at == MAP_FAILED) {
         return NULL;
     }
diff --git a/android/utils/mapfile.h b/android/utils/mapfile.h
index c125337..18f8845 100644
--- a/android/utils/mapfile.h
+++ b/android/utils/mapfile.h
@@ -39,7 +39,7 @@
 static inline int
 mapfile_is_valid(MapFile* handle)
 {
-    return (int)handle != -1;
+    return handle != (void*)(ptrdiff_t)-1;
 }
 
 /* Opens file in selected mode.
diff --git a/android/utils/system.c b/android/utils/system.c
index 8443877..5b20b4b 100644
--- a/android/utils/system.c
+++ b/android/utils/system.c
@@ -66,7 +66,7 @@
     if (block2 != NULL)
         return block2;
 
-    fprintf(stderr, "PANIC: not enough memory to reallocate %d bytes\n", size);
+    fprintf(stderr, "PANIC: not enough memory to reallocate %lld bytes\n", (uint64_t)size);
     exit(1);
     return NULL;
 }
diff --git a/android/utils/timezone.c b/android/utils/timezone.c
index 2707e2e..1b99917 100644
--- a/android/utils/timezone.c
+++ b/android/utils/timezone.c
@@ -185,7 +185,7 @@
     }
 
     if ( st.st_size != scan->localtime_st.st_size ) {
-        D( " size mistmatch (%lld != %lld)\n", st.st_size, scan->localtime_st.st_size );
+        D( " size mistmatch (%zd != %zd)\n", (size_t)st.st_size, (size_t)scan->localtime_st.st_size );
         return 0;
     }
 
diff --git a/cpu-defs.h b/cpu-defs.h
index 8d4bf86..f9294c3 100644
--- a/cpu-defs.h
+++ b/cpu-defs.h
@@ -94,12 +94,12 @@
     target_ulong addr_code;
     /* Addend to virtual address to get host address.  IO accesses
        use the corresponding iotlb value.  */
-    unsigned long addend;
+    size_t addend;
     /* padding to get a power of two size */
-    uint8_t dummy[(1 << CPU_TLB_ENTRY_BITS) - 
-                  (sizeof(target_ulong) * 3 + 
-                   ((-sizeof(target_ulong) * 3) & (sizeof(unsigned long) - 1)) + 
-                   sizeof(unsigned long))];
+    uint8_t dummy[(1 << CPU_TLB_ENTRY_BITS) -
+                  (sizeof(target_ulong) * 3 +
+                   ((-sizeof(target_ulong) * 3) & (sizeof(size_t) - 1)) +
+                   sizeof(size_t))];
 } CPUTLBEntry;
 
 extern int CPUTLBEntry_wrong_size[sizeof(CPUTLBEntry) == (1 << CPU_TLB_ENTRY_BITS) ? 1 : -1];
diff --git a/elff/dwarf_die.cc b/elff/dwarf_die.cc
index 0f58cbe..9939952 100644
--- a/elff/dwarf_die.cc
+++ b/elff/dwarf_die.cc
@@ -213,7 +213,7 @@
           while (elf_file()->get_range<Elf_Xword>(off, &low, &high) &&

                  (low != 0 || high != 0)) {

             printf("                                %08" FMT_I64 "X - %08" FMT_I64 "X\n",

-                   low, high);

+                   (unsigned long long)low, (unsigned long long)high);

             off += 16;

           }

         } else {

diff --git a/exec.c b/exec.c
index 2ad8a4f..8786791 100644
--- a/exec.c
+++ b/exec.c
@@ -1984,7 +1984,7 @@
     unsigned int index;
     target_ulong address;
     target_ulong code_address;
-    target_phys_addr_t addend;
+    ptrdiff_t addend;
     int ret;
     CPUTLBEntry *te;
     CPUWatchpoint *wp;
@@ -2007,7 +2007,7 @@
         /* IO memory case (romd handled later) */
         address |= TLB_MMIO;
     }
-    addend = (unsigned long)qemu_get_ram_ptr(pd & TARGET_PAGE_MASK);
+    addend = (ptrdiff_t)qemu_get_ram_ptr(pd & TARGET_PAGE_MASK);
     if ((pd & ~TARGET_PAGE_MASK) <= IO_MEM_ROM) {
         /* Normal RAM.  */
         iotlb = pd & TARGET_PAGE_MASK;
diff --git a/hw/goldfish_audio.c b/hw/goldfish_audio.c
index 75f65bb..37e4c09 100644
--- a/hw/goldfish_audio.c
+++ b/hw/goldfish_audio.c
@@ -439,7 +439,7 @@
         case AUDIO_SET_READ_BUFFER:
             /* save pointer to the read buffer */
             goldfish_audio_buff_set_address( s->in_buff, val );
-            D( "%s: AUDIO_SET_READ_BUFFER %p", __FUNCTION__, (void*)val );
+            D( "%s: AUDIO_SET_READ_BUFFER %08x", __FUNCTION__, val );
             break;
 
         case AUDIO_START_READ:
diff --git a/hw/goldfish_mmc.c b/hw/goldfish_mmc.c
index 3824db9..3157bb3 100644
--- a/hw/goldfish_mmc.c
+++ b/hw/goldfish_mmc.c
@@ -251,7 +251,7 @@
                 m = (uint32_t)(capacity / (512*1024)) - 1;
                 // m must fit into 22 bits
                 if (m & 0xFFC00000) {
-                    fprintf(stderr, "SD card too big (%lld bytes).  Maximum SDHC card size is 128 gigabytes.\n", capacity);
+                    fprintf(stderr, "SD card too big (%lld bytes).  Maximum SDHC card size is 128 gigabytes.\n", (long long)capacity);
                     abort();
                 }
 
@@ -277,7 +277,7 @@
                 exponent = 0;
                 capacity = sector_count * 512;
                 if (capacity > 2147483648U) {
-                    fprintf(stderr, "SD card too big (%lld bytes).  Maximum SD card size is 2 gigabytes.\n", capacity);
+                    fprintf(stderr, "SD card too big (%lld bytes).  Maximum SD card size is 2 gigabytes.\n", (long long)capacity);
                     abort();
                 }
                 capacity >>= 10; // convert to Kbytes
diff --git a/memcheck/memcheck_api.h b/memcheck/memcheck_api.h
index 1961465..9e76ecd 100644
--- a/memcheck/memcheck_api.h
+++ b/memcheck/memcheck_api.h
@@ -43,7 +43,7 @@
  * array is used to obtain guest PC address from a translated PC address.
  * tcg_gen_code_common will fill it up when memchecker is enabled. The array is
  * declared in ./translate_all.c */
-extern target_ulong* gen_opc_tpc2gpc_ptr;
+extern void** gen_opc_tpc2gpc_ptr;
 
 /* Number of (tb_pc, guest_pc) pairs stored in gen_opc_tpc2gpc array.
  * The variable is declared in ./translate_all.c */
diff --git a/memcheck/memcheck_common.h b/memcheck/memcheck_common.h
index 668b78c..e6d12db 100644
--- a/memcheck/memcheck_common.h
+++ b/memcheck/memcheck_common.h
@@ -125,7 +125,7 @@
 /* Helpers for addressing field in MallocDesc structure, using which emulator
  * reports an error back to the guest.
  */
-#define ALLOC_RES_OFFSET        ((uint32_t)&(((MallocDesc*)0)->libc_pid))
+#define ALLOC_RES_OFFSET        ((uint32_t)(ptrdiff_t)&(((MallocDesc*)0)->libc_pid))
 #define ALLOC_RES_ADDRESS(p)    (p + ALLOC_RES_OFFSET)
 
 /* Describes memory block info queried from emulator. This structure is passed
@@ -174,7 +174,7 @@
 /* Helpers for addressing field in MallocDescQuery structure using which
  * emulator reports an error back to the guest.
  */
-#define QUERY_RES_OFFSET        ((uint32_t)&(((MallocDescQuery*)0)->libc_pid))
+#define QUERY_RES_OFFSET        ((uint32_t)(ptrdiff_t)&(((MallocDescQuery*)0)->libc_pid))
 #define QUERY_RES_ADDRESS(p)    (p + QUERY_RES_OFFSET)
 
 /* Describes memory block that is being freed back to the heap. This structure
@@ -201,7 +201,7 @@
 /* Helpers for addressing field in MallocFree structure, using which emulator
  * reports an error back to the guest.
  */
-#define FREE_RES_OFFSET         ((uint32_t)&(((MallocFree*)0)->libc_pid))
+#define FREE_RES_OFFSET         ((uint32_t)(ptrdiff_t)&(((MallocFree*)0)->libc_pid))
 #define FREE_RES_ADDRESS(p)     (p + FREE_RES_OFFSET)
 
 /* Extends MallocDesc structure with additional information, used by memchecker.
diff --git a/softmmu_template.h b/softmmu_template.h
index d140b8c..1ea4398 100644
--- a/softmmu_template.h
+++ b/softmmu_template.h
@@ -127,7 +127,7 @@
             /* We only validate access to the guest's user space, for which
              * mmu_idx is set to 1. */
             if (memcheck_instrument_mmu && mmu_idx == 1 &&
-                memcheck_validate_ld(addr, DATA_SIZE, (target_ulong)GETPC())) {
+                memcheck_validate_ld(addr, DATA_SIZE, (target_ulong)(ptrdiff_t)GETPC())) {
                 /* Memory read breaks page boundary. So, if required, we
                  * must invalidate two caches in TLB. */
                 invalidate_cache = 2;
@@ -147,7 +147,7 @@
              * mmu_idx is set to 1. */
             if (memcheck_instrument_mmu && mmu_idx == 1) {
                 invalidate_cache = memcheck_validate_ld(addr, DATA_SIZE,
-                                                        (target_ulong)GETPC());
+                                                        (target_ulong)(ptrdiff_t)GETPC());
             }
 #endif  // CONFIG_MEMCHECK_MMU
             /* unaligned/aligned access in the same page */
@@ -303,7 +303,7 @@
              * mmu_idx is set to 1. */
             if (memcheck_instrument_mmu && mmu_idx == 1 &&
                 memcheck_validate_st(addr, DATA_SIZE, (uint64_t)val,
-                                     (target_ulong)GETPC())) {
+                                     (target_ulong)(ptrdiff_t)GETPC())) {
                 /* Memory write breaks page boundary. So, if required, we
                  * must invalidate two caches in TLB. */
                 invalidate_cache = 2;
@@ -323,7 +323,7 @@
             if (memcheck_instrument_mmu && mmu_idx == 1) {
                 invalidate_cache = memcheck_validate_st(addr, DATA_SIZE,
                                                         (uint64_t)val,
-                                                        (target_ulong)GETPC());
+                                                        (target_ulong)(ptrdiff_t)GETPC());
             }
 #endif  // CONFIG_MEMCHECK_MMU
             /* aligned/unaligned access in the same page */
diff --git a/target-arm/helper.c b/target-arm/helper.c
index 56d9953..258e2cb 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -2672,11 +2672,11 @@
 }
 
 #ifdef CONFIG_MEMCHECK
-void HELPER(on_call)(void* pc, void* ret) {
-    memcheck_on_call((target_ulong)pc, (target_ulong)ret);
+void HELPER(on_call)(target_ulong pc, target_ulong ret) {
+    memcheck_on_call(pc, ret);
 }
 
-void HELPER(on_ret)(void* ret) {
-    memcheck_on_ret((target_ulong)ret);
+void HELPER(on_ret)(target_ulong ret) {
+    memcheck_on_ret(ret);
 }
 #endif  // CONFIG_MEMCHECK
diff --git a/target-arm/helpers.h b/target-arm/helpers.h
index a42b3ae..5dd4925 100644
--- a/target-arm/helpers.h
+++ b/target-arm/helpers.h
@@ -473,12 +473,12 @@
  *  First pointer contains guest PC where BL/BLX has been found.
  *  Second pointer contains guest PC where BL/BLX will return.
  */
-DEF_HELPER_2(on_call, void, ptr, ptr)
+DEF_HELPER_2(on_call, void, i32, i32)
 /* Hooks to return from translated BL/BLX. This callback is used to build
  * thread's calling stack.
  * Param:
  *  Pointer contains guest PC where BL/BLX will return.
  */
-DEF_HELPER_1(on_ret, void, ptr)
+DEF_HELPER_1(on_ret, void, i32)
 #endif  // CONFIG_MEMCHECK
 #include "def-helper.h"
diff --git a/target-arm/translate.c b/target-arm/translate.c
index d298f89..798105c 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -5770,7 +5770,7 @@
 }
 
 static void
-gen_traceBB( uint64_t  bbNum, target_phys_addr_t  tb )
+gen_traceBB( uint64_t  bbNum, void* tb )
 {
 #if HOST_LONG_BITS == 32
     TCGv_i64  tmpNum = tcg_temp_new_i64();
@@ -5787,7 +5787,7 @@
 
     tcg_gen_movi_i64(tmpNum, (int64_t)bbNum);
     tcg_gen_movi_i64(tmpTb,  (int64_t)tb);
-    gen_helper_traceBB32(tmpNum, tmpTb);
+    gen_helper_traceBB64(tmpNum, tmpTb);
     tcg_temp_free_i64(tmpTb);
     tcg_temp_free_i64(tmpNum);
 #endif
@@ -8909,7 +8909,7 @@
     gen_icount_start();
 #ifdef CONFIG_TRACE
     if (tracing) {
-        gen_traceBB(trace_static.bb_num, (target_phys_addr_t)tb );
+        gen_traceBB(trace_static.bb_num, tb);
         trace_bb_start(dc->pc);
     }
 #endif
diff --git a/tcg/tcg.c b/tcg/tcg.c
index 2fe9964..a57edb1 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -1125,7 +1125,7 @@
     /* sanity check */
     if (gen_opc_ptr - gen_opc_buf > OPC_BUF_SIZE) {
         fprintf(stderr, "PANIC: too many opcodes generated (%d > %d)\n",
-                gen_opc_ptr - gen_opc_buf, OPC_BUF_SIZE);
+                (int)(gen_opc_ptr - gen_opc_buf), OPC_BUF_SIZE);
         tcg_abort();
     }
 
@@ -1982,9 +1982,9 @@
          * tcg_gen_code_search_pc. */
         if (memcheck_enabled && search_pc < 0 &&
             gen_opc_instr_start[op_index]) {
-            gen_opc_tpc2gpc_ptr[tpc2gpc_index] = (target_ulong)s->code_ptr;
+            gen_opc_tpc2gpc_ptr[tpc2gpc_index] = s->code_ptr;
             tpc2gpc_index++;
-            gen_opc_tpc2gpc_ptr[tpc2gpc_index] = gen_opc_pc[op_index];
+            gen_opc_tpc2gpc_ptr[tpc2gpc_index] = (void*)(ptrdiff_t)gen_opc_pc[op_index];
             tpc2gpc_index++;
             gen_opc_tpc2gpc_pairs++;
         }
@@ -2087,7 +2087,7 @@
     /* sanity check */
     if (gen_opc_ptr - gen_opc_buf > OPC_BUF_SIZE) {
         fprintf(stderr, "PANIC: too many opcodes generated (%d > %d)\n",
-                gen_opc_ptr - gen_opc_buf, OPC_BUF_SIZE);
+                (int)(gen_opc_ptr - gen_opc_buf), OPC_BUF_SIZE);
         tcg_abort();
     }
 
diff --git a/telephony/android_modem.c b/telephony/android_modem.c
index ddfef94..0df1186 100644
--- a/telephony/android_modem.c
+++ b/telephony/android_modem.c
@@ -1201,8 +1201,6 @@
 static const char*
 handlePrlVersion( const char* cmd, AModem modem )
 {
-    long arg;
-    char *endptr = NULL;
     assert ( !memcmp( "+WPRL", cmd, 5 ) );
     cmd += 5;
     if (cmd[0] == '?') {
diff --git a/translate-all.c b/translate-all.c
index c6b369a..3830007 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -59,8 +59,8 @@
 /* Array of (tb_pc, guest_pc) pairs, big enough for all translations. This
  * array is used to obtain guest PC address from a translated PC address.
  * tcg_gen_code_common will fill it up when memchecker is enabled. */
-static target_ulong gen_opc_tpc2gpc[OPC_BUF_SIZE * 2];
-target_ulong* gen_opc_tpc2gpc_ptr = &gen_opc_tpc2gpc[0];
+static void* gen_opc_tpc2gpc[OPC_BUF_SIZE * 2];
+void** gen_opc_tpc2gpc_ptr = &gen_opc_tpc2gpc[0];
 /* Number of (tb_pc, guest_pc) pairs stored in gen_opc_tpc2gpc array. */
 unsigned int gen_opc_tpc2gpc_pairs;
 #endif  // CONFIG_MEMCHECK