From 64e79f36c3f39486ad3f922543d88cc4af5c64bf Mon Sep 17 00:00:00 2001 From: Sami Vaarala Date: Mon, 27 Mar 2017 19:45:12 +0300 Subject: [PATCH] Use __builtin_{setjmp,longjmp}() for MinGW Use __builtin_{setjmp,longjmp}() for MinGW for both POSIX and Windows build targets, to avoid issues described in: - http://www.agardner.me/golang/windows/cgo/64-bit/setjmp/longjmp/2016/02/29/go-windows-setjmp-x86.html --- config/platforms.yaml | 1 + config/platforms/platform_windows.h.in | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/config/platforms.yaml b/config/platforms.yaml index 00bed2e987..8254590f0e 100644 --- a/config/platforms.yaml +++ b/config/platforms.yaml @@ -32,6 +32,7 @@ autodetect: check: DUK_F_DURANGO include: platform_durango.h.in - + # For Cygwin POSIX target, __CYGWIN__ will be set but _WIN32 etc won't. name: Windows check: DUK_F_WINDOWS include: platform_windows.h.in diff --git a/config/platforms/platform_windows.h.in b/config/platforms/platform_windows.h.in index 9e6fcf9ec8..bd53016309 100644 --- a/config/platforms/platform_windows.h.in +++ b/config/platforms/platform_windows.h.in @@ -57,3 +57,12 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 1 #endif + +/* Use __builtin_setjmp() for MinGW to avoid issues described in: + * http://www.agardner.me/golang/windows/cgo/64-bit/setjmp/longjmp/2016/02/29/go-windows-setjmp-x86.html. + */ +#if defined(DUK_F_MINGW) +#define DUK_JMPBUF_TYPE jmp_buf +#define DUK_SETJMP(jb) __builtin_setjmp((jb)) +#define DUK_LONGJMP(jb) __builtin_longjmp((jb), 1) +#endif