summaryrefslogtreecommitdiff
path: root/py/gc.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-11-27 17:01:44 +0000
committerDamien George <damien.p.george@gmail.com>2015-11-29 14:25:35 +0000
commit999cedb90ff0827cdb9dfe0e4faa6ebc1739d271 (patch)
tree897eb07b82f1893cfd413b9ef7f625cd996f859d /py/gc.c
parentcbf7674025814797f5c537d6d1c195efe58ccaaf (diff)
py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR.
This allows the mp_obj_t type to be configured to something other than a pointer-sized primitive type. This patch also includes additional changes to allow the code to compile when sizeof(mp_uint_t) != sizeof(void*), such as using size_t instead of mp_uint_t, and various casts.
Diffstat (limited to 'py/gc.c')
-rw-r--r--py/gc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/py/gc.c b/py/gc.c
index 2dad9d8a7..6de8a7a02 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -203,7 +203,7 @@ STATIC void gc_drain_stack(void) {
mp_obj_t *scan = (mp_obj_t*)PTR_FROM_BLOCK(block);
for (mp_uint_t i = n_blocks * WORDS_PER_BLOCK; i > 0; i--, scan++) {
mp_obj_t obj = *scan;
- void *ptr2 = (void*)obj;
+ void *ptr2 = MP_OBJ_TO_PTR(obj);
VERIFY_MARK_AND_PUSH(ptr2);
}
}
@@ -237,7 +237,7 @@ STATIC void gc_sweep(void) {
#if MICROPY_ENABLE_FINALISER
if (FTB_GET(block)) {
mp_obj_t obj = (mp_obj_t)PTR_FROM_BLOCK(block);
- if (((mp_obj_base_t*)obj)->type != MP_OBJ_NULL) {
+ if (((mp_obj_base_t*)MP_OBJ_TO_PTR(obj))->type != NULL) {
// if the object has a type then see if it has a __del__ method
mp_obj_t dest[2];
mp_load_method_maybe(obj, MP_QSTR___del__, dest);