Merge "Support building with newest Mingw64 cross-toolchain."
diff --git a/Makefile.android b/Makefile.android
index 8c2db0a..c5bcd0d 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -151,6 +151,13 @@
endif
endif
+ifeq ($(HOST_OS)-$(BUILD_STANDALONE_EMULATOR),windows-true)
+ # Ensure that printf() et al use GNU printf format specifiers as required
+ # by QEMU. This is important when using the newer Mingw64 cross-toolchain.
+ # See http://sourceforge.net/apps/trac/mingw-w64/wiki/gnu%20printf
+ MY_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
+endif
+
# Enable warning, except those related to missing field initializers
# (the QEMU coding style loves using these).
#
@@ -218,7 +225,7 @@
#
QEMU_SYSTEM_LDLIBS := -lm
ifeq ($(HOST_OS),windows)
- QEMU_SYSTEM_LDLIBS += -mno-cygwin -mwindows -mconsole
+ QEMU_SYSTEM_LDLIBS += -mwindows -mconsole
endif
ifeq ($(HOST_OS),freebsd)
diff --git a/android-configure.sh b/android-configure.sh
index 65f08c5..e79ce1b 100755
--- a/android-configure.sh
+++ b/android-configure.sh
@@ -487,6 +487,16 @@
feature_check_header HAVE_MACHINE_BSWAP_H "<machine/bswap.h>"
feature_check_header HAVE_FNMATCH_H "<fnmatch.h>"
+# check for Mingw version.
+MINGW_VERSION=
+if [ "$TARGET_OS" = "windows" ]; then
+log "Mingw : Probing for GCC version."
+GCC_VERSION=$($CC -v 2>&1 | awk '$1 == "gcc" && $2 == "version" { print $3; }')
+GCC_MAJOR=$(echo "$GCC_VERSION" | cut -f1 -d.)
+GCC_MINOR=$(echo "$GCC_VERSION" | cut -f2 -d.)
+log "Mingw : Found GCC version $GCC_MAJOR.$GCC_MINOR [$GCC_VERSION]"
+MINGW_GCC_VERSION=$(( $GCC_MAJOR * 100 + $GCC_MINOR ))
+fi
# Build the config.make file
#
@@ -583,6 +593,7 @@
echo "" >> $config_mk
echo "USE_MINGW := 1" >> $config_mk
echo "HOST_OS := windows" >> $config_mk
+ echo "HOST_MINGW_VERSION := $MINGW_GCC_VERSION" >> $config_mk
fi
if [ "$HOST_OS" = "darwin" ]; then
diff --git a/android/build/common.sh b/android/build/common.sh
index 9849bb2..76c907f 100644
--- a/android/build/common.sh
+++ b/android/build/common.sh
@@ -204,19 +204,29 @@
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 $MINGW32_PREFIX-gcc is not in your path"
- echo "Please install the mingw32 package !"
+ 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
fi
log2 "Mingw : Found $MINGW32_CC"
- CC=$MINGW32_CC
- LD=$MINGW32_CC
- AR=$MINGW32_PREFIX-ar
- FORCE_32BIT=no
+ CC=$MINGW_CC
+ LD=$MINGW_CC
+ AR=$MINGW_PREFIX-ar
}
# Cygwin is normally not supported, unless you call this function
diff --git a/android/main-emulator.c b/android/main-emulator.c
index 6251106..1db090c 100644
--- a/android/main-emulator.c
+++ b/android/main-emulator.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <android/utils/compiler.h>
#include <android/utils/panic.h>
#include <android/utils/path.h>
#include <android/utils/bufprint.h>
@@ -68,14 +69,14 @@
static char* getSharedLibraryPath(const char* progName, const char* libName);
static void prependSharedLibraryPath(const char* prefix);
-/* The execv() definition in mingw is slightly bogus.
+/* The execv() definition in older mingw is slightly bogus.
* It takes a second argument of type 'const char* const*'
* while POSIX mandates char** instead.
*
* To avoid compiler warnings, define the safe_execv macro
* to perform an explicit cast with mingw.
*/
-#ifdef _WIN32
+#if defined(_WIN32) && !ANDROID_GCC_PREREQ(4,4)
# define safe_execv(_filepath,_argv) execv((_filepath),(const char* const*)(_argv))
#else
# define safe_execv(_filepath,_argv) execv((_filepath),(_argv))
diff --git a/android/sockets.c b/android/sockets.c
index 4b8796d..4334ce9 100644
--- a/android/sockets.c
+++ b/android/sockets.c
@@ -1210,11 +1210,11 @@
int socket_init(void)
{
WSADATA Data;
- int ret, err;
+ int ret;
ret = WSAStartup(MAKEWORD(2,2), &Data);
if (ret != 0) {
- err = WSAGetLastError();
+ (void) WSAGetLastError();
return -1;
}
atexit(socket_cleanup);
diff --git a/android/utils/compiler.h b/android/utils/compiler.h
index 4c5f7b1..8462cea 100644
--- a/android/utils/compiler.h
+++ b/android/utils/compiler.h
@@ -20,4 +20,13 @@
#define ANDROID_END_HEADER /* nothing */
#endif
+// ANDROID_GCC_PREREQ(<major>,<minor>) will evaluate to true
+// iff the current version of GCC is <major>.<minor> or higher.
+#if defined(__GNUC__) && defined(__GNUC_MINOR__)
+# define ANDROID_GCC_PREREQ(maj, min) \
+ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+#else
+# define ANDROID_GCC_PREREQ(maj, min) 0
+#endif
+
#endif // ANDROID_UTILS_COMPILER_H
diff --git a/android/utils/filelock.c b/android/utils/filelock.c
index 8baffe4..b009e25 100644
--- a/android/utils/filelock.c
+++ b/android/utils/filelock.c
@@ -91,13 +91,13 @@
#ifdef _WIN32
int pidfile_fd = -1;
- ret = _mkdir( lock->lock );
+ ret = mkdir( lock->lock );
if (ret < 0) {
if (errno == ENOENT) {
D( "could not access directory '%s', check path elements", lock->lock );
return -1;
} else if (errno != EEXIST) {
- D( "_mkdir(%s): %s", lock->lock, strerror(errno) );
+ D( "mkdir(%s): %s", lock->lock, strerror(errno) );
return -1;
}
diff --git a/android/utils/path.c b/android/utils/path.c
index f1a146f..c88b5cc 100644
--- a/android/utils/path.c
+++ b/android/utils/path.c
@@ -284,7 +284,7 @@
{
#ifdef _WIN32
(void)mode;
- return _mkdir(path);
+ return mkdir(path);
#else
return HANDLE_EINTR(mkdir(path, mode));
#endif
diff --git a/android/utils/system.c b/android/utils/system.c
index 6a6a4e1..a0344fd 100644
--- a/android/utils/system.c
+++ b/android/utils/system.c
@@ -67,7 +67,8 @@
if (block2 != NULL)
return block2;
- fprintf(stderr, "PANIC: not enough memory to reallocate %zu bytes\n", size);
+ fprintf(stderr, "PANIC: not enough memory to reallocate %u bytes\n",
+ (unsigned)size);
exit(1);
return NULL;
}
diff --git a/android/utils/system.h b/android/utils/system.h
index 4f4677d..a6b84d1 100644
--- a/android/utils/system.h
+++ b/android/utils/system.h
@@ -103,9 +103,9 @@
extern char* win32_strsep(char** pline, const char* delim);
#endif
-/** Handle strcasecmp on Windows
+/** Handle strcasecmp on Windows (and older Mingw32 toolchain)
**/
-#ifdef _WIN32
+#if defined(_WIN32) && !ANDROID_GCC_PREREQ(4,4)
# define strcasecmp stricmp
#endif
diff --git a/audio/mixeng.c b/audio/mixeng.c
index 3f876e7..b7c7bc7 100644
--- a/audio/mixeng.c
+++ b/audio/mixeng.c
@@ -301,7 +301,7 @@
struct rate *rate = audio_calloc (AUDIO_FUNC, 1, sizeof (*rate));
if (!rate) {
- dolog ("Could not allocate resampler (%zu bytes)\n", sizeof (*rate));
+ dolog ("Could not allocate resampler (%u bytes)\n", (int)sizeof (*rate));
return NULL;
}
diff --git a/distrib/elff/elff/elff_map_file.h b/distrib/elff/elff/elff_map_file.h
index 26419fe..a5fd08b 100644
--- a/distrib/elff/elff/elff_map_file.h
+++ b/distrib/elff/elff/elff_map_file.h
@@ -16,4 +16,4 @@
// TODO(digit): Provide standalone implementation for the library.
#include "android/utils/mapfile.h"
-#endif // ELFF_MAP_FILE_H
\ No newline at end of file
+#endif // ELFF_MAP_FILE_H
diff --git a/distrib/sdl-1.2.15/include/SDL_opengl.h b/distrib/sdl-1.2.15/include/SDL_opengl.h
index 3d791d6..e1e4169 100644
--- a/distrib/sdl-1.2.15/include/SDL_opengl.h
+++ b/distrib/sdl-1.2.15/include/SDL_opengl.h
@@ -27,7 +27,7 @@
#include "SDL_config.h"
#ifdef __WIN32__
-#define WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
#ifndef NOMINMAX
#define NOMINMAX /* Don't defined min() and max() */
#endif
diff --git a/distrib/sdl-1.2.15/include/SDL_syswm.h b/distrib/sdl-1.2.15/include/SDL_syswm.h
index 771d6b1..f252767 100644
--- a/distrib/sdl-1.2.15/include/SDL_syswm.h
+++ b/distrib/sdl-1.2.15/include/SDL_syswm.h
@@ -129,7 +129,7 @@
} SDL_SysWMinfo;
#elif defined(SDL_VIDEO_DRIVER_WINDIB) || defined(SDL_VIDEO_DRIVER_DDRAW) || defined(SDL_VIDEO_DRIVER_GAPI)
-#define WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
/** The windows custom event structure */
diff --git a/distrib/sdl-1.2.15/src/thread/win32/SDL_systhread.c b/distrib/sdl-1.2.15/src/thread/win32/SDL_systhread.c
index 55cb88a..6912bd2 100644
--- a/distrib/sdl-1.2.15/src/thread/win32/SDL_systhread.c
+++ b/distrib/sdl-1.2.15/src/thread/win32/SDL_systhread.c
@@ -23,7 +23,7 @@
/* Win32 thread management routines for SDL */
-#define WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#include "SDL_thread.h"
diff --git a/distrib/sdl-1.2.15/src/thread/win32/SDL_systhread_c.h b/distrib/sdl-1.2.15/src/thread/win32/SDL_systhread_c.h
index 10b0a7d..9bd0089 100644
--- a/distrib/sdl-1.2.15/src/thread/win32/SDL_systhread_c.h
+++ b/distrib/sdl-1.2.15/src/thread/win32/SDL_systhread_c.h
@@ -21,7 +21,7 @@
*/
#include "SDL_config.h"
-#define WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
typedef HANDLE SYS_ThreadHandle;
diff --git a/distrib/sdl-1.2.15/src/video/wincommon/SDL_lowvideo.h b/distrib/sdl-1.2.15/src/video/wincommon/SDL_lowvideo.h
index 89d1a88..eed13db 100644
--- a/distrib/sdl-1.2.15/src/video/wincommon/SDL_lowvideo.h
+++ b/distrib/sdl-1.2.15/src/video/wincommon/SDL_lowvideo.h
@@ -24,7 +24,7 @@
#ifndef _SDL_lowvideo_h
#define _SDL_lowvideo_h
-#define WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#ifndef SetClassLongPtr
diff --git a/distrib/sdl-1.2.15/src/video/wincommon/SDL_sysevents.c b/distrib/sdl-1.2.15/src/video/wincommon/SDL_sysevents.c
index 76c67a1..2773bb9 100644
--- a/distrib/sdl-1.2.15/src/video/wincommon/SDL_sysevents.c
+++ b/distrib/sdl-1.2.15/src/video/wincommon/SDL_sysevents.c
@@ -21,7 +21,7 @@
*/
#include "SDL_config.h"
-#define WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
/* Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... */
diff --git a/distrib/sdl-1.2.15/src/video/wincommon/SDL_sysmouse.c b/distrib/sdl-1.2.15/src/video/wincommon/SDL_sysmouse.c
index 12d17e0..5e9bae0 100644
--- a/distrib/sdl-1.2.15/src/video/wincommon/SDL_sysmouse.c
+++ b/distrib/sdl-1.2.15/src/video/wincommon/SDL_sysmouse.c
@@ -21,7 +21,7 @@
*/
#include "SDL_config.h"
-#define WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#include "SDL_mouse.h"
diff --git a/distrib/sdl-1.2.15/src/video/wincommon/SDL_syswm.c b/distrib/sdl-1.2.15/src/video/wincommon/SDL_syswm.c
index 504d95d..7781814 100644
--- a/distrib/sdl-1.2.15/src/video/wincommon/SDL_syswm.c
+++ b/distrib/sdl-1.2.15/src/video/wincommon/SDL_syswm.c
@@ -21,7 +21,7 @@
*/
#include "SDL_config.h"
-#define WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#include "SDL_version.h"
diff --git a/distrib/sdl-1.2.15/src/video/windib/SDL_dibevents.c b/distrib/sdl-1.2.15/src/video/windib/SDL_dibevents.c
index 6cee54a..de4ad03 100644
--- a/distrib/sdl-1.2.15/src/video/windib/SDL_dibevents.c
+++ b/distrib/sdl-1.2.15/src/video/windib/SDL_dibevents.c
@@ -21,7 +21,7 @@
*/
#include "SDL_config.h"
-#define WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#include "SDL_main.h"
diff --git a/distrib/sdl-1.2.15/src/video/windib/SDL_dibvideo.c b/distrib/sdl-1.2.15/src/video/windib/SDL_dibvideo.c
index 9f1ffff..06c6ce2 100644
--- a/distrib/sdl-1.2.15/src/video/windib/SDL_dibvideo.c
+++ b/distrib/sdl-1.2.15/src/video/windib/SDL_dibvideo.c
@@ -21,7 +21,7 @@
*/
#include "SDL_config.h"
-#define WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
/* Not yet in the mingw32 cross-compile headers */
diff --git a/distrib/sdl-1.2.15/src/video/windib/SDL_dibvideo.h b/distrib/sdl-1.2.15/src/video/windib/SDL_dibvideo.h
index 48b1943..535fa60 100644
--- a/distrib/sdl-1.2.15/src/video/windib/SDL_dibvideo.h
+++ b/distrib/sdl-1.2.15/src/video/windib/SDL_dibvideo.h
@@ -24,7 +24,7 @@
#ifndef _SDL_dibvideo_h
#define _SDL_dibvideo_h
-#define WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
diff --git a/distrib/sdl-1.2.15/src/video/windib/SDL_gapidibvideo.h b/distrib/sdl-1.2.15/src/video/windib/SDL_gapidibvideo.h
index 64743d1..e5c079b 100644
--- a/distrib/sdl-1.2.15/src/video/windib/SDL_gapidibvideo.h
+++ b/distrib/sdl-1.2.15/src/video/windib/SDL_gapidibvideo.h
@@ -24,7 +24,7 @@
#ifndef _SDL_gapidibvideo_h
#define _SDL_gapidibvideo_h
-#define WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
/* Hidden "this" pointer for the video functions */
diff --git a/exec.c b/exec.c
index 7b4dacd..6f29389 100644
--- a/exec.c
+++ b/exec.c
@@ -1174,7 +1174,7 @@
0xff, size >> TARGET_PAGE_BITS);
//cpu_physical_memory_set_dirty_range(new_block->offset, size, 0xff);
- //qemu_ram_setup_dump(new_block->host, size);
+ qemu_ram_setup_dump(new_block->host, size);
//qemu_madvise(new_block->host, size, QEMU_MADV_HUGEPAGE);
//qemu_madvise(new_block->host, size, QEMU_MADV_DONTFORK);
diff --git a/hw/android/goldfish/mmc.c b/hw/android/goldfish/mmc.c
index cfd483a..a7d8ec4 100644
--- a/hw/android/goldfish/mmc.c
+++ b/hw/android/goldfish/mmc.c
@@ -10,6 +10,7 @@
** GNU General Public License for more details.
*/
#include "cpu.h"
+#include "qemu-common.h"
#include "migration/qemu-file.h"
#include "hw/android/goldfish/device.h"
#include "hw/hw.h"
@@ -266,7 +267,9 @@
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", (long long)capacity);
+ fprintf(stderr, "SD card too big (%" PRId64 " bytes). "
+ "Maximum SDHC card size is 128 gigabytes.\n",
+ capacity);
abort();
}
@@ -292,7 +295,9 @@
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", (long long)capacity);
+ fprintf(stderr, "SD card too big (%" PRIu64 " bytes). "
+ "Maximum SD card size is 2 gigabytes.\n",
+ capacity);
abort();
}
capacity >>= 10; // convert to Kbytes
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index b6a633a..48e3354 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -325,7 +325,7 @@
#define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1)
#define TARGET_PAGE_ALIGN(addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK)
#ifdef TARGET_X86_64
-#define TARGET_PTE_MASK 0x7fffffffffff
+#define TARGET_PTE_MASK 0x7fffffffffffULL
#endif
/* ??? These should be the larger of uintptr_t and target_ulong. */
diff --git a/include/qemu-common.h b/include/qemu-common.h
index 0a7fd4c..293c5ab 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -12,6 +12,7 @@
#ifndef QEMU_COMMON_H
#define QEMU_COMMON_H
+#include <inttypes.h>
#include <setjmp.h>
#include "qemu/compiler.h"
@@ -107,12 +108,7 @@
_fullpath(resolved_path, path, _MAX_PATH);
return resolved_path;
}
-
-#define PRId64 "I64d"
-#define PRIx64 "I64x"
-#define PRIu64 "I64u"
-#define PRIo64 "I64o"
-#endif
+#endif /* _WIN32 */
/* bottom halves */
typedef void QEMUBHFunc(void *opaque);
diff --git a/tap-win32.c b/tap-win32.c
index 734ad59..53a6bd7 100644
--- a/tap-win32.c
+++ b/tap-win32.c
@@ -576,7 +576,6 @@
} version;
DWORD version_len;
DWORD idThread;
- HANDLE hThread;
if (prefered_name != NULL)
snprintf(name_buffer, sizeof(name_buffer), "%s", prefered_name);
@@ -620,8 +619,8 @@
*phandle = &tap_overlapped;
- hThread = CreateThread(NULL, 0, tap_win32_thread_entry,
- (LPVOID)&tap_overlapped, 0, &idThread);
+ (void) CreateThread(NULL, 0, tap_win32_thread_entry,
+ (LPVOID)&tap_overlapped, 0, &idThread);
return 0;
}
diff --git a/target-i386/hax-all.c b/target-i386/hax-all.c
index c8bb7c4..25ec569 100644
--- a/target-i386/hax-all.c
+++ b/target-i386/hax-all.c
@@ -642,13 +642,12 @@
{
case HAX_EMUL_ONE:
ret = 1;
- cpu->hax_vcpu->emulation_state = HAX_EMULATE_STATE_MMIO;
+ vcpu->emulation_state = HAX_EMULATE_STATE_MMIO;
hax_prepare_emulation(env);
break;
case HAX_EMUL_REAL:
ret = 1;
- cpu->hax_vcpu->emulation_state =
- HAX_EMULATE_STATE_REAL;
+ vcpu->emulation_state = HAX_EMULATE_STATE_REAL;
hax_prepare_emulation(env);
break;
case HAX_EMUL_HLT:
diff --git a/telephony/sms.c b/telephony/sms.c
index 50ef715..812ac7c 100644
--- a/telephony/sms.c
+++ b/telephony/sms.c
@@ -13,6 +13,7 @@
#include "gsm.h"
#include <memory.h>
#include <stdlib.h>
+#include <string.h>
#include <assert.h>
#define DEBUG 1
diff --git a/util/osdep.c b/util/osdep.c
index 69eb0e9..f726b4e 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -494,7 +494,8 @@
}
#endif
-#ifdef WIN32
+#if defined(_WIN32) && !QEMU_GNUC_PREREQ(4,4)
+// Older Mingw32 didn't provide these.
int asprintf( char **, const char *, ... );
int vasprintf( char **, const char *, va_list );
@@ -516,4 +517,4 @@
va_end( argv );
return retval;
}
-#endif
+#endif // _WIN32 && !QEMU_GNUC_PREREQ(4,4)