Skip to content

Commit

Permalink
Use __builtin_{setjmp,longjmp}() for MinGW
Browse files Browse the repository at this point in the history
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
  • Loading branch information
svaarala committed Dec 18, 2017
1 parent d88f8d4 commit 64e79f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/platforms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions config/platforms/platform_windows.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 64e79f3

Please sign in to comment.