summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
Diffstat (limited to 'py')
-rw-r--r--py/nlr.c2
-rw-r--r--py/nlr.h10
-rw-r--r--py/nlrx64.c10
-rw-r--r--py/nlrx86.c8
4 files changed, 12 insertions, 18 deletions
diff --git a/py/nlr.c b/py/nlr.c
index 52d56afb8..7114d4997 100644
--- a/py/nlr.c
+++ b/py/nlr.c
@@ -28,7 +28,7 @@
#if !MICROPY_NLR_SETJMP
// When not using setjmp, nlr_push_tail is called from inline asm so needs special c
-#if MICROPY_NLR_X86 && (defined(_WIN32) || defined(__CYGWIN__))
+#if MICROPY_NLR_X86 && MICROPY_NLR_OS_WINDOWS
// On these 32-bit platforms make sure nlr_push_tail doesn't have a leading undersco
unsigned int nlr_push_tail(nlr_buf_t *nlr) asm("nlr_push_tail");
#else
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
diff --git a/py/nlrx64.c b/py/nlrx64.c
index 663a457b7..a3a1cf341 100644
--- a/py/nlrx64.c
+++ b/py/nlrx64.c
@@ -33,18 +33,12 @@
// x86-64 callee-save registers are:
// rbx, rbp, rsp, r12, r13, r14, r15
-#if defined(_WIN32) || defined(__CYGWIN__)
-#define NLR_OS_WINDOWS 1
-#else
-#define NLR_OS_WINDOWS 0
-#endif
-
__attribute__((used)) unsigned int nlr_push_tail(nlr_buf_t *nlr);
unsigned int nlr_push(nlr_buf_t *nlr) {
(void)nlr;
- #if NLR_OS_WINDOWS
+ #if MICROPY_NLR_OS_WINDOWS
__asm volatile (
"movq (%rsp), %rax \n" // load return %rip
@@ -93,7 +87,7 @@ NORETURN void nlr_jump(void *val) {
__asm volatile (
"movq %0, %%rcx \n" // %rcx points to nlr_buf
- #if NLR_OS_WINDOWS
+ #if MICROPY_NLR_OS_WINDOWS
"movq 88(%%rcx), %%rsi \n" // load saved %rsi
"movq 80(%%rcx), %%rdi \n" // load saved %rdr
#endif
diff --git a/py/nlrx86.c b/py/nlrx86.c
index 9490c4f42..23882cc30 100644
--- a/py/nlrx86.c
+++ b/py/nlrx86.c
@@ -33,13 +33,7 @@
// For reference, x86 callee save regs are:
// ebx, esi, edi, ebp, esp, eip
-#if defined(_WIN32) || defined(__CYGWIN__)
-#define NLR_OS_WINDOWS 1
-#else
-#define NLR_OS_WINDOWS 0
-#endif
-
-#if NLR_OS_WINDOWS
+#if MICROPY_NLR_OS_WINDOWS
unsigned int nlr_push_tail(nlr_buf_t *nlr) asm("nlr_push_tail");
#else
__attribute__((used)) unsigned int nlr_push_tail(nlr_buf_t *nlr);