From: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, zealot351@gmail.com,
maria.klimushenkova@ispras.ru, pavel.dovgaluk@ispras.ru,
sw@weilnetz.de
Subject: [Qemu-devel] [PATCH] win64: perform correct setjmp calls
Date: Mon, 09 Feb 2015 10:55:30 +0300 [thread overview]
Message-ID: <20150209075530.4252.76551.stgit@PASHA-ISP> (raw)
On w64, setjmp is implemented by _setjmp which needs a second parameter.
This parameter should be NULL to allow using longjump from generated code.
This patch replaces all usages of setjmp.h with new header files which
replaces setjmp with _setjmp function on win64 platform.
Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
---
coroutine-sigaltstack.c | 2 +-
coroutine-ucontext.c | 2 +-
disas/i386.c | 2 +-
disas/m68k.c | 2 +-
include/qom/cpu.h | 2 +-
include/sysemu/os-win32.h | 17 -----------------
include/sysemu/setjmp.h | 35 +++++++++++++++++++++++++++++++++++
util/oslib-posix.c | 2 +-
8 files changed, 41 insertions(+), 23 deletions(-)
create mode 100755 include/sysemu/setjmp.h
diff --git a/coroutine-sigaltstack.c b/coroutine-sigaltstack.c
index 63519ff..c890496 100644
--- a/coroutine-sigaltstack.c
+++ b/coroutine-sigaltstack.c
@@ -26,7 +26,7 @@
#undef _FORTIFY_SOURCE
#endif
#include <stdlib.h>
-#include <setjmp.h>
+#include "sysemu/setjmp.h"
#include <stdint.h>
#include <pthread.h>
#include <signal.h>
diff --git a/coroutine-ucontext.c b/coroutine-ucontext.c
index 259fcb4..12e2826 100644
--- a/coroutine-ucontext.c
+++ b/coroutine-ucontext.c
@@ -23,7 +23,7 @@
#undef _FORTIFY_SOURCE
#endif
#include <stdlib.h>
-#include <setjmp.h>
+#include "sysemu/setjmp.h"
#include <stdint.h>
#include <ucontext.h>
#include "qemu-common.h"
diff --git a/disas/i386.c b/disas/i386.c
index 00ceca9..fdb1ec6 100644
--- a/disas/i386.c
+++ b/disas/i386.c
@@ -153,7 +153,7 @@
/* opcodes/i386-dis.c r1.126 */
#include "qemu-common.h"
-#include <setjmp.h>
+#include "sysemu/setjmp.h"
static int fetch_data2(struct disassemble_info *, bfd_byte *);
static int fetch_data(struct disassemble_info *, bfd_byte *);
diff --git a/disas/m68k.c b/disas/m68k.c
index cc0db96..312351e 100644
--- a/disas/m68k.c
+++ b/disas/m68k.c
@@ -616,7 +616,7 @@ static const char *const reg_half_names[] =
/* Maximum length of an instruction. */
#define MAXLEN 22
-#include <setjmp.h>
+#include "sysemu/setjmp.h"
struct private
{
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 2098f1c..16dc2f7 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -21,7 +21,7 @@
#define QEMU_CPU_H
#include <signal.h>
-#include <setjmp.h>
+#include "sysemu/setjmp.h"
#include "hw/qdev-core.h"
#include "exec/hwaddr.h"
#include "qemu/queue.h"
diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h
index af3fbc4..0387313 100644
--- a/include/sysemu/os-win32.h
+++ b/include/sysemu/os-win32.h
@@ -55,23 +55,6 @@
# define EWOULDBLOCK WSAEWOULDBLOCK
#endif
-#if defined(_WIN64)
-/* On w64, setjmp is implemented by _setjmp which needs a second parameter.
- * If this parameter is NULL, longjump does no stack unwinding.
- * That is what we need for QEMU. Passing the value of register rsp (default)
- * lets longjmp try a stack unwinding which will crash with generated code. */
-# undef setjmp
-# define setjmp(env) _setjmp(env, NULL)
-#endif
-/* QEMU uses sigsetjmp()/siglongjmp() as the portable way to specify
- * "longjmp and don't touch the signal masks". Since we know that the
- * savemask parameter will always be zero we can safely define these
- * in terms of setjmp/longjmp on Win32.
- */
-#define sigjmp_buf jmp_buf
-#define sigsetjmp(env, savemask) setjmp(env)
-#define siglongjmp(env, val) longjmp(env, val)
-
/* Declaration of ffs() is missing in MinGW's strings.h. */
int ffs(int i);
diff --git a/include/sysemu/setjmp.h b/include/sysemu/setjmp.h
new file mode 100755
index 0000000..ffd804a
--- /dev/null
+++ b/include/sysemu/setjmp.h
@@ -0,0 +1,35 @@
+/*
+ * setjmp.h
+ *
+ * Copyright (c) 2015 Institute for System Programming
+ * of the Russian Academy of Sciences.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+#ifndef QEMU_SETJMP_H
+#define QEMU_SETJMP_H
+
+#include <setjmp.h>
+
+#if defined(_WIN32)
+#if defined(_WIN64)
+/* On w64, setjmp is implemented by _setjmp which needs a second parameter.
+ * If this parameter is NULL, longjump does no stack unwinding.
+ * That is what we need for QEMU. Passing the value of register rsp (default)
+ * lets longjmp try a stack unwinding which will crash with generated code. */
+# undef setjmp
+# define setjmp(env) _setjmp(env, NULL)
+#endif
+/* QEMU uses sigsetjmp()/siglongjmp() as the portable way to specify
+ * "longjmp and don't touch the signal masks". Since we know that the
+ * savemask parameter will always be zero we can safely define these
+ * in terms of setjmp/longjmp on Win32.
+ */
+#define sigjmp_buf jmp_buf
+#define sigsetjmp(env, savemask) setjmp(env)
+#define siglongjmp(env, val) longjmp(env, val)
+#endif
+
+#endif
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 16fcec2..23b7af8 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -59,7 +59,7 @@ extern int daemon(int, int);
#include "qemu/sockets.h"
#include <sys/mman.h>
#include <libgen.h>
-#include <setjmp.h>
+#include "sysemu/setjmp.h"
#include <sys/signal.h>
#ifdef CONFIG_LINUX
next reply other threads:[~2015-02-09 7:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-09 7:55 Pavel Dovgalyuk [this message]
2015-02-09 8:04 ` [Qemu-devel] [PATCH] win64: perform correct setjmp calls Stefan Weil
2015-02-09 8:07 ` Pavel Dovgaluk
2015-02-09 19:47 ` Stefan Weil
2015-02-10 5:50 ` Pavel Dovgaluk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150209075530.4252.76551.stgit@PASHA-ISP \
--to=pavel.dovgaluk@ispras.ru \
--cc=maria.klimushenkova@ispras.ru \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=sw@weilnetz.de \
--cc=zealot351@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.