From ef95bd8d29786671e3a0b50d1fdeadb341937a40 Mon Sep 17 00:00:00 2001 From: ligd Date: Tue, 3 Sep 2024 16:15:04 +0800 Subject: [PATCH] pthread_cleanup: move clenup down to tls Signed-off-by: ligd --- testing/ltp/Makefile | 2 +- testing/ostest/CMakeLists.txt | 2 +- testing/ostest/Makefile | 2 +- testing/ostest/cancel.c | 14 +++++++------- testing/ostest/ostest_main.c | 2 +- testing/ostest/pthread_rwlock_cancel.c | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/testing/ltp/Makefile b/testing/ltp/Makefile index aeb415f48..8d77bda1e 100644 --- a/testing/ltp/Makefile +++ b/testing/ltp/Makefile @@ -156,7 +156,7 @@ BLACKWORDS += pthread_key_delete BLACKWORDS += pthread_setspecific BLACKWORDS += pthread_getspecific endif -ifeq ($(CONFIG_PTHREAD_CLEANUP_STACKSIZE),0) +ifeq ($(CONFIG_TLS_NCLEANUP),0) BLACKWORDS += pthread_cleanup_push BLACKWORDS += pthread_cleanup_pop endif diff --git a/testing/ostest/CMakeLists.txt b/testing/ostest/CMakeLists.txt index fea5cd7ae..6ddbf480e 100644 --- a/testing/ostest/CMakeLists.txt +++ b/testing/ostest/CMakeLists.txt @@ -83,7 +83,7 @@ if(CONFIG_TESTING_OSTEST) list(APPEND SRCS specific.c) endif() - if(NOT CONFIG_PTHREAD_CLEANUP_STACKSIZE EQUAL 0) + if(NOT CONFIG_TLS_NCLEANUP EQUAL 0) list(APPEND SRCS pthread_cleanup.c) endif() diff --git a/testing/ostest/Makefile b/testing/ostest/Makefile index e7d26234e..fdbdc42c0 100644 --- a/testing/ostest/Makefile +++ b/testing/ostest/Makefile @@ -78,7 +78,7 @@ ifneq ($(CONFIG_TLS_NELEM),0) CSRCS += specific.c endif -ifneq ($(CONFIG_PTHREAD_CLEANUP_STACKSIZE),0) +ifneq ($(CONFIG_TLS_NCLEANUP),0) CSRCS += pthread_cleanup.c endif diff --git a/testing/ostest/cancel.c b/testing/ostest/cancel.c index c0c41b076..752ed747a 100644 --- a/testing/ostest/cancel.c +++ b/testing/ostest/cancel.c @@ -49,7 +49,7 @@ static sem_t sem_thread_started; * Private Functions ****************************************************************************/ -#if CONFIG_PTHREAD_CLEANUP_STACKSIZE > 0 +#if CONFIG_TLS_NCLEANUP > 0 static void sem_cleaner(FAR void *arg) { printf("sem_cleaner #%u\n", (unsigned int)((uintptr_t)arg)); @@ -60,12 +60,12 @@ static FAR void *sem_waiter(FAR void *parameter) { int status; -#if CONFIG_PTHREAD_CLEANUP_STACKSIZE > 0 +#if CONFIG_TLS_NCLEANUP > 0 int i; /* Register some clean-up handlers */ - for (i = 0; i < CONFIG_PTHREAD_CLEANUP_STACKSIZE ; i++) + for (i = 0; i < CONFIG_TLS_NCLEANUP ; i++) { pthread_cleanup_push(sem_cleaner, (FAR void *)((uintptr_t)(i + 1))); } @@ -161,7 +161,7 @@ static FAR void *sem_waiter(FAR void *parameter) } #if !defined(CONFIG_DISABLE_MQUEUE) && defined(CONFIG_CANCELLATION_POINTS) -#if CONFIG_PTHREAD_CLEANUP_STACKSIZE > 0 +#if CONFIG_TLS_NCLEANUP > 0 static void mqueue_cleaner(FAR void *arg) { FAR mqd_t *mqcancel = (FAR mqd_t *)arg; @@ -182,7 +182,7 @@ static FAR void *mqueue_waiter(FAR void *parameter) char msgbuffer[CONFIG_MQ_MAXMSGSIZE]; size_t nbytes; -#if CONFIG_PTHREAD_CLEANUP_STACKSIZE > 0 +#if CONFIG_TLS_NCLEANUP > 0 /* Register clean-up handler */ pthread_cleanup_push(mqueue_cleaner, (FAR void *)&mqcancel); @@ -249,12 +249,12 @@ static FAR void *asynch_waiter(FAR void *parameter) { int status; -#if CONFIG_PTHREAD_CLEANUP_STACKSIZE > 0 +#if CONFIG_TLS_NCLEANUP > 0 int i; /* Register some clean-up handlers */ - for (i = 0; i < CONFIG_PTHREAD_CLEANUP_STACKSIZE ; i++) + for (i = 0; i < CONFIG_TLS_NCLEANUP ; i++) { pthread_cleanup_push(sem_cleaner, (FAR void *)((uintptr_t)(i + 1))); diff --git a/testing/ostest/ostest_main.c b/testing/ostest/ostest_main.c index 88a7de927..afe1f4a24 100644 --- a/testing/ostest/ostest_main.c +++ b/testing/ostest/ostest_main.c @@ -470,7 +470,7 @@ static int user_main(int argc, char *argv[]) pthread_rwlock_cancel_test(); check_test_memory_usage(); -#if CONFIG_PTHREAD_CLEANUP_STACKSIZE > 0 +#if CONFIG_TLS_NCLEANUP > 0 /* Verify pthread cancellation cleanup handlers */ printf("\nuser_main: pthread_cleanup test\n"); diff --git a/testing/ostest/pthread_rwlock_cancel.c b/testing/ostest/pthread_rwlock_cancel.c index 4bb0eae4f..e0c826a9c 100644 --- a/testing/ostest/pthread_rwlock_cancel.c +++ b/testing/ostest/pthread_rwlock_cancel.c @@ -204,7 +204,7 @@ static void test_timeout(void) * usable state after deferred cancellation. */ -#if CONFIG_PTHREAD_CLEANUP_STACKSIZE > 0 && defined(CONFIG_CANCELLATION_POINTS) +#if CONFIG_TLS_NCLEANUP > 0 && defined(CONFIG_CANCELLATION_POINTS) status = pthread_rwlock_trywrlock(&write_lock); if (status != EBUSY) { @@ -254,7 +254,7 @@ static void test_timeout(void) "ERROR pthread_rwlock_wrlock, status=%d\n", status); ASSERT(false); } -#endif /* CONFIG_PTHREAD_CLEANUP_STACKSIZE > 0 && CONFIG_CANCELLATION_POINTS */ +#endif /* CONFIG_TLS_NCLEANUP > 0 && CONFIG_CANCELLATION_POINTS */ pthread_rwlock_destroy(&write_lock); pthread_rwlock_destroy(&read_lock);