summaryrefslogtreecommitdiff
path: root/py/nlr.h
diff options
context:
space:
mode:
authorstijn <stijn@ignitron.net>2017-12-26 10:52:09 +0100
committerDamien George <damien.p.george@gmail.com>2017-12-29 22:24:46 +1100
commitb184b6ae5334b87472897d0034a7388acafe41cc (patch)
treee7e7aaa67cccc1d5f7e9f9a6a7f632f0d3a92b25 /py/nlr.h
parent8041de59fed09e3185aaf01bb2faf1f733747dc8 (diff)
py/nlr: Fix nlr functions for 64bit ports built with gcc on Windows
The number of registers used should be 10, not 12, to match the assembly code in nlrx64.c. With this change the 64bit mingw builds don't need to use the setjmp implementation, and this fixes miscellaneous crashes and assertion failures as reported in #1751 for instance. To avoid mistakes in the future where something gcc-related for Windows only gets fixed for one particular compiler/environment combination, make use of a MICROPY_NLR_OS_WINDOWS macro. To make sure everything nlr-related is now ok when built with gcc this has been verified with: - unix port built with gcc on Cygwin (i686-pc-cygwin-gcc and x86_64-pc-cygwin-gcc, version 6.4.0) - windows port built with mingw-w64's gcc from Cygwin (i686-w64-mingw32-gcc and x86_64-w64-mingw32-gcc, version 6.4.0) and MSYS2 (like the ones on Cygwin but version 7.2.0)
Diffstat (limited to 'py/nlr.h')
-rw-r--r--py/nlr.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/py/nlr.h b/py/nlr.h
index e4dfa6896..90595a12d 100644
--- a/py/nlr.h
+++ b/py/nlr.h
@@ -36,13 +36,19 @@
// If MICROPY_NLR_SETJMP is not enabled then auto-detect the machine arch
#if !MICROPY_NLR_SETJMP
+// A lot of nlr-related things need different treatment on Windows
+#if defined(_WIN32) || defined(__CYGWIN__)
+#define MICROPY_NLR_OS_WINDOWS 1
+#else
+#define MICROPY_NLR_OS_WINDOWS 0
+#endif
#if defined(__i386__)
#define MICROPY_NLR_X86 (1)
#define MICROPY_NLR_NUM_REGS (6)
#elif defined(__x86_64__)
#define MICROPY_NLR_X64 (1)
- #if defined(__CYGWIN__)
- #define MICROPY_NLR_NUM_REGS (12)
+ #if MICROPY_NLR_OS_WINDOWS
+ #define MICROPY_NLR_NUM_REGS (10)
#else
#define MICROPY_NLR_NUM_REGS (8)
#endif