Skip to content

Commit bf1570c

Browse files
stinospfalcon
authored andcommitted
nlr: Use single preprocessor symbol to check if building on Windows
1 parent 6edffd0 commit bf1570c

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

py/nlrx64.S

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,16 @@
3939
#define NLR_TOP (_mp_state_ctx + NLR_TOP_OFFSET)
4040
#else
4141
#define NLR_TOP (mp_state_ctx + NLR_TOP_OFFSET)
42+
#endif
43+
44+
#if defined(_WIN32) || defined(__CYGWIN__)
45+
#define NLR_OS_WINDOWS
4246
#endif
4347

4448
.file "nlr.s"
4549
.text
4650

47-
#if !defined(__CYGWIN__)
51+
#if !defined(NLR_OS_WINDOWS)
4852

4953
/******************************************************************************/
5054
//
@@ -140,11 +144,11 @@ nlr_jump:
140144
je _nlr_jump_fail # transfer control to nlr_jump_fail
141145
#endif
142146

143-
#else // !defined(__CYGWIN__)
147+
#else // !defined(NLR_OS_WINDOWS)
144148

145149
/******************************************************************************/
146150
//
147-
// Functions for Cygwin
151+
// Functions for Windows
148152
//
149153
/******************************************************************************/
150154

@@ -210,6 +214,6 @@ nlr_jump:
210214
movq %rax, %rcx # put argument back in first-arg register
211215
je nlr_jump_fail # transfer control to nlr_jump_fail
212216

213-
#endif // !defined(__CYGWIN__)
217+
#endif // !defined(NLR_OS_WINDOWS)
214218

215219
#endif // defined(__x86_64__) && !MICROPY_NLR_SETJMP

py/nlrx86.S

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#define NLR_TOP_OFFSET (2 * 4)
3737

3838
#if defined(_WIN32) || defined(__CYGWIN__)
39+
#define NLR_OS_WINDOWS
3940
#define NLR_TOP (_mp_state_ctx + NLR_TOP_OFFSET)
4041
#else
4142
#define NLR_TOP (mp_state_ctx + NLR_TOP_OFFSET)
@@ -47,7 +48,7 @@
4748
/**************************************/
4849
// mp_uint_t nlr_push(4(%esp)=nlr_buf_t *nlr)
4950

50-
#if defined(_WIN32) || defined(__CYGWIN__)
51+
#if defined(NLR_OS_WINDOWS)
5152
.globl _nlr_push
5253
.def _nlr_push; .scl 2; .type 32; .endef
5354
_nlr_push:
@@ -69,14 +70,14 @@ nlr_push:
6970
mov %edx, NLR_TOP # stor new nlr_buf (to make linked list)
7071
xor %eax, %eax # return 0, normal return
7172
ret # return
72-
#if !(defined(_WIN32) || defined(__CYGWIN__))
73+
#if !defined(NLR_OS_WINDOWS)
7374
.size nlr_push, .-nlr_push
7475
#endif
7576

7677
/**************************************/
7778
// void nlr_pop()
7879

79-
#if defined(_WIN32) || defined(__CYGWIN__)
80+
#if defined(NLR_OS_WINDOWS)
8081
.globl _nlr_pop
8182
.def _nlr_pop; .scl 2; .type 32; .endef
8283
_nlr_pop:
@@ -89,14 +90,14 @@ nlr_pop:
8990
mov (%eax), %eax # load prev nlr_buf
9091
mov %eax, NLR_TOP # store nlr_top (to unlink list)
9192
ret # return
92-
#if !(defined(_WIN32) || defined(__CYGWIN__))
93+
#if !defined(NLR_OS_WINDOWS)
9394
.size nlr_pop, .-nlr_pop
9495
#endif
9596

9697
/**************************************/
9798
// void nlr_jump(4(%esp)=mp_uint_t val)
9899

99-
#if defined(_WIN32) || defined(__CYGWIN__)
100+
#if defined(NLR_OS_WINDOWS)
100101
.globl _nlr_jump
101102
.def _nlr_jump; .scl 2; .type 32; .endef
102103
_nlr_jump:
@@ -107,7 +108,7 @@ nlr_jump:
107108
#endif
108109
mov NLR_TOP, %edx # load nlr_top
109110
test %edx, %edx # check for nlr_top being NULL
110-
#if defined(_WIN32) || defined(__CYGWIN__)
111+
#if defined(NLR_OS_WINDOWS)
111112
je _nlr_jump_fail # fail if nlr_top is NULL
112113
#else
113114
je nlr_jump_fail # fail if nlr_top is NULL
@@ -126,7 +127,7 @@ nlr_jump:
126127
xor %eax, %eax # clear return register
127128
inc %al # increase to make 1, non-local return
128129
ret # return
129-
#if !(defined(_WIN32) || defined(__CYGWIN__))
130+
#if !defined(NLR_OS_WINDOWS)
130131
.size nlr_jump, .-nlr_jump
131132
#endif
132133

0 commit comments

Comments
 (0)