Fix setjmp/longjmp on native Windows (#1331)
* Add setjmp wrapper * Add to projects * Use wrapper on x64 * Always build on x64 and exclude on win32 * Fix signature * Add comments * Add comments for os-win32.h * Add extern decleration * Support cmake Windows build * Fix for MinGW
This commit is contained in:
@ -56,13 +56,27 @@
|
||||
# define EWOULDBLOCK WSAEWOULDBLOCK
|
||||
#endif
|
||||
|
||||
#if defined(_WIN64) && !defined(_MSC_VER)
|
||||
#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. */
|
||||
|
||||
#if defined(_MSC_VER) // MSVC
|
||||
|
||||
// See qemu/include/utils/setjmp-wrapper-win32.asm for details.
|
||||
extern int _setjmp_wrapper(jmp_buf);
|
||||
|
||||
# undef setjmp
|
||||
# define setjmp(env) _setjmp_wrapper(env)
|
||||
|
||||
#else // MinGW
|
||||
|
||||
// Original QEMU patch.
|
||||
# undef setjmp
|
||||
# define setjmp(env) _setjmp(env, NULL)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* QEMU uses sigsetjmp()/siglongjmp() as the portable way to specify
|
||||
* "longjmp and don't touch the signal masks". Since we know that the
|
||||
|
Reference in New Issue
Block a user