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_getspecific
endif
ifeq ($(CONFIG_PTHREAD_CLEANUP_STACKSIZE),0)
ifeq ($(CONFIG_TLS_NCLEANUP),0)
BLACKWORDS += pthread_cleanup_push
BLACKWORDS += pthread_cleanup_pop
endif

View File

@ -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()

View File

@ -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

View File

@ -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)));

View File

@ -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");

View File

@ -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);