py/mpthread.h: Use strong type for mp_thread_set_state() argument.

This modifies the signature of mp_thread_set_state() to use
mp_state_thread_t* instead of void*.  This matches the return type of
mp_thread_get_state(), which returns the same value.

`struct _mp_state_thread_t;` had to be moved before
`#include <mpthreadport.h>` since the stm32 port uses it in its
mpthreadport.h file.
This commit is contained in:
David Lechner 2020-01-24 11:37:53 -06:00 committed by Damien George
parent a542c6d7e0
commit b72cb0ca1b
5 changed files with 7 additions and 7 deletions

View File

@ -85,7 +85,7 @@ mp_state_thread_t *mp_thread_get_state(void) {
return pvTaskGetThreadLocalStoragePointer(NULL, 0); return pvTaskGetThreadLocalStoragePointer(NULL, 0);
} }
void mp_thread_set_state(void *state) { void mp_thread_set_state(mp_state_thread_t *state) {
vTaskSetThreadLocalStoragePointer(NULL, 0, state); vTaskSetThreadLocalStoragePointer(NULL, 0, state);
} }

View File

@ -92,7 +92,7 @@ mp_state_thread_t *mp_thread_get_state(void) {
return pvTaskGetThreadLocalStoragePointer(NULL, 1); return pvTaskGetThreadLocalStoragePointer(NULL, 1);
} }
void mp_thread_set_state(void *state) { void mp_thread_set_state(mp_state_thread_t *state) {
vTaskSetThreadLocalStoragePointer(NULL, 1, state); vTaskSetThreadLocalStoragePointer(NULL, 1, state);
} }

View File

@ -32,7 +32,7 @@ typedef pyb_mutex_t mp_thread_mutex_t;
void mp_thread_init(void); void mp_thread_init(void);
void mp_thread_gc_others(void); void mp_thread_gc_others(void);
static inline void mp_thread_set_state(void *state) { static inline void mp_thread_set_state(struct _mp_state_thread_t *state) {
pyb_thread_set_local(state); pyb_thread_set_local(state);
} }

View File

@ -158,7 +158,7 @@ mp_state_thread_t *mp_thread_get_state(void) {
return (mp_state_thread_t*)pthread_getspecific(tls_key); return (mp_state_thread_t*)pthread_getspecific(tls_key);
} }
void mp_thread_set_state(void *state) { void mp_thread_set_state(mp_state_thread_t *state) {
pthread_setspecific(tls_key, state); pthread_setspecific(tls_key, state);
} }

View File

@ -30,16 +30,16 @@
#if MICROPY_PY_THREAD #if MICROPY_PY_THREAD
struct _mp_state_thread_t;
#ifdef MICROPY_MPTHREADPORT_H #ifdef MICROPY_MPTHREADPORT_H
#include MICROPY_MPTHREADPORT_H #include MICROPY_MPTHREADPORT_H
#else #else
#include <mpthreadport.h> #include <mpthreadport.h>
#endif #endif
struct _mp_state_thread_t;
struct _mp_state_thread_t *mp_thread_get_state(void); struct _mp_state_thread_t *mp_thread_get_state(void);
void mp_thread_set_state(void *state); void mp_thread_set_state(struct _mp_state_thread_t *state);
void mp_thread_create(void *(*entry)(void*), void *arg, size_t *stack_size); void mp_thread_create(void *(*entry)(void*), void *arg, size_t *stack_size);
void mp_thread_start(void); void mp_thread_start(void);
void mp_thread_finish(void); void mp_thread_finish(void);