From b4b10fd350852e321624d74983cca286091b55a1 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 1 Jan 2015 23:30:53 +0000 Subject: py: Put all global state together in state structures. This patch consolidates all global variables in py/ core into one place, in a global structure. Root pointers are all located together to make GC tracing easier and more efficient. --- py/modgc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'py/modgc.c') diff --git a/py/modgc.c b/py/modgc.c index e3cbe72f9..38f7c15fe 100644 --- a/py/modgc.c +++ b/py/modgc.c @@ -24,6 +24,7 @@ * THE SOFTWARE. */ +#include "py/mpstate.h" #include "py/obj.h" #include "py/gc.h" @@ -48,7 +49,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(gc_collect_obj, py_gc_collect); /// \function disable() /// Disable the garbage collector. STATIC mp_obj_t gc_disable(void) { - gc_auto_collect_enabled = 0; + MP_STATE_MEM(gc_auto_collect_enabled) = 0; return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_0(gc_disable_obj, gc_disable); @@ -56,13 +57,13 @@ MP_DEFINE_CONST_FUN_OBJ_0(gc_disable_obj, gc_disable); /// \function enable() /// Enable the garbage collector. STATIC mp_obj_t gc_enable(void) { - gc_auto_collect_enabled = 1; + MP_STATE_MEM(gc_auto_collect_enabled) = 1; return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_0(gc_enable_obj, gc_enable); STATIC mp_obj_t gc_isenabled(void) { - return MP_BOOL(gc_auto_collect_enabled); + return MP_BOOL(MP_STATE_MEM(gc_auto_collect_enabled)); } MP_DEFINE_CONST_FUN_OBJ_0(gc_isenabled_obj, gc_isenabled); -- cgit v1.2.3