summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2022-12-16 17:30:26 +1100
committerDamien George <damien@micropython.org>2023-03-21 18:01:01 +1100
commit5d4bfce034ace816d67081d6286185d2e35b7125 (patch)
treed228d47518d0cb072f42016544c66692f5912301 /py
parentd677023b3decec2f10d6b00b84b34032db4a0fd4 (diff)
downloadmicropython-5d4bfce034ace816d67081d6286185d2e35b7125.tar.gz
micropython-5d4bfce034ace816d67081d6286185d2e35b7125.zip
py/mpstate: Add mp_thread_is_main_thread() helper macro.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py')
-rw-r--r--py/mpstate.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/py/mpstate.h b/py/mpstate.h
index ba47c76482..4c9380097a 100644
--- a/py/mpstate.h
+++ b/py/mpstate.h
@@ -297,8 +297,10 @@ extern mp_state_ctx_t mp_state_ctx;
#if MICROPY_PY_THREAD
extern mp_state_thread_t *mp_thread_get_state(void);
#define MP_STATE_THREAD(x) (mp_thread_get_state()->x)
+#define mp_thread_is_main_thread() (mp_thread_get_state() == &mp_state_ctx.thread)
#else
#define MP_STATE_THREAD(x) MP_STATE_MAIN_THREAD(x)
+#define mp_thread_is_main_thread() (true)
#endif
#endif // MICROPY_INCLUDED_PY_MPSTATE_H