Skip to content

Commit

Permalink
pthread_cleanup: move clenup down to tls
Browse files Browse the repository at this point in the history
Signed-off-by: ligd <liguiding1@xiaomi.com>
  • Loading branch information
GUIDINGLI authored and xiaoxiang781216 committed Sep 14, 2024
1 parent 0c734ca commit ef95bd8
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion testing/ltp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion testing/ostest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion testing/ostest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 7 additions & 7 deletions testing/ostest/cancel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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)));
}
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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)));
Expand Down
2 changes: 1 addition & 1 deletion testing/ostest/ostest_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions testing/ostest/pthread_rwlock_cancel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ef95bd8

Please sign in to comment.