diff --git a/Makefile.android b/Makefile.android index 8c2db0ab766f..c5bcd0d259b3 100644 --- a/Makefile.android +++ b/Makefile.android @@ -151,6 +151,13 @@ ifneq ($(combo_target)$(TARGET_SIMULATOR),HOST_true) 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 @@ endef # 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 65f08c5aa156..e79ce1b81b42 100755 --- a/android-configure.sh +++ b/android-configure.sh @@ -487,6 +487,16 @@ feature_check_header HAVE_BYTESWAP_H "" feature_check_header HAVE_MACHINE_BSWAP_H "" feature_check_header HAVE_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 @@ if [ "$OPTION_MINGW" = "yes" ] ; then 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 9849bb2243d9..76c907feed2f 100644 --- a/android/build/common.sh +++ b/android/build/common.sh @@ -204,19 +204,29 @@ enable_linux_mingw () 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 6251106ad163..1db090c03153 100644 --- a/android/main-emulator.c +++ b/android/main-emulator.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -68,14 +69,14 @@ static char* getTargetEmulatorPath(const char* progName, const char* avdArch, co 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 4b8796d5d667..4334ce97daca 100644 --- a/android/sockets.c +++ b/android/sockets.c @@ -1210,11 +1210,11 @@ static void socket_cleanup(void) 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 4c5f7b107a8a..8462cea231f1 100644 --- a/android/utils/compiler.h +++ b/android/utils/compiler.h @@ -20,4 +20,13 @@ #define ANDROID_END_HEADER /* nothing */ #endif +// ANDROID_GCC_PREREQ(,) will evaluate to true +// iff the current version of GCC is . 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 8baffe4f4895..b009e2536eb6 100644 --- a/android/utils/filelock.c +++ b/android/utils/filelock.c @@ -91,13 +91,13 @@ filelock_lock( FileLock* lock ) #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 f1a146fdb73d..c88b5cc90903 100644 --- a/android/utils/path.c +++ b/android/utils/path.c @@ -284,7 +284,7 @@ path_mkdir( const char* path, int mode ) { #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 6a6a4e1f2da1..a0344fd2b849 100644 --- a/android/utils/system.c +++ b/android/utils/system.c @@ -67,7 +67,8 @@ android_realloc( void* block, size_t size ) 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 4f4677d746ca..a6b84d11e871 100644 --- a/android/utils/system.h +++ b/android/utils/system.h @@ -103,9 +103,9 @@ typedef int ABool; 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 3f876e727e90..b7c7bc72cf49 100644 --- a/audio/mixeng.c +++ b/audio/mixeng.c @@ -301,7 +301,7 @@ void *st_rate_start (int inrate, int outrate) 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 26419fe20763..a5fd08b5e152 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 3d791d69b371..e1e4169280d1 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 771d6b18f7cf..f25276746b4f 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 @@ typedef struct SDL_SysWMinfo { } 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 /** 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 55cb88a58cfa..6912bd2fdaec 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 #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 10b0a7d6b5aa..9bd0089f71fe 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 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 89d1a88e893e..eed13db900d1 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 #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 76c67a1ccd59..2773bb94f84b 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 /* 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 12d17e0e834b..5e9bae05ccac 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 #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 504d95d2c684..7781814ed0f9 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 #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 6cee54ad2c03..de4ad03a0f44 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 #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 9f1ffff3890e..06c6ce240ffb 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 /* 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 48b1943a9a07..535fa6062fd2 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 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 64743d1af468..e5c079b81abc 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 /* Hidden "this" pointer for the video functions */ diff --git a/exec.c b/exec.c index 7b4dacd13497..6f293899de8f 100644 --- a/exec.c +++ b/exec.c @@ -1174,7 +1174,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name, 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 cfd483ac4299..a7d8ec41ec3d 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 @@ static void goldfish_mmc_do_command(struct goldfish_mmc_state *s, uint32_t cmd, 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 @@ static void goldfish_mmc_do_command(struct goldfish_mmc_state *s, uint32_t cmd, 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 b6a633a86d6e..48e33544790a 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -325,7 +325,7 @@ extern unsigned long reserved_va; #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 0a7fd4c88e3b..293c5abc4dc9 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -12,6 +12,7 @@ #ifndef QEMU_COMMON_H #define QEMU_COMMON_H +#include #include #include "qemu/compiler.h" @@ -107,12 +108,7 @@ static inline char *realpath(const char *path, char *resolved_path) _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 734ad591d999..53a6bd7a1192 100644 --- a/tap-win32.c +++ b/tap-win32.c @@ -576,7 +576,6 @@ static int tap_win32_open(tap_win32_overlapped_t **phandle, } 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 @@ static int tap_win32_open(tap_win32_overlapped_t **phandle, *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 c8bb7c4b6127..25ec569a794a 100644 --- a/target-i386/hax-all.c +++ b/target-i386/hax-all.c @@ -642,13 +642,12 @@ int hax_vcpu_exec(CPUState *cpu) { 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 50ef7155439a..812ac7ce28b3 100644 --- a/telephony/sms.c +++ b/telephony/sms.c @@ -13,6 +13,7 @@ #include "gsm.h" #include #include +#include #include #define DEBUG 1 diff --git a/util/osdep.c b/util/osdep.c index 69eb0e900593..f726b4eacac4 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -494,7 +494,8 @@ writev(int fd, const struct iovec *iov, int iov_cnt) } #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 @@ int asprintf( char **sptr, const char *fmt, ... ) va_end( argv ); return retval; } -#endif +#endif // _WIN32 && !QEMU_GNUC_PREREQ(4,4)