From 94238d4ae5851802db75aa49d4b68bca6f99d6a8 Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 30 May 2016 19:27:26 +0100 Subject: [PATCH] py/nlrsetjmp: Update to take into account new location of nlr_top. It's now accessed via the MP_STATE_THREAD macro. --- py/nlr.h | 10 +++++----- py/nlrsetjmp.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/py/nlr.h b/py/nlr.h index aacac6a59c..6c86fc26c3 100644 --- a/py/nlr.h +++ b/py/nlr.h @@ -70,8 +70,8 @@ struct _nlr_buf_t { NORETURN void nlr_setjmp_jump(void *val); // nlr_push() must be defined as a macro, because "The stack context will be // invalidated if the function which called setjmp() returns." -#define nlr_push(buf) ((buf)->prev = MP_STATE_VM(nlr_top), MP_STATE_VM(nlr_top) = (buf), setjmp((buf)->jmpbuf)) -#define nlr_pop() { MP_STATE_VM(nlr_top) = MP_STATE_VM(nlr_top)->prev; } +#define nlr_push(buf) ((buf)->prev = MP_STATE_THREAD(nlr_top), MP_STATE_THREAD(nlr_top) = (buf), setjmp((buf)->jmpbuf)) +#define nlr_pop() { MP_STATE_THREAD(nlr_top) = MP_STATE_THREAD(nlr_top)->prev; } #define nlr_jump(val) nlr_setjmp_jump(val) #else unsigned int nlr_push(nlr_buf_t *); @@ -91,7 +91,7 @@ void nlr_jump_fail(void *val); #include "mpstate.h" #define nlr_raise(val) \ do { \ - /*printf("nlr_raise: nlr_top=%p\n", MP_STATE_VM(nlr_top)); \ + /*printf("nlr_raise: nlr_top=%p\n", MP_STATE_THREAD(nlr_top)); \ fflush(stdout);*/ \ void *_val = MP_OBJ_TO_PTR(val); \ assert(_val != NULL); \ @@ -101,11 +101,11 @@ void nlr_jump_fail(void *val); #if !MICROPY_NLR_SETJMP #define nlr_push(val) \ - assert(MP_STATE_VM(nlr_top) != val),nlr_push(val) + assert(MP_STATE_THREAD(nlr_top) != val),nlr_push(val) /* #define nlr_push(val) \ - printf("nlr_push: before: nlr_top=%p, val=%p\n", MP_STATE_VM(nlr_top), val),assert(MP_STATE_VM(nlr_top) != val),nlr_push(val) + printf("nlr_push: before: nlr_top=%p, val=%p\n", MP_STATE_THREAD(nlr_top), val),assert(MP_STATE_THREAD(nlr_top) != val),nlr_push(val) #endif */ #endif diff --git a/py/nlrsetjmp.c b/py/nlrsetjmp.c index 661b650c5c..43a13156f2 100644 --- a/py/nlrsetjmp.c +++ b/py/nlrsetjmp.c @@ -29,8 +29,8 @@ #if MICROPY_NLR_SETJMP void nlr_setjmp_jump(void *val) { - nlr_buf_t *buf = MP_STATE_VM(nlr_top); - MP_STATE_VM(nlr_top) = buf->prev; + nlr_buf_t *buf = MP_STATE_THREAD(nlr_top); + MP_STATE_THREAD(nlr_top) = buf->prev; buf->ret_val = val; longjmp(buf->jmpbuf, 1); }