aboutsummaryrefslogtreecommitdiff
path: root/py/modgc.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-01-01 23:30:53 +0000
committerDamien George <damien.p.george@gmail.com>2015-01-07 20:33:00 +0000
commitb4b10fd350852e321624d74983cca286091b55a1 (patch)
tree7ac4aa40d70be0170a61f649e9d73c42faa4ba33 /py/modgc.c
parentad2307c92c15f0aa90dbd0741fd2538719d0b5e1 (diff)
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.
Diffstat (limited to 'py/modgc.c')
-rw-r--r--py/modgc.c7
1 files changed, 4 insertions, 3 deletions
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);