Merge pull request #146 from dhalbert/stack_check-fix

Fix broken mp_stack_check() when using -flto
This commit is contained in:
Scott Shawcroft 2017-06-05 11:51:27 -07:00 committed by GitHub
commit 9805abd858

View File

@ -31,6 +31,8 @@
#include "py/stackctrl.h" #include "py/stackctrl.h"
void mp_stack_ctrl_init(void) { void mp_stack_ctrl_init(void) {
// Force routine to not be inlined. Better guarantee than MP_NOINLINE for -flto.
asm("");
volatile int stack_dummy; volatile int stack_dummy;
MP_STATE_THREAD(stack_top) = (char*)&stack_dummy; MP_STATE_THREAD(stack_top) = (char*)&stack_dummy;
} }
@ -41,6 +43,8 @@ void mp_stack_set_top(void *top) {
mp_uint_t mp_stack_usage(void) { mp_uint_t mp_stack_usage(void) {
// Assumes descending stack // Assumes descending stack
// Force routine to not be inlined. Better guarantee than MP_NOINLINE for -flto.
asm("");
volatile int stack_dummy; volatile int stack_dummy;
return MP_STATE_THREAD(stack_top) - (char*)&stack_dummy; return MP_STATE_THREAD(stack_top) - (char*)&stack_dummy;
} }