From c2eb095c09b266507b70290a9710e21d12b5137a Mon Sep 17 00:00:00 2001 From: xiehan <52160700+Barenboim@users.noreply.github.com> Date: Tue, 21 May 2024 01:51:23 +0800 Subject: [PATCH] Use 'pthread_equal()' to compare thread id. --- src/kernel/thrdpool.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/kernel/thrdpool.c b/src/kernel/thrdpool.c index f0ecd7d8..ce41dd08 100644 --- a/src/kernel/thrdpool.c +++ b/src/kernel/thrdpool.c @@ -19,7 +19,6 @@ #include #include #include -#include #include "msgqueue.h" #include "thrdpool.h" @@ -78,7 +77,7 @@ static void *__thrdpool_routine(void *arg) pthread_cond_signal(pool->terminate); pthread_mutex_unlock(&pool->mutex); - if (memcmp(&tid, &__zero_tid, sizeof (pthread_t)) != 0) + if (!pthread_equal(tid, __zero_tid)) pthread_join(tid, NULL); return NULL; @@ -103,7 +102,7 @@ static void __thrdpool_terminate(int in_pool, thrdpool_t *pool) pthread_cond_wait(&term, &pool->mutex); pthread_mutex_unlock(&pool->mutex); - if (memcmp(&pool->tid, &__zero_tid, sizeof (pthread_t)) != 0) + if (!pthread_equal(pool->tid, __zero_tid)) pthread_join(pool->tid, NULL); } @@ -159,7 +158,7 @@ thrdpool_t *thrdpool_create(size_t nthreads, size_t stacksize) { pool->stacksize = stacksize; pool->nthreads = 0; - memset(&pool->tid, 0, sizeof (pthread_t)); + pool->tid = __zero_tid; pool->terminate = NULL; if (__thrdpool_create_threads(nthreads, pool) >= 0) return pool;