Skip to content

Commit

Permalink
py/mpstate: Add mp_thread_is_main_thread() helper macro.
Browse files Browse the repository at this point in the history
Signed-off-by: Damien George <[email protected]>
  • Loading branch information
dpgeorge committed Mar 21, 2023
1 parent d677023 commit 5d4bfce
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions py/mpstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5d4bfce

Please sign in to comment.