pthread_cleanup: move clenup down to tls

Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd 2024-09-03 16:15:04 +08:00 committed by Xiang Xiao
parent 0c734ca62b
commit ef95bd8d29
6 changed files with 13 additions and 13 deletions

View File

@ -156,7 +156,7 @@ BLACKWORDS += pthread_key_delete
BLACKWORDS += pthread_setspecific BLACKWORDS += pthread_setspecific
BLACKWORDS += pthread_getspecific BLACKWORDS += pthread_getspecific
endif endif
ifeq ($(CONFIG_PTHREAD_CLEANUP_STACKSIZE),0) ifeq ($(CONFIG_TLS_NCLEANUP),0)
BLACKWORDS += pthread_cleanup_push BLACKWORDS += pthread_cleanup_push
BLACKWORDS += pthread_cleanup_pop BLACKWORDS += pthread_cleanup_pop
endif endif

View File

@ -83,7 +83,7 @@ if(CONFIG_TESTING_OSTEST)
list(APPEND SRCS specific.c) list(APPEND SRCS specific.c)
endif() endif()
if(NOT CONFIG_PTHREAD_CLEANUP_STACKSIZE EQUAL 0) if(NOT CONFIG_TLS_NCLEANUP EQUAL 0)
list(APPEND SRCS pthread_cleanup.c) list(APPEND SRCS pthread_cleanup.c)
endif() endif()

View File

@ -78,7 +78,7 @@ ifneq ($(CONFIG_TLS_NELEM),0)
CSRCS += specific.c CSRCS += specific.c
endif endif
ifneq ($(CONFIG_PTHREAD_CLEANUP_STACKSIZE),0) ifneq ($(CONFIG_TLS_NCLEANUP),0)
CSRCS += pthread_cleanup.c CSRCS += pthread_cleanup.c
endif endif

View File

@ -49,7 +49,7 @@ static sem_t sem_thread_started;
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
#if CONFIG_PTHREAD_CLEANUP_STACKSIZE > 0 #if CONFIG_TLS_NCLEANUP > 0
static void sem_cleaner(FAR void *arg) static void sem_cleaner(FAR void *arg)
{ {
printf("sem_cleaner #%u\n", (unsigned int)((uintptr_t)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; int status;
#if CONFIG_PTHREAD_CLEANUP_STACKSIZE > 0 #if CONFIG_TLS_NCLEANUP > 0
int i; int i;
/* Register some clean-up handlers */ /* 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))); 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 !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) static void mqueue_cleaner(FAR void *arg)
{ {
FAR mqd_t *mqcancel = (FAR mqd_t *)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]; char msgbuffer[CONFIG_MQ_MAXMSGSIZE];
size_t nbytes; size_t nbytes;
#if CONFIG_PTHREAD_CLEANUP_STACKSIZE > 0 #if CONFIG_TLS_NCLEANUP > 0
/* Register clean-up handler */ /* Register clean-up handler */
pthread_cleanup_push(mqueue_cleaner, (FAR void *)&mqcancel); pthread_cleanup_push(mqueue_cleaner, (FAR void *)&mqcancel);
@ -249,12 +249,12 @@ static FAR void *asynch_waiter(FAR void *parameter)
{ {
int status; int status;
#if CONFIG_PTHREAD_CLEANUP_STACKSIZE > 0 #if CONFIG_TLS_NCLEANUP > 0
int i; int i;
/* Register some clean-up handlers */ /* 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, pthread_cleanup_push(sem_cleaner,
(FAR void *)((uintptr_t)(i + 1))); (FAR void *)((uintptr_t)(i + 1)));

View File

@ -470,7 +470,7 @@ static int user_main(int argc, char *argv[])
pthread_rwlock_cancel_test(); pthread_rwlock_cancel_test();
check_test_memory_usage(); check_test_memory_usage();
#if CONFIG_PTHREAD_CLEANUP_STACKSIZE > 0 #if CONFIG_TLS_NCLEANUP > 0
/* Verify pthread cancellation cleanup handlers */ /* Verify pthread cancellation cleanup handlers */
printf("\nuser_main: pthread_cleanup test\n"); printf("\nuser_main: pthread_cleanup test\n");

View File

@ -204,7 +204,7 @@ static void test_timeout(void)
* usable state after deferred cancellation. * 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); status = pthread_rwlock_trywrlock(&write_lock);
if (status != EBUSY) if (status != EBUSY)
{ {
@ -254,7 +254,7 @@ static void test_timeout(void)
"ERROR pthread_rwlock_wrlock, status=%d\n", status); "ERROR pthread_rwlock_wrlock, status=%d\n", status);
ASSERT(false); 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(&write_lock);
pthread_rwlock_destroy(&read_lock); pthread_rwlock_destroy(&read_lock);