summaryrefslogtreecommitdiff
path: root/qemu-os-win32.h
diff options
context:
space:
mode:
authorStefan Weil <sw@weilnetz.de>2012-04-12 21:13:28 +0200
committerStefan Weil <sw@weilnetz.de>2012-04-15 21:25:16 +0200
commit5cf6dd51abb252d25cb77d3b7a95a744bed1a69c (patch)
tree12bd37768cc2938e9dcd1f00eb33f7c9f97b1984 /qemu-os-win32.h
parentacf126ba58425f11e74fbb9c1095224cb142fffa (diff)
w64: Fix definition of setjmp
The default definition of setjmp which is implemented in MinGW-w64 cannot be used with programs like QEMU which call longjmp from code without structured exception handling (SEH). This code therefore disables stack unwinding. We could also implement SEH for QEMU's generated JIT code, but that is much more difficult. Stack unwinding would also cost execution time. Signed-off-by: Stefan Weil <sw@weilnetz.de>
Diffstat (limited to 'qemu-os-win32.h')
-rw-r--r--qemu-os-win32.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/qemu-os-win32.h b/qemu-os-win32.h
index b6533c0979..753679b194 100644
--- a/qemu-os-win32.h
+++ b/qemu-os-win32.h
@@ -56,6 +56,15 @@
# 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
+
/* Declaration of ffs() is missing in MinGW's strings.h. */
int ffs(int i);