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:
committed by
Damien George
parent
75efb3267c
commit
be5657b64f
@@ -42,19 +42,19 @@
|
||||
#define MP_THREAD_PRIORITY (ESP_TASK_PRIO_MIN + 1)
|
||||
|
||||
// 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 = NULL; // root pointer, handled by mp_thread_gc_others
|
||||
STATIC mp_thread_t thread_entry0;
|
||||
STATIC mp_thread_t *thread = NULL; // root pointer, handled by mp_thread_gc_others
|
||||
|
||||
void mp_thread_init(void *stack, uint32_t stack_len) {
|
||||
mp_thread_set_state(&mp_state_ctx.thread);
|
||||
@@ -76,7 +76,7 @@ void mp_thread_init(void *stack, uint32_t stack_len) {
|
||||
|
||||
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()) {
|
||||
@@ -100,7 +100,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;
|
||||
@@ -131,7 +131,7 @@ void mp_thread_create_ex(void *(*entry)(void *), void *arg, size_t *stack_size,
|
||||
}
|
||||
|
||||
// Allocate linked-list node (must be outside thread_mutex lock)
|
||||
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);
|
||||
|
||||
@@ -162,7 +162,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);
|
||||
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;
|
||||
@@ -178,9 +178,9 @@ void vPortCleanUpTCB(void *tcb) {
|
||||
// threading not yet initialised
|
||||
return;
|
||||
}
|
||||
thread_t *prev = NULL;
|
||||
mp_thread_t *prev = NULL;
|
||||
mp_thread_mutex_lock(&thread_mutex, 1);
|
||||
for (thread_t *th = thread; th != NULL; prev = th, th = th->next) {
|
||||
for (mp_thread_t *th = thread; th != NULL; prev = th, th = th->next) {
|
||||
// unlink the node from the list
|
||||
if ((void *)th->id == tcb) {
|
||||
if (prev != NULL) {
|
||||
@@ -216,7 +216,7 @@ void mp_thread_deinit(void) {
|
||||
// Find a task to delete
|
||||
TaskHandle_t id = NULL;
|
||||
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) {
|
||||
// Don't delete the current task
|
||||
if (th->id != xTaskGetCurrentTaskHandle()) {
|
||||
id = th->id;
|
||||
|
||||
Reference in New Issue
Block a user