From 857a0e387a6c91b5ea012aafae04c95eba314306 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Wed, 11 Mar 2015 22:08:56 +0100 Subject: [PATCH 1/3] trace/simple: Fix warning and wrong trace file name for MinGW MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Windows, getpid() always returns an int value, but pid_t (which is expected by the format string) is either a 32 bit or a 64 bit value. Without a type cast (or a modified format string), the compiler prints a warning when building for 64 bit Windows and the resulting trace_file_name will include a wrong pid: trace/simple.c:332:9: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘int’ [-Wformat=] Signed-off-by: Stefan Weil --- trace/simple.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/trace/simple.c b/trace/simple.c index 11ad030937..56a624cac8 100644 --- a/trace/simple.c +++ b/trace/simple.c @@ -329,7 +329,8 @@ bool st_set_trace_file(const char *file) g_free(trace_file_name); if (!file) { - trace_file_name = g_strdup_printf(CONFIG_TRACE_FILE, getpid()); + /* Type cast needed for Windows where getpid() returns an int. */ + trace_file_name = g_strdup_printf(CONFIG_TRACE_FILE, (pid_t)getpid()); } else { trace_file_name = g_strdup_printf("%s", file); } From a28c2f2df7679e3a87789e9fb7ed69331f697297 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sat, 14 Nov 2015 20:25:44 +0100 Subject: [PATCH 2/3] oslib-win32: Change return type of function getpagesize getpagesize on Linux returns an int. Fix QEMU's implementation for Windows to return an int (instead of size_t), too. This fixes a compiler warning which was introduced recently (commit 093e3c42). Signed-off-by: Stefan Weil --- include/sysemu/os-win32.h | 2 +- util/oslib-win32.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h index 13dcef6b4c..400e098607 100644 --- a/include/sysemu/os-win32.h +++ b/include/sysemu/os-win32.h @@ -87,7 +87,7 @@ static inline void os_setup_post(void) {} void os_set_line_buffering(void); static inline void os_set_proc_name(const char *dummy) {} -size_t getpagesize(void); +int getpagesize(void); #if !defined(EPROTONOSUPPORT) # define EPROTONOSUPPORT EINVAL diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 09f9e98a40..6a47019dfb 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -454,7 +454,7 @@ gint g_poll(GPollFD *fds, guint nfds, gint timeout) return retval; } -size_t getpagesize(void) +int getpagesize(void) { SYSTEM_INFO system_info; From 78e9d4ad11e7116376328860a58b96765ade7b62 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Thu, 26 Nov 2015 12:13:12 +0100 Subject: [PATCH 3/3] w32: Use gcc option -mthreads QEMU uses threads / coroutines, therefore support for thread local storage and thread safe libraries (-D_MT) must be enabled by using -mthreads. Signed-off-by: Stefan Weil --- configure | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure b/configure index 979bc55906..67801b06bb 100755 --- a/configure +++ b/configure @@ -727,6 +727,8 @@ if test "$mingw32" = "yes" ; then QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS" # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later) QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS" + # MinGW needs -mthreads for TLS and macro _MT. + QEMU_CFLAGS="-mthreads $QEMU_CFLAGS" LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS" write_c_skeleton; if compile_prog "" "-liberty" ; then