Skip to content

Commit e90b6ce

Browse files
committed
py/mpthread.h: Move GIL macros outside MICROPY_PY_THREAD block.
The GIL macros are needed even if threading is not enabled.
1 parent 94d2919 commit e90b6ce

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

py/mpthread.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@
3838

3939
struct _mp_state_thread_t;
4040

41-
#if MICROPY_PY_THREAD_GIL
42-
#define MP_THREAD_GIL_ENTER() mp_thread_mutex_lock(&MP_STATE_VM(gil_mutex), 1)
43-
#define MP_THREAD_GIL_EXIT() mp_thread_mutex_unlock(&MP_STATE_VM(gil_mutex))
44-
#else
45-
#define MP_THREAD_GIL_ENTER()
46-
#define MP_THREAD_GIL_EXIT()
47-
#endif
48-
4941
struct _mp_state_thread_t *mp_thread_get_state(void);
5042
void mp_thread_set_state(void *state);
5143
void mp_thread_create(void *(*entry)(void*), void *arg, size_t stack_size);
@@ -57,4 +49,12 @@ void mp_thread_mutex_unlock(mp_thread_mutex_t *mutex);
5749

5850
#endif // MICROPY_PY_THREAD
5951

52+
#if MICROPY_PY_THREAD && MICROPY_PY_THREAD_GIL
53+
#define MP_THREAD_GIL_ENTER() mp_thread_mutex_lock(&MP_STATE_VM(gil_mutex), 1)
54+
#define MP_THREAD_GIL_EXIT() mp_thread_mutex_unlock(&MP_STATE_VM(gil_mutex))
55+
#else
56+
#define MP_THREAD_GIL_ENTER()
57+
#define MP_THREAD_GIL_EXIT()
58+
#endif
59+
6060
#endif // __MICROPY_INCLUDED_PY_MPTHREAD_H__

0 commit comments

Comments
 (0)