ports: Rename thread_t to mp_thread_t.

This adds the `mp_` prefix to the `thread_t` type.  The name `thread_t`
conflicts with the same in `mach/mach_types.h` on macOS.

Signed-off-by: David Lechner <david@lechnology.com>
This commit is contained in:
David Lechner
2022-05-03 22:03:43 -05:00
committed by Damien George
parent 75efb3267c
commit be5657b64f
3 changed files with 32 additions and 32 deletions

View File

@@ -37,19 +37,19 @@
#if MICROPY_PY_THREAD
// this structure forms a linked list, one node per active thread
typedef struct _thread_t {
typedef struct _mp_thread_t {
TaskHandle_t id; // system id of thread
int ready; // whether the thread is ready and running
void *arg; // thread Python args, a GC root pointer
void *stack; // pointer to the stack
size_t stack_len; // number of words in the stack
struct _thread_t *next;
} thread_t;
struct _mp_thread_t *next;
} mp_thread_t;
// the mutex controls access to the linked list
STATIC mp_thread_mutex_t thread_mutex;
STATIC thread_t thread_entry0;
STATIC thread_t *thread; // root pointer, handled bp mp_thread_gc_others
STATIC mp_thread_t thread_entry0;
STATIC mp_thread_t *thread; // root pointer, handled bp mp_thread_gc_others
void mp_thread_init(void) {
mp_thread_mutex_init(&thread_mutex);
@@ -67,7 +67,7 @@ void mp_thread_init(void) {
void mp_thread_gc_others(void) {
mp_thread_mutex_lock(&thread_mutex, 1);
for (thread_t *th = thread; th != NULL; th = th->next) {
for (mp_thread_t *th = thread; th != NULL; th = th->next) {
gc_collect_root((void **)&th, 1);
gc_collect_root(&th->arg, 1); // probably not needed
if (th->id == xTaskGetCurrentTaskHandle()) {
@@ -91,7 +91,7 @@ void mp_thread_set_state(mp_state_thread_t *state) {
void mp_thread_start(void) {
mp_thread_mutex_lock(&thread_mutex, 1);
for (thread_t *th = thread; th != NULL; th = th->next) {
for (mp_thread_t *th = thread; th != NULL; th = th->next) {
if (th->id == xTaskGetCurrentTaskHandle()) {
th->ready = 1;
break;
@@ -124,7 +124,7 @@ void mp_thread_create(void *(*entry)(void *), void *arg, size_t *stack_size) {
// allocate TCB, stack and linked-list node (must be outside thread_mutex lock)
StaticTask_t *tcb = m_new(StaticTask_t, 1);
StackType_t *stack = m_new(StackType_t, *stack_size / sizeof(StackType_t));
thread_t *th = m_new_obj(thread_t);
mp_thread_t *th = m_new_obj(mp_thread_t);
mp_thread_mutex_lock(&thread_mutex, 1);
@@ -153,7 +153,7 @@ void mp_thread_create(void *(*entry)(void *), void *arg, size_t *stack_size) {
void mp_thread_finish(void) {
mp_thread_mutex_lock(&thread_mutex, 1);
// TODO unlink from list
for (thread_t *th = thread; th != NULL; th = th->next) {
for (mp_thread_t *th = thread; th != NULL; th = th->next) {
if (th->id == xTaskGetCurrentTaskHandle()) {
th->ready = 0;
break;