aboutsummaryrefslogtreecommitdiff
path: root/py/gc.c
diff options
context:
space:
mode:
authorDavid Lechner <david@pybricks.com>2020-01-22 11:19:37 -0600
committerDamien George <damien.p.george@gmail.com>2020-01-23 13:28:42 +1100
commitccc18f047d6669583cdf8ddd53ec41d026743a25 (patch)
tree89dc418a208b0206c34d82f18a1f2ca4f1dd718d /py/gc.c
parent6db5cede06dfb580c5e4f6cdeb1796256969b4fb (diff)
py/gc: Don't include or init gc_mutex when GIL is enabled.
When threads and the GIL are enabled, then the GC mutex is not needed. The gc_mutex field is never used in this case because of: #if MICROPY_PY_THREAD && !MICROPY_PY_THREAD_GIL #define GC_ENTER() mp_thread_mutex_lock(&MP_STATE_MEM(gc_mutex), 1) #define GC_EXIT() mp_thread_mutex_unlock(&MP_STATE_MEM(gc_mutex)) #else #define GC_ENTER() #define GC_EXIT() #endif So, we can completely remove gc_mutex everywhere when MICROPY_PY_THREAD && !MICROPY_PY_THREAD_GIL.
Diffstat (limited to 'py/gc.c')
-rw-r--r--py/gc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/py/gc.c b/py/gc.c
index c763a839e..c18cd429f 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -161,7 +161,7 @@ void gc_init(void *start, void *end) {
MP_STATE_MEM(gc_alloc_amount) = 0;
#endif
- #if MICROPY_PY_THREAD
+ #if MICROPY_PY_THREAD && !MICROPY_PY_THREAD_GIL
mp_thread_mutex_init(&MP_STATE_MEM(gc_mutex));
#endif