summaryrefslogtreecommitdiff
path: root/py/mpstate.h
diff options
context:
space:
mode:
Diffstat (limited to 'py/mpstate.h')
-rw-r--r--py/mpstate.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/py/mpstate.h b/py/mpstate.h
index 54eca596d..51f290b55 100644
--- a/py/mpstate.h
+++ b/py/mpstate.h
@@ -77,6 +77,18 @@ typedef struct _mp_sched_item_t {
mp_obj_t arg;
} mp_sched_item_t;
+// gc_lock_depth field is a combination of the GC_COLLECT_FLAG
+// bit and a lock depth shifted GC_LOCK_DEPTH_SHIFT bits left.
+#if MICROPY_ENABLE_FINALISER
+#define GC_COLLECT_FLAG 1
+#define GC_LOCK_DEPTH_SHIFT 1
+#else
+// If finalisers are disabled then this check doesn't matter, as gc_lock()
+// is called anywhere else that heap can't be changed. So save some code size.
+#define GC_COLLECT_FLAG 0
+#define GC_LOCK_DEPTH_SHIFT 0
+#endif
+
// This structure holds information about a single contiguous area of
// memory reserved for the memory manager.
typedef struct _mp_state_mem_area_t {
@@ -268,6 +280,7 @@ typedef struct _mp_state_thread_t {
#endif
// Locking of the GC is done per thread.
+ // See GC_LOCK_DEPTH_SHIFT for an explanation of this field.
uint16_t gc_lock_depth;
////////////////////////////////////////////////////////////