diff options
Diffstat (limited to 'sysdeps/pthread')
266 files changed, 1045 insertions, 268 deletions
diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile index 04ea565..de146dd 100644 --- a/sysdeps/pthread/Makefile +++ b/sysdeps/pthread/Makefile @@ -1,5 +1,5 @@ # sysdeps makefile fragment for all pthread-supporting configurations. -# Copyright (C) 2014-2024 Free Software Foundation, Inc. +# Copyright (C) 2014-2025 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -106,6 +106,7 @@ tests += \ tst-cancel28 \ tst-cancel29 \ tst-cancel30 \ + tst-cancel32 \ tst-cleanup0 \ tst-cleanup1 \ tst-cleanup2 \ @@ -154,6 +155,7 @@ tests += \ tst-exit3 \ tst-flock1 \ tst-flock2 \ + tst-fopen-threaded \ tst-fork1 \ tst-fork2 \ tst-fork3 \ @@ -174,6 +176,7 @@ tests += \ tst-join13 \ tst-join14 \ tst-join15 \ + tst-join16 \ tst-key1 \ tst-key2 \ tst-key3 \ @@ -215,6 +218,7 @@ tests += \ tst-pt-vfork2 \ tst-pthread-exit-signal \ tst-pthread-mutexattr \ + tst-pthread-mutexattr-2 \ tst-pthread-raise-blocked-self \ tst-pthread-setuid-loop \ tst-pthread_cancel-exited \ @@ -254,6 +258,8 @@ tests += \ tst-sem14 \ tst-sem15 \ tst-sem16 \ + tst-sem18 \ + tst-sem19 \ tst-setuid3 \ tst-signal1 \ tst-signal2 \ @@ -265,7 +271,9 @@ tests += \ tst-spin2 \ tst-spin3 \ tst-spin4 \ + tst-spin5 \ tst-stack1 \ + tst-stack2 \ tst-stdio1 \ tst-stdio2 \ tst-thrd-detach \ @@ -291,13 +299,14 @@ tests-time64 += \ tst-cnd-timedwait-time64 \ tst-cond11-time64 \ tst-join14-time64 \ + tst-join16-time64 \ tst-mtx-timedlock-time64 \ tst-rwlock14-time64 \ tst-sem5-time64 \ tst-thrd-sleep-time64 \ # tests-time64 -static-only-routines = pthread_atfork +static-only-routines += pthread_atfork # Files which must not be linked with libpthread. tests-nolibpthread += \ @@ -360,6 +369,7 @@ modules-names += \ tst-atfork4mod \ tst-create1mod \ tst-fini1mod \ + tst-stack2-mod \ tst-tls4moda \ tst-tls4modb \ # modules-names @@ -533,4 +543,12 @@ LDFLAGS-tst-create1 = -Wl,-export-dynamic $(objpfx)tst-create1: $(shared-thread-library) $(objpfx)tst-create1.out: $(objpfx)tst-create1mod.so +$(objpfx)tst-stack2.out: $(objpfx)tst-stack2-mod.so +$(objpfx)tst-stack2-mod.so: $(shared-thread-library) +LDFLAGS-tst-stack2-mod.so = -Wl,-z,execstack +ifeq ($(have-no-error-execstack),yes) +LDFLAGS-tst-stack2-mod.so += -Wl,--no-error-execstack +endif +tst-stack2-ENV = GLIBC_TUNABLES=glibc.rtld.execstack=2 + endif diff --git a/sysdeps/pthread/allocalim.h b/sysdeps/pthread/allocalim.h index 38fcdda..c5f1a7a 100644 --- a/sysdeps/pthread/allocalim.h +++ b/sysdeps/pthread/allocalim.h @@ -1,5 +1,5 @@ /* Determine whether block of given size can be allocated on the stack or not. - Copyright (C) 2002-2024 Free Software Foundation, Inc. + Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/bits/sigthread.h b/sysdeps/pthread/bits/sigthread.h index 700b31d..66cba33 100644 --- a/sysdeps/pthread/bits/sigthread.h +++ b/sysdeps/pthread/bits/sigthread.h @@ -1,5 +1,5 @@ /* Signal handling function for threaded programs. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/call_once.c b/sysdeps/pthread/call_once.c index f4f5700..9c0eb39 100644 --- a/sysdeps/pthread/call_once.c +++ b/sysdeps/pthread/call_once.c @@ -1,5 +1,5 @@ /* C11 threads call once implementation. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/cnd_broadcast.c b/sysdeps/pthread/cnd_broadcast.c index 299fefd..4bef01a 100644 --- a/sysdeps/pthread/cnd_broadcast.c +++ b/sysdeps/pthread/cnd_broadcast.c @@ -1,5 +1,5 @@ /* C11 thread conditional broadcast implementation. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/cnd_destroy.c b/sysdeps/pthread/cnd_destroy.c index bdb7ddc..ed5e433 100644 --- a/sysdeps/pthread/cnd_destroy.c +++ b/sysdeps/pthread/cnd_destroy.c @@ -1,5 +1,5 @@ /* C11 threads conditional destroy implementation. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/cnd_init.c b/sysdeps/pthread/cnd_init.c index 33da3d8..fce84de 100644 --- a/sysdeps/pthread/cnd_init.c +++ b/sysdeps/pthread/cnd_init.c @@ -1,5 +1,5 @@ /* C11 thread conditional initialization implementation. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/cnd_signal.c b/sysdeps/pthread/cnd_signal.c index acf58cf..2737ae1 100644 --- a/sysdeps/pthread/cnd_signal.c +++ b/sysdeps/pthread/cnd_signal.c @@ -1,5 +1,5 @@ /* C11 threads conditional signal implementation. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/cnd_timedwait.c b/sysdeps/pthread/cnd_timedwait.c index 48948ea..f0529d8 100644 --- a/sysdeps/pthread/cnd_timedwait.c +++ b/sysdeps/pthread/cnd_timedwait.c @@ -1,5 +1,5 @@ /* C11 threads conditional timed wait implementation. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/cnd_wait.c b/sysdeps/pthread/cnd_wait.c index 85f6f28..706466e 100644 --- a/sysdeps/pthread/cnd_wait.c +++ b/sysdeps/pthread/cnd_wait.c @@ -1,5 +1,5 @@ /* C11 threads conditional wait implementation. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/eintr.c b/sysdeps/pthread/eintr.c index 3fe0f28..b06cc1c 100644 --- a/sysdeps/pthread/eintr.c +++ b/sysdeps/pthread/eintr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/elision-conf.h b/sysdeps/pthread/elision-conf.h index 6233f78..a6b4b9a 100644 --- a/sysdeps/pthread/elision-conf.h +++ b/sysdeps/pthread/elision-conf.h @@ -1,5 +1,5 @@ /* elision-conf.h: Lock elision configuration. Stub version. - Copyright (C) 2021-2024 Free Software Foundation, Inc. + Copyright (C) 2021-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/mtx_destroy.c b/sysdeps/pthread/mtx_destroy.c index b2f43df..f468666 100644 --- a/sysdeps/pthread/mtx_destroy.c +++ b/sysdeps/pthread/mtx_destroy.c @@ -1,5 +1,5 @@ /* C11 threads mutex destroy implementation. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/mtx_init.c b/sysdeps/pthread/mtx_init.c index 729b179..a807eca 100644 --- a/sysdeps/pthread/mtx_init.c +++ b/sysdeps/pthread/mtx_init.c @@ -1,5 +1,5 @@ /* C11 threads mutex initialization implementation. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/mtx_lock.c b/sysdeps/pthread/mtx_lock.c index bce7959..7318d42 100644 --- a/sysdeps/pthread/mtx_lock.c +++ b/sysdeps/pthread/mtx_lock.c @@ -1,5 +1,5 @@ /* C11 threads mutex lock implementation. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/mtx_timedlock.c b/sysdeps/pthread/mtx_timedlock.c index c4cd62b..8e7e0af 100644 --- a/sysdeps/pthread/mtx_timedlock.c +++ b/sysdeps/pthread/mtx_timedlock.c @@ -1,5 +1,5 @@ /* C11 threads mutex timed lock implementation. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/mtx_trylock.c b/sysdeps/pthread/mtx_trylock.c index a7c6554..57b3e6d 100644 --- a/sysdeps/pthread/mtx_trylock.c +++ b/sysdeps/pthread/mtx_trylock.c @@ -1,5 +1,5 @@ /* C11 threads mutex try lock implementation. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/mtx_unlock.c b/sysdeps/pthread/mtx_unlock.c index 331c304..978a9ee 100644 --- a/sysdeps/pthread/mtx_unlock.c +++ b/sysdeps/pthread/mtx_unlock.c @@ -1,5 +1,5 @@ /* C11 threads mutex unlock implementation. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/posix-timer.h b/sysdeps/pthread/posix-timer.h index d53e094..d621701 100644 --- a/sysdeps/pthread/posix-timer.h +++ b/sysdeps/pthread/posix-timer.h @@ -1,5 +1,5 @@ /* Definitions for POSIX timer implementation on top of NPTL. - Copyright (C) 2000-2024 Free Software Foundation, Inc. + Copyright (C) 2000-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/pthread_atfork.c b/sysdeps/pthread/pthread_atfork.c index 5d937d4..171ab34 100644 --- a/sysdeps/pthread/pthread_atfork.c +++ b/sysdeps/pthread/pthread_atfork.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/pthread_atfork_compat.c b/sysdeps/pthread/pthread_atfork_compat.c index ac06174..c4b5ea0 100644 --- a/sysdeps/pthread/pthread_atfork_compat.c +++ b/sysdeps/pthread/pthread_atfork_compat.c @@ -1,5 +1,5 @@ /* Compat pthread_atfork implementation. - Copyright (C) 2002-2024 Free Software Foundation, Inc. + Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/pthread_early_init.h b/sysdeps/pthread/pthread_early_init.h index 2f214db..3f1de38 100644 --- a/sysdeps/pthread/pthread_early_init.h +++ b/sysdeps/pthread/pthread_early_init.h @@ -1,5 +1,5 @@ /* pthread initialization called from __libc_early_init. Generic version. - Copyright (C) 2021-2024 Free Software Foundation, Inc. + Copyright (C) 2021-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/pthread_mutex_conf.h b/sysdeps/pthread/pthread_mutex_conf.h index 89f3806..070df25 100644 --- a/sysdeps/pthread/pthread_mutex_conf.h +++ b/sysdeps/pthread/pthread_mutex_conf.h @@ -1,5 +1,5 @@ /* Pthread mutex tunable parameters. Generic version. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/sem_close.c b/sysdeps/pthread/sem_close.c index 3652531..e989ed8 100644 --- a/sysdeps/pthread/sem_close.c +++ b/sysdeps/pthread/sem_close.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/sem_open.c b/sysdeps/pthread/sem_open.c index e412361..e5eacb5 100644 --- a/sysdeps/pthread/sem_open.c +++ b/sysdeps/pthread/sem_open.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -26,6 +26,7 @@ #include <futex-internal.h> #include <libc-lock.h> + #if !PTHREAD_IN_LIBC /* The private names are not exported from libc. */ # define __link link @@ -57,11 +58,7 @@ __sem_open (const char *name, int oflag, ...) } /* Disable asynchronous cancellation. */ -#ifdef __libc_ptf_call - int state; - __libc_ptf_call (__pthread_setcancelstate, - (PTHREAD_CANCEL_DISABLE, &state), 0); -#endif + int state = __pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &state); /* If the semaphore object has to exist simply open it. */ if ((oflag & O_CREAT) == 0 || (oflag & O_EXCL) == 0) @@ -76,6 +73,7 @@ __sem_open (const char *name, int oflag, ...) goto try_create; /* Return. errno is already set. */ + result = SEM_FAILED; } else /* Check whether we already have this semaphore mapped and @@ -213,9 +211,7 @@ __sem_open (const char *name, int oflag, ...) } out: -#ifdef __libc_ptf_call - __libc_ptf_call (__pthread_setcancelstate, (state, NULL), 0); -#endif + __pthread_setcancelstate (state, NULL); return result; } diff --git a/sysdeps/pthread/sem_routines.c b/sysdeps/pthread/sem_routines.c index a309249..6208935 100644 --- a/sysdeps/pthread/sem_routines.c +++ b/sysdeps/pthread/sem_routines.c @@ -1,5 +1,5 @@ /* Helper code for POSIX semaphore implementation. - Copyright (C) 2021-2024 Free Software Foundation, Inc. + Copyright (C) 2021-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/sem_routines.h b/sysdeps/pthread/sem_routines.h index 4715650..9d0a837 100644 --- a/sysdeps/pthread/sem_routines.h +++ b/sysdeps/pthread/sem_routines.h @@ -1,5 +1,5 @@ /* Helper code for POSIX semaphore implementation. - Copyright (C) 2021-2024 Free Software Foundation, Inc. + Copyright (C) 2021-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/sem_unlink.c b/sysdeps/pthread/sem_unlink.c index 67e95b4..428a93a 100644 --- a/sysdeps/pthread/sem_unlink.c +++ b/sysdeps/pthread/sem_unlink.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/semaphore.h b/sysdeps/pthread/semaphore.h index 8a09633..41e3a37 100644 --- a/sysdeps/pthread/semaphore.h +++ b/sysdeps/pthread/semaphore.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/thrd_create.c b/sysdeps/pthread/thrd_create.c index 1b01ace..788eb62 100644 --- a/sysdeps/pthread/thrd_create.c +++ b/sysdeps/pthread/thrd_create.c @@ -1,5 +1,5 @@ /* C11 threads thread creation implementation. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/thrd_detach.c b/sysdeps/pthread/thrd_detach.c index ac0c52d..d1a0598 100644 --- a/sysdeps/pthread/thrd_detach.c +++ b/sysdeps/pthread/thrd_detach.c @@ -1,5 +1,5 @@ /* C11 threads thread detach implementation. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/thrd_equal.c b/sysdeps/pthread/thrd_equal.c index 5a23e6a..4f0c548 100644 --- a/sysdeps/pthread/thrd_equal.c +++ b/sysdeps/pthread/thrd_equal.c @@ -1,5 +1,5 @@ /* C11 threads thread equality check implementation. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/thrd_exit.c b/sysdeps/pthread/thrd_exit.c index b80580e..9207ac2 100644 --- a/sysdeps/pthread/thrd_exit.c +++ b/sysdeps/pthread/thrd_exit.c @@ -1,5 +1,5 @@ /* C11 threads thread exit implementation. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/thrd_join.c b/sysdeps/pthread/thrd_join.c index 0cdc4e6..ca9cf3b 100644 --- a/sysdeps/pthread/thrd_join.c +++ b/sysdeps/pthread/thrd_join.c @@ -1,5 +1,5 @@ /* C11 threads thread join implementation. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/thrd_priv.h b/sysdeps/pthread/thrd_priv.h index 875f9ea..5d2d260 100644 --- a/sysdeps/pthread/thrd_priv.h +++ b/sysdeps/pthread/thrd_priv.h @@ -1,5 +1,5 @@ /* Internal C11 threads definitions. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/thrd_sleep.c b/sysdeps/pthread/thrd_sleep.c index 023a834..1ea12d2 100644 --- a/sysdeps/pthread/thrd_sleep.c +++ b/sysdeps/pthread/thrd_sleep.c @@ -1,5 +1,5 @@ /* C11 threads thread sleep implementation. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/threads.h b/sysdeps/pthread/threads.h index 7cade24..44c9bc7 100644 --- a/sysdeps/pthread/threads.h +++ b/sysdeps/pthread/threads.h @@ -1,5 +1,5 @@ /* ISO C11 Standard: 7.26 - Thread support library <threads.h>. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tss_create.c b/sysdeps/pthread/tss_create.c index d41bd5d..b99e80d 100644 --- a/sysdeps/pthread/tss_create.c +++ b/sysdeps/pthread/tss_create.c @@ -1,5 +1,5 @@ /* C11 threads thread-specific creation implementation. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tss_delete.c b/sysdeps/pthread/tss_delete.c index cc1feac..584f878 100644 --- a/sysdeps/pthread/tss_delete.c +++ b/sysdeps/pthread/tss_delete.c @@ -1,5 +1,5 @@ /* C11 threads thread-specific delete implementation. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tss_get.c b/sysdeps/pthread/tss_get.c index 97d72ad..bb31cb1 100644 --- a/sysdeps/pthread/tss_get.c +++ b/sysdeps/pthread/tss_get.c @@ -1,5 +1,5 @@ /* C11 threads thread-specific get implementation. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tss_set.c b/sysdeps/pthread/tss_set.c index 5b525f0..a751c37 100644 --- a/sysdeps/pthread/tss_set.c +++ b/sysdeps/pthread/tss_set.c @@ -1,5 +1,5 @@ /* C11 threads thread-specific set implementation. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-_res1.c b/sysdeps/pthread/tst-_res1.c index 5fbb5e4..372c846 100644 --- a/sysdeps/pthread/tst-_res1.c +++ b/sysdeps/pthread/tst-_res1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-_res1mod1.c b/sysdeps/pthread/tst-_res1mod1.c index cfeb8f3..56f0239 100644 --- a/sysdeps/pthread/tst-_res1mod1.c +++ b/sysdeps/pthread/tst-_res1mod1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-abstime.c b/sysdeps/pthread/tst-abstime.c index faeb04b..b111846 100644 --- a/sysdeps/pthread/tst-abstime.c +++ b/sysdeps/pthread/tst-abstime.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2024 Free Software Foundation, Inc. +/* Copyright (C) 2010-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-atfork1.c b/sysdeps/pthread/tst-atfork1.c index 1c35366..84999b5 100644 --- a/sysdeps/pthread/tst-atfork1.c +++ b/sysdeps/pthread/tst-atfork1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-atfork2.c b/sysdeps/pthread/tst-atfork2.c index 6255150..9f97baf 100644 --- a/sysdeps/pthread/tst-atfork2.c +++ b/sysdeps/pthread/tst-atfork2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-atfork2mod.c b/sysdeps/pthread/tst-atfork2mod.c index 72af4ea..2c3e0a7 100644 --- a/sysdeps/pthread/tst-atfork2mod.c +++ b/sysdeps/pthread/tst-atfork2mod.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-atfork3.c b/sysdeps/pthread/tst-atfork3.c index ad2477a..f6556ed 100644 --- a/sysdeps/pthread/tst-atfork3.c +++ b/sysdeps/pthread/tst-atfork3.c @@ -1,5 +1,5 @@ /* Check if pthread_atfork handler can call dlclose (BZ#24595). - Copyright (C) 2022-2024 Free Software Foundation, Inc. + Copyright (C) 2022-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-atfork3mod.c b/sysdeps/pthread/tst-atfork3mod.c index 932f113..9b48f64 100644 --- a/sysdeps/pthread/tst-atfork3mod.c +++ b/sysdeps/pthread/tst-atfork3mod.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2022-2024 Free Software Foundation, Inc. +/* Copyright (C) 2022-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-atfork4.c b/sysdeps/pthread/tst-atfork4.c index ea2f98f..9153314 100644 --- a/sysdeps/pthread/tst-atfork4.c +++ b/sysdeps/pthread/tst-atfork4.c @@ -1,5 +1,5 @@ /* pthread_atfork supports handlers that call pthread_atfork or dlclose. - Copyright (C) 2022-2024 Free Software Foundation, Inc. + Copyright (C) 2022-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-atfork4mod.c b/sysdeps/pthread/tst-atfork4mod.c index b51621e..650d32a 100644 --- a/sysdeps/pthread/tst-atfork4mod.c +++ b/sysdeps/pthread/tst-atfork4mod.c @@ -1,5 +1,5 @@ /* pthread_atfork supports handlers that call pthread_atfork or dlclose. - Copyright (C) 2022-2024 Free Software Foundation, Inc. + Copyright (C) 2022-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-attr1.c b/sysdeps/pthread/tst-attr1.c index f1d8809..187ac19 100644 --- a/sysdeps/pthread/tst-attr1.c +++ b/sysdeps/pthread/tst-attr1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-backtrace1.c b/sysdeps/pthread/tst-backtrace1.c index 069eac4..01b8a0c 100644 --- a/sysdeps/pthread/tst-backtrace1.c +++ b/sysdeps/pthread/tst-backtrace1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2024 Free Software Foundation, Inc. +/* Copyright (C) 2004-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-bad-schedattr.c b/sysdeps/pthread/tst-bad-schedattr.c index 2576bb8..2458fc3 100644 --- a/sysdeps/pthread/tst-bad-schedattr.c +++ b/sysdeps/pthread/tst-bad-schedattr.c @@ -1,5 +1,5 @@ /* Test that pthread_create diagnoses invalid scheduling parameters. - Copyright (C) 2014-2024 Free Software Foundation, Inc. + Copyright (C) 2014-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-barrier1.c b/sysdeps/pthread/tst-barrier1.c index 705f01d..f93e565 100644 --- a/sysdeps/pthread/tst-barrier1.c +++ b/sysdeps/pthread/tst-barrier1.c @@ -1,5 +1,5 @@ /* Tests barrier initialization. - Copyright (C) 2002-2024 Free Software Foundation, Inc. + Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-barrier2.c b/sysdeps/pthread/tst-barrier2.c index 77d367b..02e3b50 100644 --- a/sysdeps/pthread/tst-barrier2.c +++ b/sysdeps/pthread/tst-barrier2.c @@ -1,5 +1,5 @@ /* Tests process-shared barriers. - Copyright (C) 2002-2024 Free Software Foundation, Inc. + Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-barrier3.c b/sysdeps/pthread/tst-barrier3.c index 544d96c..38d7183 100644 --- a/sysdeps/pthread/tst-barrier3.c +++ b/sysdeps/pthread/tst-barrier3.c @@ -1,5 +1,5 @@ /* Test of POSIX barriers. - Copyright (C) 2002-2024 Free Software Foundation, Inc. + Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-barrier4.c b/sysdeps/pthread/tst-barrier4.c index 73deb6c..e5ccd87 100644 --- a/sysdeps/pthread/tst-barrier4.c +++ b/sysdeps/pthread/tst-barrier4.c @@ -1,5 +1,5 @@ /* This tests destruction of a barrier right after waiting on it. - Copyright (C) 2004-2024 Free Software Foundation, Inc. + Copyright (C) 2004-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-basic1.c b/sysdeps/pthread/tst-basic1.c index bada378..23a0273 100644 --- a/sysdeps/pthread/tst-basic1.c +++ b/sysdeps/pthread/tst-basic1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-basic2.c b/sysdeps/pthread/tst-basic2.c index a273299..41e82a5 100644 --- a/sysdeps/pthread/tst-basic2.c +++ b/sysdeps/pthread/tst-basic2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-basic3.c b/sysdeps/pthread/tst-basic3.c index 860218c..b284996 100644 --- a/sysdeps/pthread/tst-basic3.c +++ b/sysdeps/pthread/tst-basic3.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-basic4.c b/sysdeps/pthread/tst-basic4.c index d8f791b..aa7f0fd 100644 --- a/sysdeps/pthread/tst-basic4.c +++ b/sysdeps/pthread/tst-basic4.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-basic5.c b/sysdeps/pthread/tst-basic5.c index 015ce5a..66ffd52 100644 --- a/sysdeps/pthread/tst-basic5.c +++ b/sysdeps/pthread/tst-basic5.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-basic6.c b/sysdeps/pthread/tst-basic6.c index 0e8406f..d462b93 100644 --- a/sysdeps/pthread/tst-basic6.c +++ b/sysdeps/pthread/tst-basic6.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-call-once.c b/sysdeps/pthread/tst-call-once.c index 2970a96..4f17af3 100644 --- a/sysdeps/pthread/tst-call-once.c +++ b/sysdeps/pthread/tst-call-once.c @@ -1,5 +1,5 @@ /* C11 threads call_once test. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel-self-cancelstate.c b/sysdeps/pthread/tst-cancel-self-cancelstate.c index 7890fbd..8e0fc80 100644 --- a/sysdeps/pthread/tst-cancel-self-cancelstate.c +++ b/sysdeps/pthread/tst-cancel-self-cancelstate.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2012-2024 Free Software Foundation, Inc. +/* Copyright (C) 2012-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel-self-canceltype.c b/sysdeps/pthread/tst-cancel-self-canceltype.c index dd2c448..ced892c 100644 --- a/sysdeps/pthread/tst-cancel-self-canceltype.c +++ b/sysdeps/pthread/tst-cancel-self-canceltype.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2012-2024 Free Software Foundation, Inc. +/* Copyright (C) 2012-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel-self-cleanup.c b/sysdeps/pthread/tst-cancel-self-cleanup.c index 2e23422..bd680bb 100644 --- a/sysdeps/pthread/tst-cancel-self-cleanup.c +++ b/sysdeps/pthread/tst-cancel-self-cleanup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2012-2024 Free Software Foundation, Inc. +/* Copyright (C) 2012-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel-self-testcancel.c b/sysdeps/pthread/tst-cancel-self-testcancel.c index 822ca23..253456a 100644 --- a/sysdeps/pthread/tst-cancel-self-testcancel.c +++ b/sysdeps/pthread/tst-cancel-self-testcancel.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2012-2024 Free Software Foundation, Inc. +/* Copyright (C) 2012-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel-self.c b/sysdeps/pthread/tst-cancel-self.c index f62e1c8..de11c66 100644 --- a/sysdeps/pthread/tst-cancel-self.c +++ b/sysdeps/pthread/tst-cancel-self.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2012-2024 Free Software Foundation, Inc. +/* Copyright (C) 2012-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel1.c b/sysdeps/pthread/tst-cancel1.c index 79ae095..f1d1550 100644 --- a/sysdeps/pthread/tst-cancel1.c +++ b/sysdeps/pthread/tst-cancel1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel10.c b/sysdeps/pthread/tst-cancel10.c index 313bde3..05edbe7 100644 --- a/sysdeps/pthread/tst-cancel10.c +++ b/sysdeps/pthread/tst-cancel10.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel11.c b/sysdeps/pthread/tst-cancel11.c index 2c5e9ae..5591b85 100644 --- a/sysdeps/pthread/tst-cancel11.c +++ b/sysdeps/pthread/tst-cancel11.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel12.c b/sysdeps/pthread/tst-cancel12.c index 3483acb..872c747 100644 --- a/sysdeps/pthread/tst-cancel12.c +++ b/sysdeps/pthread/tst-cancel12.c @@ -1,5 +1,5 @@ /* Test sem_wait cancellation for uncontended case. - Copyright (C) 2003-2024 Free Software Foundation, Inc. + Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel13.c b/sysdeps/pthread/tst-cancel13.c index fc298e0..7df7186 100644 --- a/sysdeps/pthread/tst-cancel13.c +++ b/sysdeps/pthread/tst-cancel13.c @@ -1,5 +1,5 @@ /* Test sem_wait cancellation for contended case. - Copyright (C) 2003-2024 Free Software Foundation, Inc. + Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel14.c b/sysdeps/pthread/tst-cancel14.c index 0254d62..e9d29bf 100644 --- a/sysdeps/pthread/tst-cancel14.c +++ b/sysdeps/pthread/tst-cancel14.c @@ -1,5 +1,5 @@ /* Test sem_timedwait cancellation for uncontended case. - Copyright (C) 2003-2024 Free Software Foundation, Inc. + Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel15.c b/sysdeps/pthread/tst-cancel15.c index d509fb1..de04b52 100644 --- a/sysdeps/pthread/tst-cancel15.c +++ b/sysdeps/pthread/tst-cancel15.c @@ -1,5 +1,5 @@ /* Test sem_timedwait cancellation for contended case. - Copyright (C) 2003-2024 Free Software Foundation, Inc. + Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel16.c b/sysdeps/pthread/tst-cancel16.c index 37732a4..4c02d69 100644 --- a/sysdeps/pthread/tst-cancel16.c +++ b/sysdeps/pthread/tst-cancel16.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel18.c b/sysdeps/pthread/tst-cancel18.c index 7975bf3..75331f5 100644 --- a/sysdeps/pthread/tst-cancel18.c +++ b/sysdeps/pthread/tst-cancel18.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel19.c b/sysdeps/pthread/tst-cancel19.c index 07265f3..8c81c28 100644 --- a/sysdeps/pthread/tst-cancel19.c +++ b/sysdeps/pthread/tst-cancel19.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel2.c b/sysdeps/pthread/tst-cancel2.c index ac38b50..f714e2d 100644 --- a/sysdeps/pthread/tst-cancel2.c +++ b/sysdeps/pthread/tst-cancel2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -32,6 +32,10 @@ tf (void *arg) char buf[100000]; while (write (fd[1], buf, sizeof (buf)) > 0); + /* The write can return -1/EPIPE if the pipe was closed before the + thread calls write, which signals a side-effect that must be + signaled to the thread. */ + pthread_testcancel (); return (void *) 42l; } diff --git a/sysdeps/pthread/tst-cancel20.c b/sysdeps/pthread/tst-cancel20.c index e612fc1..0089ad3 100644 --- a/sysdeps/pthread/tst-cancel20.c +++ b/sysdeps/pthread/tst-cancel20.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel21.c b/sysdeps/pthread/tst-cancel21.c index 75064fc..018d9f4 100644 --- a/sysdeps/pthread/tst-cancel21.c +++ b/sysdeps/pthread/tst-cancel21.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel22.c b/sysdeps/pthread/tst-cancel22.c index 3ec6678..d5e0850 100644 --- a/sysdeps/pthread/tst-cancel22.c +++ b/sysdeps/pthread/tst-cancel22.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel26.c b/sysdeps/pthread/tst-cancel26.c index c36321e..cff75ed 100644 --- a/sysdeps/pthread/tst-cancel26.c +++ b/sysdeps/pthread/tst-cancel26.c @@ -1,5 +1,5 @@ /* Check for failure paths handling for cancellation points. - Copyright (C) 2015-2024 Free Software Foundation, Inc. + Copyright (C) 2015-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel27.c b/sysdeps/pthread/tst-cancel27.c index 1566676..0814fd7 100644 --- a/sysdeps/pthread/tst-cancel27.c +++ b/sysdeps/pthread/tst-cancel27.c @@ -1,5 +1,5 @@ /* Check for failure paths handling for cancellation points. - Copyright (C) 2015-2024 Free Software Foundation, Inc. + Copyright (C) 2015-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel28.c b/sysdeps/pthread/tst-cancel28.c index 2280d57..b66965a 100644 --- a/sysdeps/pthread/tst-cancel28.c +++ b/sysdeps/pthread/tst-cancel28.c @@ -1,6 +1,6 @@ /* Check if the thread created by POSIX timer using SIGEV_THREAD is cancellable. - Copyright (C) 2020-2024 Free Software Foundation, Inc. + Copyright (C) 2020-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -52,7 +52,7 @@ thread_handler (union sigval sv) static int do_test (void) { - struct sigevent sev = { 0 }; + struct sigevent sev = { }; sev.sigev_notify = SIGEV_THREAD; sev.sigev_notify_function = &thread_handler; @@ -61,7 +61,7 @@ do_test (void) xpthread_barrier_init (&barrier, NULL, 2); - struct itimerspec trigger = { 0 }; + struct itimerspec trigger = { }; trigger.it_value.tv_nsec = 1000000; TEST_COMPARE (timer_settime (timerid, 0, &trigger, NULL), 0); diff --git a/sysdeps/pthread/tst-cancel29.c b/sysdeps/pthread/tst-cancel29.c index 47a34c0..aff4ea6 100644 --- a/sysdeps/pthread/tst-cancel29.c +++ b/sysdeps/pthread/tst-cancel29.c @@ -1,7 +1,7 @@ /* Check if a thread that disables cancellation and which call functions that might be interrupted by a signal do not see the internal SIGCANCEL. - Copyright (C) 2022-2024 Free Software Foundation, Inc. + Copyright (C) 2022-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel3.c b/sysdeps/pthread/tst-cancel3.c index 368be82..4a58286 100644 --- a/sysdeps/pthread/tst-cancel3.c +++ b/sysdeps/pthread/tst-cancel3.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel30.c b/sysdeps/pthread/tst-cancel30.c index 94ad628..2a854cb 100644 --- a/sysdeps/pthread/tst-cancel30.c +++ b/sysdeps/pthread/tst-cancel30.c @@ -1,7 +1,7 @@ /* Check if printf like functions does not disable asynchronous cancellation mode (BZ#29214). - Copyright (C) 2022-2024 Free Software Foundation, Inc. + Copyright (C) 2022-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel32.c b/sysdeps/pthread/tst-cancel32.c new file mode 100644 index 0000000..ab550c1 --- /dev/null +++ b/sysdeps/pthread/tst-cancel32.c @@ -0,0 +1,73 @@ +/* Check if pthread_setcanceltype disables asynchronous cancellation + once cancellation happens (BZ 32782) + + Copyright (C) 2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +/* The pthread_setcanceltype is a cancellation entrypoint, and if + asynchronous is enabled and the cancellation starts (on the second + pthread_setcanceltype call), the asynchronous should not restart + the process. */ + +#include <support/xthread.h> + +#define NITER 1000 +#define NTHREADS 8 + +static void +tf_cleanup (void *arg) +{ +} + +static void * +tf (void *closure) +{ + pthread_cleanup_push (tf_cleanup, NULL); + for (;;) + { + /* The only possible failure for pthread_setcanceltype is an + invalid state type. */ + pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL); + pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, NULL); + } + pthread_cleanup_pop (1); + + return NULL; +} + +static void +poll_threads (int nthreads) +{ + pthread_t thr[nthreads]; + for (int i = 0; i < nthreads; i++) + thr[i] = xpthread_create (NULL, tf, NULL); + for (int i = 0; i < nthreads; i++) + xpthread_cancel (thr[i]); + for (int i = 0; i < nthreads; i++) + xpthread_join (thr[i]); +} + +static int +do_test (void) +{ + for (int k = 0; k < NITER; k++) + poll_threads (NTHREADS); + + return 0; +} + +#include <support/test-driver.c> diff --git a/sysdeps/pthread/tst-cancel4-common.c b/sysdeps/pthread/tst-cancel4-common.c index ee8e5fa..920bc68 100644 --- a/sysdeps/pthread/tst-cancel4-common.c +++ b/sysdeps/pthread/tst-cancel4-common.c @@ -1,6 +1,6 @@ /* Common file for all tst-cancel4_* - Copyright (C) 2016-2024 Free Software Foundation, Inc. + Copyright (C) 2016-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel4-common.h b/sysdeps/pthread/tst-cancel4-common.h index 890cc35..27fe74b 100644 --- a/sysdeps/pthread/tst-cancel4-common.h +++ b/sysdeps/pthread/tst-cancel4-common.h @@ -1,6 +1,6 @@ /* Common definition for tst-cancel4_* tests. - Copyright (C) 2016-2024 Free Software Foundation, Inc. + Copyright (C) 2016-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel4.c b/sysdeps/pthread/tst-cancel4.c index f9c895d..7a95938 100644 --- a/sysdeps/pthread/tst-cancel4.c +++ b/sysdeps/pthread/tst-cancel4.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel6.c b/sysdeps/pthread/tst-cancel6.c index bdd41ff..a95cddd 100644 --- a/sysdeps/pthread/tst-cancel6.c +++ b/sysdeps/pthread/tst-cancel6.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel8.c b/sysdeps/pthread/tst-cancel8.c index 0d2f517..f82c1c9 100644 --- a/sysdeps/pthread/tst-cancel8.c +++ b/sysdeps/pthread/tst-cancel8.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cancel9.c b/sysdeps/pthread/tst-cancel9.c index 900da5e..2f40163 100644 --- a/sysdeps/pthread/tst-cancel9.c +++ b/sysdeps/pthread/tst-cancel9.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cleanup0.c b/sysdeps/pthread/tst-cleanup0.c index f018b49..42bd792 100644 --- a/sysdeps/pthread/tst-cleanup0.c +++ b/sysdeps/pthread/tst-cleanup0.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cleanup1.c b/sysdeps/pthread/tst-cleanup1.c index 9f8f12e..6c3584c 100644 --- a/sysdeps/pthread/tst-cleanup1.c +++ b/sysdeps/pthread/tst-cleanup1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cleanup2.c b/sysdeps/pthread/tst-cleanup2.c index fd305a8..d2c5dde 100644 --- a/sysdeps/pthread/tst-cleanup2.c +++ b/sysdeps/pthread/tst-cleanup2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cleanup3.c b/sysdeps/pthread/tst-cleanup3.c index 659ac2e..8e1b444 100644 --- a/sysdeps/pthread/tst-cleanup3.c +++ b/sysdeps/pthread/tst-cleanup3.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-clock1.c b/sysdeps/pthread/tst-clock1.c index edc0114..7aacc85 100644 --- a/sysdeps/pthread/tst-clock1.c +++ b/sysdeps/pthread/tst-clock1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cnd-basic.c b/sysdeps/pthread/tst-cnd-basic.c index 6e1aadf..ef67f81 100644 --- a/sysdeps/pthread/tst-cnd-basic.c +++ b/sysdeps/pthread/tst-cnd-basic.c @@ -1,5 +1,5 @@ /* C11 threads condition variable tests. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cnd-broadcast.c b/sysdeps/pthread/tst-cnd-broadcast.c index 7bedd70..5a713c0 100644 --- a/sysdeps/pthread/tst-cnd-broadcast.c +++ b/sysdeps/pthread/tst-cnd-broadcast.c @@ -1,5 +1,5 @@ /* C11 threads condition broadcast variable tests. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cnd-timedwait.c b/sysdeps/pthread/tst-cnd-timedwait.c index 9418ca9..a049916 100644 --- a/sysdeps/pthread/tst-cnd-timedwait.c +++ b/sysdeps/pthread/tst-cnd-timedwait.c @@ -1,5 +1,5 @@ /* C11 threads condition timed wait variable tests. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cond-except.c b/sysdeps/pthread/tst-cond-except.c index aa1b4b6..1cdc237 100644 --- a/sysdeps/pthread/tst-cond-except.c +++ b/sysdeps/pthread/tst-cond-except.c @@ -1,5 +1,5 @@ /* Verify that exception table for pthread_cond_wait is correct. - Copyright (C) 2012-2024 Free Software Foundation, Inc. + Copyright (C) 2012-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cond1.c b/sysdeps/pthread/tst-cond1.c index 224bb9e..a7ec048 100644 --- a/sysdeps/pthread/tst-cond1.c +++ b/sysdeps/pthread/tst-cond1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cond10.c b/sysdeps/pthread/tst-cond10.c index 14ff8f8..6984b28 100644 --- a/sysdeps/pthread/tst-cond10.c +++ b/sysdeps/pthread/tst-cond10.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cond11.c b/sysdeps/pthread/tst-cond11.c index 3582c44..02c5346 100644 --- a/sysdeps/pthread/tst-cond11.c +++ b/sysdeps/pthread/tst-cond11.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cond12.c b/sysdeps/pthread/tst-cond12.c index 046e4b1..73ce692 100644 --- a/sysdeps/pthread/tst-cond12.c +++ b/sysdeps/pthread/tst-cond12.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cond14.c b/sysdeps/pthread/tst-cond14.c index e410a36..bdf6331 100644 --- a/sysdeps/pthread/tst-cond14.c +++ b/sysdeps/pthread/tst-cond14.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2024 Free Software Foundation, Inc. +/* Copyright (C) 2004-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cond15.c b/sysdeps/pthread/tst-cond15.c index 9c63454..c3f8bb9 100644 --- a/sysdeps/pthread/tst-cond15.c +++ b/sysdeps/pthread/tst-cond15.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2024 Free Software Foundation, Inc. +/* Copyright (C) 2004-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cond16.c b/sysdeps/pthread/tst-cond16.c index a06b8df..7aa45d9 100644 --- a/sysdeps/pthread/tst-cond16.c +++ b/sysdeps/pthread/tst-cond16.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2024 Free Software Foundation, Inc. +/* Copyright (C) 2004-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cond18.c b/sysdeps/pthread/tst-cond18.c index 5df5e08..0d5fd9c 100644 --- a/sysdeps/pthread/tst-cond18.c +++ b/sysdeps/pthread/tst-cond18.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2024 Free Software Foundation, Inc. +/* Copyright (C) 2004-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cond19.c b/sysdeps/pthread/tst-cond19.c index 9b42f34..55735a5 100644 --- a/sysdeps/pthread/tst-cond19.c +++ b/sysdeps/pthread/tst-cond19.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2024 Free Software Foundation, Inc. +/* Copyright (C) 2004-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cond2.c b/sysdeps/pthread/tst-cond2.c index ccbf139..7d93f14 100644 --- a/sysdeps/pthread/tst-cond2.c +++ b/sysdeps/pthread/tst-cond2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cond20.c b/sysdeps/pthread/tst-cond20.c index 1415874..5e6364d 100644 --- a/sysdeps/pthread/tst-cond20.c +++ b/sysdeps/pthread/tst-cond20.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2024 Free Software Foundation, Inc. +/* Copyright (C) 2004-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cond23.c b/sysdeps/pthread/tst-cond23.c index 4a86eff..0a68472 100644 --- a/sysdeps/pthread/tst-cond23.c +++ b/sysdeps/pthread/tst-cond23.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2024 Free Software Foundation, Inc. +/* Copyright (C) 2008-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cond24.c b/sysdeps/pthread/tst-cond24.c index 9fbf395..983ba52 100644 --- a/sysdeps/pthread/tst-cond24.c +++ b/sysdeps/pthread/tst-cond24.c @@ -1,5 +1,5 @@ /* Verify that condition variables synchronized by PI mutexes don't hang. - Copyright (C) 2012-2024 Free Software Foundation, Inc. + Copyright (C) 2012-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cond25.c b/sysdeps/pthread/tst-cond25.c index 28967ce..7f61d42 100644 --- a/sysdeps/pthread/tst-cond25.c +++ b/sysdeps/pthread/tst-cond25.c @@ -1,6 +1,6 @@ /* Verify that condition variables synchronized by PI mutexes don't hang on on cancellation. - Copyright (C) 2012-2024 Free Software Foundation, Inc. + Copyright (C) 2012-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cond27.c b/sysdeps/pthread/tst-cond27.c index 71bfb6f..eb49c68 100644 --- a/sysdeps/pthread/tst-cond27.c +++ b/sysdeps/pthread/tst-cond27.c @@ -1,6 +1,6 @@ /* Test pthread_cond_clockwait timeout. - Copyright (C) 2019-2024 Free Software Foundation, Inc. + Copyright (C) 2019-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cond3.c b/sysdeps/pthread/tst-cond3.c index 7e52ade..7e9075a 100644 --- a/sysdeps/pthread/tst-cond3.c +++ b/sysdeps/pthread/tst-cond3.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cond4.c b/sysdeps/pthread/tst-cond4.c index d1734ad..c15fbcc 100644 --- a/sysdeps/pthread/tst-cond4.c +++ b/sysdeps/pthread/tst-cond4.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cond5.c b/sysdeps/pthread/tst-cond5.c index d0a9e01..bcac5c2 100644 --- a/sysdeps/pthread/tst-cond5.c +++ b/sysdeps/pthread/tst-cond5.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cond6.c b/sysdeps/pthread/tst-cond6.c index 1a0c5c3..ed140ac 100644 --- a/sysdeps/pthread/tst-cond6.c +++ b/sysdeps/pthread/tst-cond6.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cond7.c b/sysdeps/pthread/tst-cond7.c index b43695d..bd840cb 100644 --- a/sysdeps/pthread/tst-cond7.c +++ b/sysdeps/pthread/tst-cond7.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cond8.c b/sysdeps/pthread/tst-cond8.c index bb54df9..322a864 100644 --- a/sysdeps/pthread/tst-cond8.c +++ b/sysdeps/pthread/tst-cond8.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-cond9.c b/sysdeps/pthread/tst-cond9.c index 564f1ed..d2024d4 100644 --- a/sysdeps/pthread/tst-cond9.c +++ b/sysdeps/pthread/tst-cond9.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-create-detached.c b/sysdeps/pthread/tst-create-detached.c index 7b6a0c3..9fd5795 100644 --- a/sysdeps/pthread/tst-create-detached.c +++ b/sysdeps/pthread/tst-create-detached.c @@ -1,5 +1,5 @@ /* Bug 20116: Test rapid creation of detached threads. - Copyright (C) 2017-2024 Free Software Foundation, Inc. + Copyright (C) 2017-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-create1.c b/sysdeps/pthread/tst-create1.c index d5a44d0..cd8c137 100644 --- a/sysdeps/pthread/tst-create1.c +++ b/sysdeps/pthread/tst-create1.c @@ -1,5 +1,5 @@ /* Verify that pthread_create does not deadlock when ctors take locks. - Copyright (C) 2021-2024 Free Software Foundation, Inc. + Copyright (C) 2021-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-create1mod.c b/sysdeps/pthread/tst-create1mod.c index 9754409..ea08107 100644 --- a/sysdeps/pthread/tst-create1mod.c +++ b/sysdeps/pthread/tst-create1mod.c @@ -1,5 +1,5 @@ /* Verify that pthread_create does not deadlock when ctors take locks. - Copyright (C) 2021-2024 Free Software Foundation, Inc. + Copyright (C) 2021-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-detach1.c b/sysdeps/pthread/tst-detach1.c index 08983db..1be3799 100644 --- a/sysdeps/pthread/tst-detach1.c +++ b/sysdeps/pthread/tst-detach1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-eintr2.c b/sysdeps/pthread/tst-eintr2.c index d3b8051..e27c04d 100644 --- a/sysdeps/pthread/tst-eintr2.c +++ b/sysdeps/pthread/tst-eintr2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-eintr3.c b/sysdeps/pthread/tst-eintr3.c index c57c848..dee94a4 100644 --- a/sysdeps/pthread/tst-eintr3.c +++ b/sysdeps/pthread/tst-eintr3.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-eintr4.c b/sysdeps/pthread/tst-eintr4.c index ae9a18f..9df4a9f 100644 --- a/sysdeps/pthread/tst-eintr4.c +++ b/sysdeps/pthread/tst-eintr4.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-eintr5.c b/sysdeps/pthread/tst-eintr5.c index 631626e..fdae541 100644 --- a/sysdeps/pthread/tst-eintr5.c +++ b/sysdeps/pthread/tst-eintr5.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-exec1.c b/sysdeps/pthread/tst-exec1.c index 5f7fc9a..42d8ff7 100644 --- a/sysdeps/pthread/tst-exec1.c +++ b/sysdeps/pthread/tst-exec1.c @@ -1,5 +1,5 @@ /* Simple exec test, only a thread in the parent. - Copyright (C) 2002-2024 Free Software Foundation, Inc. + Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-exec2.c b/sysdeps/pthread/tst-exec2.c index c86df18..befe1c6 100644 --- a/sysdeps/pthread/tst-exec2.c +++ b/sysdeps/pthread/tst-exec2.c @@ -1,5 +1,5 @@ /* Thread with running thread calls exec. - Copyright (C) 2002-2024 Free Software Foundation, Inc. + Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-exec3.c b/sysdeps/pthread/tst-exec3.c index 6772df2..3b38249 100644 --- a/sysdeps/pthread/tst-exec3.c +++ b/sysdeps/pthread/tst-exec3.c @@ -1,5 +1,5 @@ /* Thread calls exec. - Copyright (C) 2002-2024 Free Software Foundation, Inc. + Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-exit1.c b/sysdeps/pthread/tst-exit1.c index 9fe489f..449bdcd 100644 --- a/sysdeps/pthread/tst-exit1.c +++ b/sysdeps/pthread/tst-exit1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-fini1.c b/sysdeps/pthread/tst-fini1.c index ad6951f..36b6fc5 100644 --- a/sysdeps/pthread/tst-fini1.c +++ b/sysdeps/pthread/tst-fini1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2024 Free Software Foundation, Inc. +/* Copyright (C) 2004-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-fini1mod.c b/sysdeps/pthread/tst-fini1mod.c index ae29455..1f71ac7 100644 --- a/sysdeps/pthread/tst-fini1mod.c +++ b/sysdeps/pthread/tst-fini1mod.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2024 Free Software Foundation, Inc. +/* Copyright (C) 2004-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-flock1.c b/sysdeps/pthread/tst-flock1.c index 99ae837..ead86cd 100644 --- a/sysdeps/pthread/tst-flock1.c +++ b/sysdeps/pthread/tst-flock1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-flock2.c b/sysdeps/pthread/tst-flock2.c index 49b9156..68d55fb 100644 --- a/sysdeps/pthread/tst-flock2.c +++ b/sysdeps/pthread/tst-flock2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-fopen-threaded.c b/sysdeps/pthread/tst-fopen-threaded.c new file mode 100644 index 0000000..ade58ad --- /dev/null +++ b/sysdeps/pthread/tst-fopen-threaded.c @@ -0,0 +1,258 @@ +/* Test for fread and fwrite with multiple threads. + Copyright (C) 2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +/* Description of test intent. + The test creates NUM_THREADS threads for reading and writing to the + prepared file. The prepared file contains 'NUM_THREADS - 1' bytes + where each byte is unique number from 0 to 'NUM_THREADS - 2'. If all + operations are correctly multi-threaded safe then all concurent read + operations should succeed and read a unique 1 byte value. The last + thread to read should get an EOF. In concurrent write, all write + operations should succeed and the file should contain all unique 1 + byte values from 0 to 'NUM_THREADS - 1'. Both concurrent read and + concurrent write tests are repeated ITERS times to increase + the probability of detecting concurrency issues. */ + +#include <errno.h> +#include <pthread.h> +#include <stdbool.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> + +#include <support/check.h> +#include <support/temp_file.h> +#include <support/xstdio.h> +#include <support/xthread.h> + +#define NUM_THREADS 100 +#define ITERS 10 + +char *temp_file; +pthread_barrier_t barrier; + +struct thread_data +{ + FILE *fd; + /* Read value or value to be written. */ + unsigned char value; + bool eof; +}; + +static void * +threadReadRoutine (void *argv) +{ + struct thread_data *my_data; + unsigned char read_buffer; + int ret = 0; + my_data = (struct thread_data *) argv; + /* Wait for all threads to be ready to read. */ + xpthread_barrier_wait (&barrier); + + ret = fread (&read_buffer, 1, sizeof (read_buffer), my_data->fd); + /* If no data is returned (we read only 1 byte, so there's no short read + situation here), look for EOF flag and record it in MY_DATA. The EOF flag + is not cleared because that could result in a test failure being masked + when two threads fail to read and one of them clears error/EOF flags + before the second one has the chance to observe it. + + Successful readers could still see the EOF if they fall behind the failing + read when calling feof(), which could result in a false test failure. To + avoid this race, we only make the failing reader check for EOF or + error. */ + if (ret == 0) + { + if (feof (my_data->fd) != 0) + my_data->eof = true; + else + FAIL_EXIT1 ("fread failed (ferror: %d): %m", ferror (my_data->fd)); + } + else + /* Save the read value. */ + my_data->value = read_buffer; + TEST_COMPARE (ferror (my_data->fd), 0); + return NULL; +} + +void * +threadWriteRoutine (void *argv) +{ + struct thread_data *my_data; + int ret = 0; + my_data = (struct thread_data *) argv; + /* Wait for all threads to be ready to write. */ + xpthread_barrier_wait (&barrier); + + ret = fwrite (&my_data->value, sizeof (unsigned char), 1, my_data->fd); + TEST_COMPARE (ferror (my_data->fd), 0); + TEST_COMPARE (feof (my_data->fd), 0); + TEST_COMPARE (ret, 1); + return NULL; +} + +void * +threadOpenCloseRoutine (void *argv) +{ + /* Wait for all threads to be ready to call fopen and fclose. */ + xpthread_barrier_wait (&barrier); + + FILE *fd = xfopen ("/tmp/openclosetest", "w+"); + xfclose (fd); + return NULL; +} + +static int +do_test (void) +{ + FILE *fd_file = NULL; + unsigned char buffer[NUM_THREADS] = "0"; + size_t ret = 0; + pthread_t threads[NUM_THREADS]; + struct thread_data thread_data_array[NUM_THREADS]; + bool present_values[NUM_THREADS] = { false }; + + /* Prepare files. */ + for (int i = 0; i < NUM_THREADS; i++) + buffer[i] = i; + int fd = create_temp_file ("tst-fopen.", &temp_file); + TEST_VERIFY_EXIT (fd != -1); + fd_file = fdopen (fd, "w"); + /* NUM_THREADS - 1: last thread will read EOF */ + ret = fwrite (buffer, sizeof (unsigned char), NUM_THREADS - 1, fd_file); + TEST_COMPARE (ret, NUM_THREADS - 1); + xfclose (fd_file); + + /* Test 1: Concurrent read. */ + for (int reps = 1; reps <= ITERS; reps++) + { + fd_file = xfopen (temp_file, "r"); + xpthread_barrier_init (&barrier, NULL, NUM_THREADS); + for (int i = 0; i < NUM_THREADS; i++) + { + thread_data_array[i].fd = fd_file; + /* Initialize with highest possible value so it's easier to debug if + anything goes wrong. */ + thread_data_array[i].value = 255; + thread_data_array[i].eof = false; + + threads[i] = + xpthread_create (support_small_stack_thread_attribute (), + threadReadRoutine, + (void *) &thread_data_array[i]); + } + + for (int i = 0; i < NUM_THREADS; i++) + { + xpthread_join (threads[i]); + } + xpthread_barrier_destroy (&barrier); + xfclose (fd_file); + + /* Verify read values. */ + int eof_cnt = 0; + for (int i = 0; i < NUM_THREADS; i++) + present_values[i] = false; + for (int i = 0; i < NUM_THREADS; i++) + { + if (thread_data_array[i].eof) + { + /* EOF was read. */ + present_values[NUM_THREADS - 1] = true; + eof_cnt++; + } + else + { + /* The same value shouldn't be read twice. */ + TEST_VERIFY (!present_values[thread_data_array[i].value]); + present_values[thread_data_array[i].value] = true; + } + } + /* EOF is read exactly once. */ + TEST_COMPARE (eof_cnt, 1); + for (int i = 0; i < NUM_THREADS; i++) + { + /* All values should be read. */ + TEST_VERIFY (present_values[i]); + } + } + + /* Test 2: Concurrent write. */ + for (int reps = 1; reps <= ITERS; reps++) + { + fd_file = xfopen (temp_file, "w"); + xpthread_barrier_init (&barrier, NULL, NUM_THREADS); + for (int i = 0; i < NUM_THREADS; i++) + { + thread_data_array[i].fd = fd_file; + thread_data_array[i].value = i; + + threads[i] = + xpthread_create (support_small_stack_thread_attribute (), + threadWriteRoutine, + (void *) &thread_data_array[i]); + } + + for (int i = 0; i < NUM_THREADS; i++) + { + xpthread_join (threads[i]); + } + xpthread_barrier_destroy (&barrier); + xfclose (fd_file); + + /* Verify written values. */ + for (int i = 0; i < NUM_THREADS; i++) + present_values[i] = false; + memset (buffer, 0, NUM_THREADS); + fd_file = xfopen (temp_file, "r"); + ret = fread (buffer, sizeof (unsigned char), NUM_THREADS, fd_file); + TEST_COMPARE (ret, NUM_THREADS); + for (int i = 0; i < NUM_THREADS; i++) + { + /* The same value shouldn't be written twice. */ + TEST_VERIFY (!present_values[buffer[i]]); + present_values[buffer[i]] = true; + } + for (int i = 0; i < NUM_THREADS; i++) + { + /* All values should be written. */ + TEST_VERIFY (present_values[i]); + } + xfclose (fd_file); + } + + /* Test 3: Concurrent open/close. */ + for (int reps = 1; reps <= ITERS; reps++) + { + xpthread_barrier_init (&barrier, NULL, NUM_THREADS); + for (int i = 0; i < NUM_THREADS; i++) + { + threads[i] = + xpthread_create (support_small_stack_thread_attribute (), + threadOpenCloseRoutine, NULL); + } + for (int i = 0; i < NUM_THREADS; i++) + { + xpthread_join (threads[i]); + } + xpthread_barrier_destroy (&barrier); + } + + return 0; +} + +#include <support/test-driver.c> diff --git a/sysdeps/pthread/tst-fork1.c b/sysdeps/pthread/tst-fork1.c index 68340c9..4c83593 100644 --- a/sysdeps/pthread/tst-fork1.c +++ b/sysdeps/pthread/tst-fork1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-fork2.c b/sysdeps/pthread/tst-fork2.c index e1eb3f9..55cc8ce 100644 --- a/sysdeps/pthread/tst-fork2.c +++ b/sysdeps/pthread/tst-fork2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-fork3.c b/sysdeps/pthread/tst-fork3.c index 58a9e4b..e280f0c 100644 --- a/sysdeps/pthread/tst-fork3.c +++ b/sysdeps/pthread/tst-fork3.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-fork4.c b/sysdeps/pthread/tst-fork4.c index f32e818..33eb943 100644 --- a/sysdeps/pthread/tst-fork4.c +++ b/sysdeps/pthread/tst-fork4.c @@ -1,5 +1,5 @@ /* Test of fork updating child universe's pthread structures. - Copyright (C) 2003-2024 Free Software Foundation, Inc. + Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-join1.c b/sysdeps/pthread/tst-join1.c index aa3967d..766c6d6 100644 --- a/sysdeps/pthread/tst-join1.c +++ b/sysdeps/pthread/tst-join1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-join10.c b/sysdeps/pthread/tst-join10.c index ee6eb49..4deb0f8 100644 --- a/sysdeps/pthread/tst-join10.c +++ b/sysdeps/pthread/tst-join10.c @@ -1,5 +1,5 @@ /* Check if pthread_clockjoin_np is a cancellation entrypoint. - Copyright (C) 2019-2024 Free Software Foundation, Inc. + Copyright (C) 2019-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-join11.c b/sysdeps/pthread/tst-join11.c index f6d14a9..4912a10 100644 --- a/sysdeps/pthread/tst-join11.c +++ b/sysdeps/pthread/tst-join11.c @@ -1,5 +1,5 @@ /* Check if pthread_clockjoin_np is a cancellation entrypoint. - Copyright (C) 2019-2024 Free Software Foundation, Inc. + Copyright (C) 2019-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-join12.c b/sysdeps/pthread/tst-join12.c index 5ad5ea0..6f28d33 100644 --- a/sysdeps/pthread/tst-join12.c +++ b/sysdeps/pthread/tst-join12.c @@ -1,5 +1,5 @@ /* Check if pthread_clockjoin_np is a cancellation entrypoint. - Copyright (C) 2019-2024 Free Software Foundation, Inc. + Copyright (C) 2019-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-join13.c b/sysdeps/pthread/tst-join13.c index dbc7258..c142b19 100644 --- a/sysdeps/pthread/tst-join13.c +++ b/sysdeps/pthread/tst-join13.c @@ -1,5 +1,5 @@ /* Check if pthread_clockjoin_np is a cancellation entrypoint. - Copyright (C) 2019-2024 Free Software Foundation, Inc. + Copyright (C) 2019-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-join14.c b/sysdeps/pthread/tst-join14.c index 1aa7fde..0831e6e 100644 --- a/sysdeps/pthread/tst-join14.c +++ b/sysdeps/pthread/tst-join14.c @@ -1,5 +1,5 @@ /* pthread_timedjoin_np, pthread_clockjoin_np NULL timeout test. - Copyright (C) 2019-2024 Free Software Foundation, Inc. + Copyright (C) 2019-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-join15.c b/sysdeps/pthread/tst-join15.c index d1f57cd..cfb9cd4 100644 --- a/sysdeps/pthread/tst-join15.c +++ b/sysdeps/pthread/tst-join15.c @@ -1,5 +1,5 @@ /* Check pthread_clockjoin_np clock support. - Copyright (C) 2020-2024 Free Software Foundation, Inc. + Copyright (C) 2020-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-join16-time64.c b/sysdeps/pthread/tst-join16-time64.c new file mode 100644 index 0000000..730cc56 --- /dev/null +++ b/sysdeps/pthread/tst-join16-time64.c @@ -0,0 +1 @@ +#include "tst-join16.c" diff --git a/sysdeps/pthread/tst-join16.c b/sysdeps/pthread/tst-join16.c new file mode 100644 index 0000000..f353897 --- /dev/null +++ b/sysdeps/pthread/tst-join16.c @@ -0,0 +1,87 @@ +/* Test pthread_timedjoin_np and pthread_clockjoin_np with an invalid timeout. + Copyright (C) 2024-2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <pthread.h> +#include <stdio.h> +#include <time.h> +#include <support/check.h> +#include <support/xthread.h> +#include <support/xtime.h> + + +#define CLOCK_USE_TIMEDJOIN (-1) + +static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; + +static void * +tf (void *arg) +{ + xpthread_mutex_lock (&lock); + xpthread_mutex_unlock (&lock); + return (void *) 42l; +} + +static int +do_test_clock (clockid_t clockid) +{ + const clockid_t clockid_for_get = + (clockid == CLOCK_USE_TIMEDJOIN) ? CLOCK_REALTIME : clockid; + + xpthread_mutex_lock (&lock); + pthread_t th = xpthread_create (NULL, tf, NULL); + + void *status; + int ret; + struct timespec timeout = xclock_now (clockid_for_get); + timeout.tv_sec += 2; + timeout.tv_nsec = -1; + if (clockid == CLOCK_USE_TIMEDJOIN) + ret = pthread_timedjoin_np (th, &status, &timeout); + else + ret = pthread_clockjoin_np (th, &status, clockid, &timeout); + TEST_COMPARE (ret, EINVAL); + timeout.tv_nsec = 1000000000; + if (clockid == CLOCK_USE_TIMEDJOIN) + ret = pthread_timedjoin_np (th, &status, &timeout); + else + ret = pthread_clockjoin_np (th, &status, clockid, &timeout); + TEST_COMPARE (ret, EINVAL); + xpthread_mutex_unlock (&lock); + timeout.tv_nsec = 0; + ret = pthread_join (th, &status); + TEST_COMPARE (ret, 0); + if (status != (void *) 42l) + FAIL_EXIT1 ("return value %p, expected %p\n", status, (void *) 42l); + + return 0; +} + +static int +do_test (void) +{ + puts ("testing pthread_timedjoin_np"); + do_test_clock (CLOCK_USE_TIMEDJOIN); + puts ("testing CLOCK_REALTIME"); + do_test_clock (CLOCK_REALTIME); + puts ("testing CLOCK_MONOTONIC"); + do_test_clock (CLOCK_MONOTONIC); + return 0; +} + +#include <support/test-driver.c> diff --git a/sysdeps/pthread/tst-join2.c b/sysdeps/pthread/tst-join2.c index 95fd8d0..c876c34 100644 --- a/sysdeps/pthread/tst-join2.c +++ b/sysdeps/pthread/tst-join2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-join3.c b/sysdeps/pthread/tst-join3.c index ea5f37b..4f3060c 100644 --- a/sysdeps/pthread/tst-join3.c +++ b/sysdeps/pthread/tst-join3.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-join4.c b/sysdeps/pthread/tst-join4.c index fbe05a4..61ace70 100644 --- a/sysdeps/pthread/tst-join4.c +++ b/sysdeps/pthread/tst-join4.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-join5.c b/sysdeps/pthread/tst-join5.c index a4e4f55..7c8778f 100644 --- a/sysdeps/pthread/tst-join5.c +++ b/sysdeps/pthread/tst-join5.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-join7.c b/sysdeps/pthread/tst-join7.c index 75e25bc..95d3d29 100644 --- a/sysdeps/pthread/tst-join7.c +++ b/sysdeps/pthread/tst-join7.c @@ -1,6 +1,6 @@ /* Verify that TLS access in separate thread in a dlopened library does not deadlock. - Copyright (C) 2015-2024 Free Software Foundation, Inc. + Copyright (C) 2015-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-join7mod.c b/sysdeps/pthread/tst-join7mod.c index 6b1278f..77edaea 100644 --- a/sysdeps/pthread/tst-join7mod.c +++ b/sysdeps/pthread/tst-join7mod.c @@ -1,6 +1,6 @@ /* Verify that TLS access in separate thread in a dlopened library does not deadlock - the module. - Copyright (C) 2015-2024 Free Software Foundation, Inc. + Copyright (C) 2015-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-join8.c b/sysdeps/pthread/tst-join8.c index fb0797f..b3cec81 100644 --- a/sysdeps/pthread/tst-join8.c +++ b/sysdeps/pthread/tst-join8.c @@ -1,5 +1,5 @@ /* Check if pthread_timedjoin_np is a cancellation entrypoint. - Copyright (C) 2019-2024 Free Software Foundation, Inc. + Copyright (C) 2019-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-join9.c b/sysdeps/pthread/tst-join9.c index 85bc5ab..d87a404 100644 --- a/sysdeps/pthread/tst-join9.c +++ b/sysdeps/pthread/tst-join9.c @@ -1,5 +1,5 @@ /* Check if pthread_timedjoin_np is a cancellation entrypoint. - Copyright (C) 2019-2024 Free Software Foundation, Inc. + Copyright (C) 2019-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-key1.c b/sysdeps/pthread/tst-key1.c index 2de536c..a0e52591 100644 --- a/sysdeps/pthread/tst-key1.c +++ b/sysdeps/pthread/tst-key1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-key2.c b/sysdeps/pthread/tst-key2.c index 10f41cf..4004b98 100644 --- a/sysdeps/pthread/tst-key2.c +++ b/sysdeps/pthread/tst-key2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-key3.c b/sysdeps/pthread/tst-key3.c index f6783fd..2e95b5e 100644 --- a/sysdeps/pthread/tst-key3.c +++ b/sysdeps/pthread/tst-key3.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-key4.c b/sysdeps/pthread/tst-key4.c index c4d4725..b317fae 100644 --- a/sysdeps/pthread/tst-key4.c +++ b/sysdeps/pthread/tst-key4.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-kill1.c b/sysdeps/pthread/tst-kill1.c index d320aae..ef32d19 100644 --- a/sysdeps/pthread/tst-kill1.c +++ b/sysdeps/pthread/tst-kill1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-kill2.c b/sysdeps/pthread/tst-kill2.c index 6e7c298..a84c188 100644 --- a/sysdeps/pthread/tst-kill2.c +++ b/sysdeps/pthread/tst-kill2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-kill3.c b/sysdeps/pthread/tst-kill3.c index 9e81925..b66c549 100644 --- a/sysdeps/pthread/tst-kill3.c +++ b/sysdeps/pthread/tst-kill3.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-kill5.c b/sysdeps/pthread/tst-kill5.c index cd9dfc6..b546d7c 100644 --- a/sysdeps/pthread/tst-kill5.c +++ b/sysdeps/pthread/tst-kill5.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-kill6.c b/sysdeps/pthread/tst-kill6.c index 5e96c3d..cd51dbf 100644 --- a/sysdeps/pthread/tst-kill6.c +++ b/sysdeps/pthread/tst-kill6.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-memstream.c b/sysdeps/pthread/tst-memstream.c index 8ea760c..0d2bbbc 100644 --- a/sysdeps/pthread/tst-memstream.c +++ b/sysdeps/pthread/tst-memstream.c @@ -1,5 +1,5 @@ /* Test for open_memstream locking. - Copyright (C) 2017-2024 Free Software Foundation, Inc. + Copyright (C) 2017-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-mtx-basic.c b/sysdeps/pthread/tst-mtx-basic.c index ca449de..c4d89dd 100644 --- a/sysdeps/pthread/tst-mtx-basic.c +++ b/sysdeps/pthread/tst-mtx-basic.c @@ -1,5 +1,5 @@ /* C11 threads basic mutex tests. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-mtx-recursive.c b/sysdeps/pthread/tst-mtx-recursive.c index f24ddfd..ff4f644 100644 --- a/sysdeps/pthread/tst-mtx-recursive.c +++ b/sysdeps/pthread/tst-mtx-recursive.c @@ -1,5 +1,5 @@ /* C11 threads recursive mutex tests. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-mtx-timedlock.c b/sysdeps/pthread/tst-mtx-timedlock.c index 59d5342..dd8f060 100644 --- a/sysdeps/pthread/tst-mtx-timedlock.c +++ b/sysdeps/pthread/tst-mtx-timedlock.c @@ -1,5 +1,5 @@ /* C11 threads timed mutex tests. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-mtx-trylock.c b/sysdeps/pthread/tst-mtx-trylock.c index 65b7a9b..9135078 100644 --- a/sysdeps/pthread/tst-mtx-trylock.c +++ b/sysdeps/pthread/tst-mtx-trylock.c @@ -1,5 +1,5 @@ /* C11 threads trylock mutex tests. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-mutex-errorcheck.c b/sysdeps/pthread/tst-mutex-errorcheck.c index f44836d..8a08ab9 100644 --- a/sysdeps/pthread/tst-mutex-errorcheck.c +++ b/sysdeps/pthread/tst-mutex-errorcheck.c @@ -1,5 +1,5 @@ /* Check that error checking mutexes are not subject to lock elision. - Copyright (C) 2016-2024 Free Software Foundation, Inc. + Copyright (C) 2016-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-mutex1.c b/sysdeps/pthread/tst-mutex1.c index 01ea5ad..d5b1a2d 100644 --- a/sysdeps/pthread/tst-mutex1.c +++ b/sysdeps/pthread/tst-mutex1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-mutex10.c b/sysdeps/pthread/tst-mutex10.c index a325840..2346f85 100644 --- a/sysdeps/pthread/tst-mutex10.c +++ b/sysdeps/pthread/tst-mutex10.c @@ -1,5 +1,5 @@ /* Testing race while enabling lock elision. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-mutex11.c b/sysdeps/pthread/tst-mutex11.c index 0beb0a8..b46c91f 100644 --- a/sysdeps/pthread/tst-mutex11.c +++ b/sysdeps/pthread/tst-mutex11.c @@ -1,6 +1,6 @@ /* Test unsupported/bad clocks passed to pthread_mutex_clocklock. - Copyright (C) 2019-2024 Free Software Foundation, Inc. + Copyright (C) 2019-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-mutex2.c b/sysdeps/pthread/tst-mutex2.c index 3884e6b..d9e0d2b 100644 --- a/sysdeps/pthread/tst-mutex2.c +++ b/sysdeps/pthread/tst-mutex2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-mutex3.c b/sysdeps/pthread/tst-mutex3.c index 389c27f..69283af 100644 --- a/sysdeps/pthread/tst-mutex3.c +++ b/sysdeps/pthread/tst-mutex3.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-mutex4.c b/sysdeps/pthread/tst-mutex4.c index 3552fe5..bad2071 100644 --- a/sysdeps/pthread/tst-mutex4.c +++ b/sysdeps/pthread/tst-mutex4.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-mutex5.c b/sysdeps/pthread/tst-mutex5.c index ce689d8..10b231d 100644 --- a/sysdeps/pthread/tst-mutex5.c +++ b/sysdeps/pthread/tst-mutex5.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-mutex6.c b/sysdeps/pthread/tst-mutex6.c index 3ff58be..946dbf5 100644 --- a/sysdeps/pthread/tst-mutex6.c +++ b/sysdeps/pthread/tst-mutex6.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-mutex7.c b/sysdeps/pthread/tst-mutex7.c index 65fabeb..fc8220e 100644 --- a/sysdeps/pthread/tst-mutex7.c +++ b/sysdeps/pthread/tst-mutex7.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-mutex9.c b/sysdeps/pthread/tst-mutex9.c index 89bda47..791dad5 100644 --- a/sysdeps/pthread/tst-mutex9.c +++ b/sysdeps/pthread/tst-mutex9.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-once1.c b/sysdeps/pthread/tst-once1.c index 92e7e51..8df1b04 100644 --- a/sysdeps/pthread/tst-once1.c +++ b/sysdeps/pthread/tst-once1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-once2.c b/sysdeps/pthread/tst-once2.c index 37434b9..e663831 100644 --- a/sysdeps/pthread/tst-once2.c +++ b/sysdeps/pthread/tst-once2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-once3.c b/sysdeps/pthread/tst-once3.c index ee4274a..5902d0a 100644 --- a/sysdeps/pthread/tst-once3.c +++ b/sysdeps/pthread/tst-once3.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-once4.c b/sysdeps/pthread/tst-once4.c index 90ba25e..3b9bcf2 100644 --- a/sysdeps/pthread/tst-once4.c +++ b/sysdeps/pthread/tst-once4.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-pt-align.c b/sysdeps/pthread/tst-pt-align.c index 6206619..56edb64 100644 --- a/sysdeps/pthread/tst-pt-align.c +++ b/sysdeps/pthread/tst-pt-align.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-pt-align3.c b/sysdeps/pthread/tst-pt-align3.c index db619cd..0d5ffa5 100644 --- a/sysdeps/pthread/tst-pt-align3.c +++ b/sysdeps/pthread/tst-pt-align3.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005-2024 Free Software Foundation, Inc. +/* Copyright (C) 2005-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-pt-popen1.c b/sysdeps/pthread/tst-pt-popen1.c index 1fc7e67..92ee761 100644 --- a/sysdeps/pthread/tst-pt-popen1.c +++ b/sysdeps/pthread/tst-pt-popen1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-pt-sysconf.c b/sysdeps/pthread/tst-pt-sysconf.c index 18ebb8f..70d8375 100644 --- a/sysdeps/pthread/tst-pt-sysconf.c +++ b/sysdeps/pthread/tst-pt-sysconf.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-pt-tls1.c b/sysdeps/pthread/tst-pt-tls1.c index b336333..a4ef146 100644 --- a/sysdeps/pthread/tst-pt-tls1.c +++ b/sysdeps/pthread/tst-pt-tls1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-pt-tls2.c b/sysdeps/pthread/tst-pt-tls2.c index 490c9d0..0ce47ec 100644 --- a/sysdeps/pthread/tst-pt-tls2.c +++ b/sysdeps/pthread/tst-pt-tls2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-pt-tls4.c b/sysdeps/pthread/tst-pt-tls4.c index 1bec047..400c8ee 100644 --- a/sysdeps/pthread/tst-pt-tls4.c +++ b/sysdeps/pthread/tst-pt-tls4.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-pthread-exit-signal.c b/sysdeps/pthread/tst-pthread-exit-signal.c index cb85d26..1d79837 100644 --- a/sysdeps/pthread/tst-pthread-exit-signal.c +++ b/sysdeps/pthread/tst-pthread-exit-signal.c @@ -1,5 +1,5 @@ /* Test that pending signals are not delivered on thread exit (bug 28607). - Copyright (C) 2021-2024 Free Software Foundation, Inc. + Copyright (C) 2021-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-pthread-mutexattr-2.c b/sysdeps/pthread/tst-pthread-mutexattr-2.c new file mode 100644 index 0000000..76b9648 --- /dev/null +++ b/sysdeps/pthread/tst-pthread-mutexattr-2.c @@ -0,0 +1,60 @@ +/* Test pthread_mutexattr_gettype and pthread_mutexattr_settype with + valid and invalid kinds. + + Copyright (C) 2024-2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <stdio.h> +#include <pthread.h> + +#include <support/check.h> +#include <support/xthread.h> + + +static void +do_test_kind (int test_kind, const char *name) +{ + printf ("testing %s\n", name); + pthread_mutexattr_t attr; + xpthread_mutexattr_init (&attr); + int ret = pthread_mutexattr_settype (&attr, test_kind); + TEST_COMPARE (ret, 0); + int kind = 123456789; + ret = pthread_mutexattr_gettype (&attr, &kind); + TEST_COMPARE (ret, 0); + TEST_COMPARE (kind, test_kind); +} + +int +do_test (void) +{ + do_test_kind (PTHREAD_MUTEX_NORMAL, "PTHREAD_MUTEX_NORMAL"); + do_test_kind (PTHREAD_MUTEX_ERRORCHECK, "PTHREAD_MUTEX_ERRORCHECK"); + do_test_kind (PTHREAD_MUTEX_RECURSIVE, "PTHREAD_MUTEX_RECURSIVE"); + do_test_kind (PTHREAD_MUTEX_DEFAULT, "PTHREAD_MUTEX_DEFAULT"); + + /* Also test an invalid kind. */ + pthread_mutexattr_t attr; + xpthread_mutexattr_init (&attr); + int ret = pthread_mutexattr_settype (&attr, 123456789); + TEST_COMPARE (ret, EINVAL); + + return 0; +} + +#include <support/test-driver.c> diff --git a/sysdeps/pthread/tst-pthread-mutexattr.c b/sysdeps/pthread/tst-pthread-mutexattr.c index 514ddca..dee3e4d 100644 --- a/sysdeps/pthread/tst-pthread-mutexattr.c +++ b/sysdeps/pthread/tst-pthread-mutexattr.c @@ -1,6 +1,6 @@ /* Make sure that pthread_mutexattr_gettype returns a valid kind. - Copyright (C) 2015-2024 Free Software Foundation, Inc. + Copyright (C) 2015-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-pthread-raise-blocked-self.c b/sysdeps/pthread/tst-pthread-raise-blocked-self.c index 5dc2932..afac122 100644 --- a/sysdeps/pthread/tst-pthread-raise-blocked-self.c +++ b/sysdeps/pthread/tst-pthread-raise-blocked-self.c @@ -1,5 +1,5 @@ /* Test that raise sends signal to current thread even if blocked. - Copyright (C) 2021-2024 Free Software Foundation, Inc. + Copyright (C) 2021-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-pthread-setuid-loop.c b/sysdeps/pthread/tst-pthread-setuid-loop.c index d36218c..8ef47e2 100644 --- a/sysdeps/pthread/tst-pthread-setuid-loop.c +++ b/sysdeps/pthread/tst-pthread-setuid-loop.c @@ -1,5 +1,5 @@ /* Test that setuid, pthread_create, thread exit do not deadlock (bug 28361). - Copyright (C) 2021-2024 Free Software Foundation, Inc. + Copyright (C) 2021-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-pthread_cancel-exited.c b/sysdeps/pthread/tst-pthread_cancel-exited.c index 4d9fb6b..94336d6 100644 --- a/sysdeps/pthread/tst-pthread_cancel-exited.c +++ b/sysdeps/pthread/tst-pthread_cancel-exited.c @@ -1,5 +1,5 @@ /* Test that pthread_kill succeeds for an exited thread. - Copyright (C) 2021-2024 Free Software Foundation, Inc. + Copyright (C) 2021-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-pthread_cancel-select-loop.c b/sysdeps/pthread/tst-pthread_cancel-select-loop.c index 33d1c6a..3bc8e15 100644 --- a/sysdeps/pthread/tst-pthread_cancel-select-loop.c +++ b/sysdeps/pthread/tst-pthread_cancel-select-loop.c @@ -1,5 +1,5 @@ /* Test that pthread_cancel succeeds during thread exit. - Copyright (C) 2021-2024 Free Software Foundation, Inc. + Copyright (C) 2021-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-pthread_kill-exited.c b/sysdeps/pthread/tst-pthread_kill-exited.c index 73d5130..3d500ff 100644 --- a/sysdeps/pthread/tst-pthread_kill-exited.c +++ b/sysdeps/pthread/tst-pthread_kill-exited.c @@ -1,5 +1,5 @@ /* Test that pthread_kill succeeds for an exited thread. - Copyright (C) 2021-2024 Free Software Foundation, Inc. + Copyright (C) 2021-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-pthread_kill-exiting.c b/sysdeps/pthread/tst-pthread_kill-exiting.c index ff172bb..c3697ac 100644 --- a/sysdeps/pthread/tst-pthread_kill-exiting.c +++ b/sysdeps/pthread/tst-pthread_kill-exiting.c @@ -1,5 +1,5 @@ /* Test that pthread_kill succeeds during thread exit. - Copyright (C) 2021-2024 Free Software Foundation, Inc. + Copyright (C) 2021-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-raise1.c b/sysdeps/pthread/tst-raise1.c index 9ecead7..664086c 100644 --- a/sysdeps/pthread/tst-raise1.c +++ b/sysdeps/pthread/tst-raise1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-robust1.c b/sysdeps/pthread/tst-robust1.c index 9c562dd..bd659cc 100644 --- a/sysdeps/pthread/tst-robust1.c +++ b/sysdeps/pthread/tst-robust1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005-2024 Free Software Foundation, Inc. +/* Copyright (C) 2005-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-robust10.c b/sysdeps/pthread/tst-robust10.c index 2f17ad6..ef1e311 100644 --- a/sysdeps/pthread/tst-robust10.c +++ b/sysdeps/pthread/tst-robust10.c @@ -1,5 +1,5 @@ /* Test that pthread_mutex_timedlock properly times out. - Copyright (C) 2016-2024 Free Software Foundation, Inc. + Copyright (C) 2016-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-robust7.c b/sysdeps/pthread/tst-robust7.c index 569d60c..bf660e8 100644 --- a/sysdeps/pthread/tst-robust7.c +++ b/sysdeps/pthread/tst-robust7.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005-2024 Free Software Foundation, Inc. +/* Copyright (C) 2005-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-rwlock-tryrdlock-stall.c b/sysdeps/pthread/tst-rwlock-tryrdlock-stall.c index ad4aa8c..7f6bcaa 100644 --- a/sysdeps/pthread/tst-rwlock-tryrdlock-stall.c +++ b/sysdeps/pthread/tst-rwlock-tryrdlock-stall.c @@ -1,5 +1,5 @@ /* Bug 23844: Test for pthread_rwlock_tryrdlock stalls. - Copyright (C) 2019-2024 Free Software Foundation, Inc. + Copyright (C) 2019-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-rwlock-trywrlock-stall.c b/sysdeps/pthread/tst-rwlock-trywrlock-stall.c index 7a9b0f6..edd935a 100644 --- a/sysdeps/pthread/tst-rwlock-trywrlock-stall.c +++ b/sysdeps/pthread/tst-rwlock-trywrlock-stall.c @@ -1,5 +1,5 @@ /* Bug 23844: Test for pthread_rwlock_trywrlock stalls. - Copyright (C) 2019-2024 Free Software Foundation, Inc. + Copyright (C) 2019-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-rwlock1.c b/sysdeps/pthread/tst-rwlock1.c index 43866e1..7f173bc 100644 --- a/sysdeps/pthread/tst-rwlock1.c +++ b/sysdeps/pthread/tst-rwlock1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-rwlock12.c b/sysdeps/pthread/tst-rwlock12.c index b91765f..1027a6f 100644 --- a/sysdeps/pthread/tst-rwlock12.c +++ b/sysdeps/pthread/tst-rwlock12.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-rwlock13.c b/sysdeps/pthread/tst-rwlock13.c index 1d4e74a..af7e10e 100644 --- a/sysdeps/pthread/tst-rwlock13.c +++ b/sysdeps/pthread/tst-rwlock13.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2024 Free Software Foundation, Inc. +/* Copyright (C) 2004-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-rwlock14.c b/sysdeps/pthread/tst-rwlock14.c index 81c7a1e..e7f4b69 100644 --- a/sysdeps/pthread/tst-rwlock14.c +++ b/sysdeps/pthread/tst-rwlock14.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2024 Free Software Foundation, Inc. +/* Copyright (C) 2004-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-rwlock16.c b/sysdeps/pthread/tst-rwlock16.c index 5ca000e..5a82c29 100644 --- a/sysdeps/pthread/tst-rwlock16.c +++ b/sysdeps/pthread/tst-rwlock16.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2015-2024 Free Software Foundation, Inc. +/* Copyright (C) 2015-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-rwlock4.c b/sysdeps/pthread/tst-rwlock4.c index 569b529..de64ff2 100644 --- a/sysdeps/pthread/tst-rwlock4.c +++ b/sysdeps/pthread/tst-rwlock4.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-rwlock5.c b/sysdeps/pthread/tst-rwlock5.c index b321ebe..99a9a0d 100644 --- a/sysdeps/pthread/tst-rwlock5.c +++ b/sysdeps/pthread/tst-rwlock5.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-sem1.c b/sysdeps/pthread/tst-sem1.c index 86082e5..e9e0a38 100644 --- a/sysdeps/pthread/tst-sem1.c +++ b/sysdeps/pthread/tst-sem1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-sem10.c b/sysdeps/pthread/tst-sem10.c index ece00ed..eb3f8ae 100644 --- a/sysdeps/pthread/tst-sem10.c +++ b/sysdeps/pthread/tst-sem10.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2024 Free Software Foundation, Inc. +/* Copyright (C) 2007-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-sem14.c b/sysdeps/pthread/tst-sem14.c index a6f8a33..7ef1393 100644 --- a/sysdeps/pthread/tst-sem14.c +++ b/sysdeps/pthread/tst-sem14.c @@ -1,5 +1,5 @@ /* Test for sem_post race: bug 14532. - Copyright (C) 2012-2024 Free Software Foundation, Inc. + Copyright (C) 2012-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-sem15.c b/sysdeps/pthread/tst-sem15.c index d2f82dc..9322031 100644 --- a/sysdeps/pthread/tst-sem15.c +++ b/sysdeps/pthread/tst-sem15.c @@ -1,5 +1,5 @@ /* Test for SEM_VALUE_MAX overflow detection: BZ #18434. - Copyright (C) 2015-2024 Free Software Foundation, Inc. + Copyright (C) 2015-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-sem16.c b/sysdeps/pthread/tst-sem16.c index 4e67ae6..fbaaab8 100644 --- a/sysdeps/pthread/tst-sem16.c +++ b/sysdeps/pthread/tst-sem16.c @@ -1,5 +1,5 @@ /* Test for sem_open cancellation handling: BZ #15765. - Copyright (C) 2016-2024 Free Software Foundation, Inc. + Copyright (C) 2016-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-sem18.c b/sysdeps/pthread/tst-sem18.c new file mode 100644 index 0000000..5db91d1 --- /dev/null +++ b/sysdeps/pthread/tst-sem18.c @@ -0,0 +1,35 @@ +/* Test sem_open with missing file. + Copyright (C) 2024-2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <semaphore.h> + +#include <support/check.h> + +int +do_test (void) +{ + sem_unlink ("/glibc-tst-sem18"); + errno = 0; + sem_t *s = sem_open ("/glibc-tst-sem18", 0); + TEST_VERIFY (s == SEM_FAILED); + TEST_COMPARE (errno, ENOENT); + return 0; +} + +#include <support/test-driver.c> diff --git a/sysdeps/pthread/tst-sem19.c b/sysdeps/pthread/tst-sem19.c new file mode 100644 index 0000000..9d79eb1 --- /dev/null +++ b/sysdeps/pthread/tst-sem19.c @@ -0,0 +1,77 @@ +/* Test sem_trywait with threads. + Copyright (C) 2024-2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <pthread.h> +#include <semaphore.h> +#include <support/check.h> +#include <support/xthread.h> + +/* The test uses two threads, the main thread and a newly created + thread to test the operation of sem_trywait in a threaded scenario. + The intent is to test sem_trywait when it would return EAGAIN, and + then again after the critical section in the new thread has posted + to the semaphore and the main thread succeeds in calling + sem_trywait. It is possible this test fails with a timeout if the + second thread takes longer than the test timeout to acquire the + lock, and post. */ + +static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; +static sem_t sem; + +static void * +tf (void *arg) +{ + xpthread_mutex_lock (&lock); + sem_post (&sem); + xpthread_mutex_unlock (&lock); + return NULL; +} + +static int +do_test (void) +{ + int ret; + + ret = sem_init (&sem, 0, 0); + TEST_VERIFY_EXIT (ret == 0); + xpthread_mutex_lock (&lock); + pthread_t th = xpthread_create (NULL, tf, NULL); + errno = 0; + /* The other thread is waiting on the lock before it calls sem_post, + so sem_trywait should fail. */ + ret = sem_trywait (&sem); + TEST_COMPARE (ret, -1); + TEST_COMPARE (errno, EAGAIN); + xpthread_mutex_unlock (&lock); + /* The other thread now takes the lock, calls sem_post and releases + the lock. */ + for (;;) + { + errno = 0; + ret = sem_trywait (&sem); + if (ret == 0) + break; + TEST_COMPARE (errno, EAGAIN); + } + xpthread_join (th); + + return 0; +} + +#include <support/test-driver.c> diff --git a/sysdeps/pthread/tst-sem2.c b/sysdeps/pthread/tst-sem2.c index 2f43e3d..a33f030 100644 --- a/sysdeps/pthread/tst-sem2.c +++ b/sysdeps/pthread/tst-sem2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-sem3.c b/sysdeps/pthread/tst-sem3.c index 6c1d2f5..9908196 100644 --- a/sysdeps/pthread/tst-sem3.c +++ b/sysdeps/pthread/tst-sem3.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-sem4.c b/sysdeps/pthread/tst-sem4.c index 0596b35..7ee5b35 100644 --- a/sysdeps/pthread/tst-sem4.c +++ b/sysdeps/pthread/tst-sem4.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-sem5.c b/sysdeps/pthread/tst-sem5.c index dc2b45e..5eec6ef 100644 --- a/sysdeps/pthread/tst-sem5.c +++ b/sysdeps/pthread/tst-sem5.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-sem6.c b/sysdeps/pthread/tst-sem6.c index a49ed58..22349ce 100644 --- a/sysdeps/pthread/tst-sem6.c +++ b/sysdeps/pthread/tst-sem6.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-sem7.c b/sysdeps/pthread/tst-sem7.c index a989686..6d05835 100644 --- a/sysdeps/pthread/tst-sem7.c +++ b/sysdeps/pthread/tst-sem7.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-sem8.c b/sysdeps/pthread/tst-sem8.c index 0fdabec..1c25555 100644 --- a/sysdeps/pthread/tst-sem8.c +++ b/sysdeps/pthread/tst-sem8.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-sem9.c b/sysdeps/pthread/tst-sem9.c index afa5095..e4b23c8 100644 --- a/sysdeps/pthread/tst-sem9.c +++ b/sysdeps/pthread/tst-sem9.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-setuid3.c b/sysdeps/pthread/tst-setuid3.c index 3845ab0..8d4b937 100644 --- a/sysdeps/pthread/tst-setuid3.c +++ b/sysdeps/pthread/tst-setuid3.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2024 Free Software Foundation, Inc. +/* Copyright (C) 2014-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-signal1.c b/sysdeps/pthread/tst-signal1.c index ca145ee..245a202 100644 --- a/sysdeps/pthread/tst-signal1.c +++ b/sysdeps/pthread/tst-signal1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-signal2.c b/sysdeps/pthread/tst-signal2.c index aeefb0a..8358360 100644 --- a/sysdeps/pthread/tst-signal2.c +++ b/sysdeps/pthread/tst-signal2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-signal4.c b/sysdeps/pthread/tst-signal4.c index a7408b9..ec5f356 100644 --- a/sysdeps/pthread/tst-signal4.c +++ b/sysdeps/pthread/tst-signal4.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-signal5.c b/sysdeps/pthread/tst-signal5.c index 3ad3eff..f9c2986 100644 --- a/sysdeps/pthread/tst-signal5.c +++ b/sysdeps/pthread/tst-signal5.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-signal6.c b/sysdeps/pthread/tst-signal6.c index d0aa68d..ab5538f 100644 --- a/sysdeps/pthread/tst-signal6.c +++ b/sysdeps/pthread/tst-signal6.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-signal8.c b/sysdeps/pthread/tst-signal8.c index 8f48906..4a09016 100644 --- a/sysdeps/pthread/tst-signal8.c +++ b/sysdeps/pthread/tst-signal8.c @@ -1,5 +1,5 @@ /* Tests for sigisemptyset and pthread_sigmask. - Copyright (C) 2020-2024 Free Software Foundation, Inc. + Copyright (C) 2020-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-spin1.c b/sysdeps/pthread/tst-spin1.c index 3a47bb7..5491ede 100644 --- a/sysdeps/pthread/tst-spin1.c +++ b/sysdeps/pthread/tst-spin1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-spin2.c b/sysdeps/pthread/tst-spin2.c index 6fb9850..d665b10 100644 --- a/sysdeps/pthread/tst-spin2.c +++ b/sysdeps/pthread/tst-spin2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-spin3.c b/sysdeps/pthread/tst-spin3.c index 817dac4..3b43370 100644 --- a/sysdeps/pthread/tst-spin3.c +++ b/sysdeps/pthread/tst-spin3.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-spin5.c b/sysdeps/pthread/tst-spin5.c new file mode 100644 index 0000000..afe2b01 --- /dev/null +++ b/sysdeps/pthread/tst-spin5.c @@ -0,0 +1,82 @@ +/* Threaded test the pthread_spin_trylock function. + Copyright (C) 2024-2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <stdio.h> +#include <errno.h> +#include <support/check.h> +#include <support/support.h> +#include <support/xunistd.h> +#include <support/xthread.h> + +pthread_spinlock_t lock; + +void * +thread (void *arg) +{ + int ret; + int thr_id = *(int *) arg; + + ret = pthread_spin_trylock (&lock); + if (thr_id == 1) + /* thread with already acquired lock. */ + { + if (ret != EBUSY) + { + FAIL_EXIT1 ("pthread_spin_trylock should fail with EBUSY"); + } + } + else if (thr_id == 2) + /* thread with released spin lock. */ + { + if (ret != 0) + { + FAIL_EXIT1 ("pthread_spin_trylock should be able to acquire lock"); + } + } + return NULL; +} + +static int +do_test (void) +{ + pthread_t thr1, thr2; + int ret; + int thr1_id = 1, thr2_id = 2; + + pthread_spin_init (&lock, PTHREAD_PROCESS_PRIVATE); + /* lock spin in main thread. */ + ret = pthread_spin_trylock (&lock); + if (ret != 0) + { + FAIL_EXIT1 ("Main thread should be able to acquire spin lock"); + } + + /* create first thread to try locking already acquired spin lock. */ + thr1 = xpthread_create (NULL, thread, &thr1_id); + xpthread_join (thr1); + + /* release spin lock and create thread to acquire released spin lock. */ + pthread_spin_unlock (&lock); + thr2 = xpthread_create (NULL, thread, &thr2_id); + xpthread_join (thr2); + + pthread_spin_destroy (&lock); + return 0; +} + +#include <support/test-driver.c> diff --git a/sysdeps/pthread/tst-stack1.c b/sysdeps/pthread/tst-stack1.c index 574edb3..21989f0 100644 --- a/sysdeps/pthread/tst-stack1.c +++ b/sysdeps/pthread/tst-stack1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-stack2-mod.c b/sysdeps/pthread/tst-stack2-mod.c new file mode 100644 index 0000000..806fdbc --- /dev/null +++ b/sysdeps/pthread/tst-stack2-mod.c @@ -0,0 +1,39 @@ +/* Check if pthread_getattr_np works within modules with non-exectuble + stacks (BZ 32897). + Copyright (C) 2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <pthread.h> + +bool init_result; + +void +__attribute__ ((constructor)) +init (void) +{ + pthread_t me = pthread_self (); + pthread_attr_t attr; + init_result = pthread_getattr_np (me, &attr) == 0; +} + +int +mod_func (void) +{ + pthread_t me = pthread_self (); + pthread_attr_t attr; + return pthread_getattr_np (me, &attr); +} diff --git a/sysdeps/pthread/tst-stack2.c b/sysdeps/pthread/tst-stack2.c new file mode 100644 index 0000000..20ab5af --- /dev/null +++ b/sysdeps/pthread/tst-stack2.c @@ -0,0 +1,47 @@ +/* Check if pthread_getattr_np works within modules with non-exectuble + stacks (BZ 32897). + Copyright (C) 2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <pthread.h> +#include <stdbool.h> +#include <support/xdlfcn.h> +#include <support/check.h> + +static int +do_test (void) +{ + { + pthread_t me = pthread_self (); + pthread_attr_t attr; + TEST_COMPARE (pthread_getattr_np (me, &attr), 0); + } + + void *h = xdlopen ("tst-stack2-mod.so", RTLD_NOW); + + bool *init_result = xdlsym (h, "init_result"); + TEST_COMPARE (*init_result, true); + + int (*mod_func)(void) = xdlsym (h, "mod_func"); + TEST_COMPARE (mod_func (), 0); + + xdlclose (h); + + return 0; +} + +#include <support/test-driver.c> diff --git a/sysdeps/pthread/tst-stdio1.c b/sysdeps/pthread/tst-stdio1.c index 1865956..c43922d 100644 --- a/sysdeps/pthread/tst-stdio1.c +++ b/sysdeps/pthread/tst-stdio1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-stdio2.c b/sysdeps/pthread/tst-stdio2.c index 51b705f..0876ed6 100644 --- a/sysdeps/pthread/tst-stdio2.c +++ b/sysdeps/pthread/tst-stdio2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -75,7 +75,7 @@ do_test (void) exit (1); } - puts ("join returned succsefully"); + puts ("join returned successfully"); return 0; } diff --git a/sysdeps/pthread/tst-thrd-detach.c b/sysdeps/pthread/tst-thrd-detach.c index ae5c272..966e7c1 100644 --- a/sysdeps/pthread/tst-thrd-detach.c +++ b/sysdeps/pthread/tst-thrd-detach.c @@ -1,5 +1,5 @@ /* C11 threads thread detach tests. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-thrd-sleep.c b/sysdeps/pthread/tst-thrd-sleep.c index 1f2fa51..01b0d01 100644 --- a/sysdeps/pthread/tst-thrd-sleep.c +++ b/sysdeps/pthread/tst-thrd-sleep.c @@ -1,5 +1,5 @@ /* C11 threads thread sleep tests. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-timer.c b/sysdeps/pthread/tst-timer.c index 02543a7..b1b2b94 100644 --- a/sysdeps/pthread/tst-timer.c +++ b/sysdeps/pthread/tst-timer.c @@ -1,5 +1,5 @@ /* Tests for POSIX timer implementation. - Copyright (C) 2000-2024 Free Software Foundation, Inc. + Copyright (C) 2000-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-tls4moda.c b/sysdeps/pthread/tst-tls4moda.c index 96976d9..1a40af0 100644 --- a/sysdeps/pthread/tst-tls4moda.c +++ b/sysdeps/pthread/tst-tls4moda.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-tls4modb.c b/sysdeps/pthread/tst-tls4modb.c index 8b27afb..7fac114 100644 --- a/sysdeps/pthread/tst-tls4modb.c +++ b/sysdeps/pthread/tst-tls4modb.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-tsd1.c b/sysdeps/pthread/tst-tsd1.c index c12f1a8..8b6a85c 100644 --- a/sysdeps/pthread/tst-tsd1.c +++ b/sysdeps/pthread/tst-tsd1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-tsd2.c b/sysdeps/pthread/tst-tsd2.c index 631d9c3..22125ff 100644 --- a/sysdeps/pthread/tst-tsd2.c +++ b/sysdeps/pthread/tst-tsd2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2024 Free Software Foundation, Inc. +/* Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-tsd5.c b/sysdeps/pthread/tst-tsd5.c index e182f95..31ff3b5 100644 --- a/sysdeps/pthread/tst-tsd5.c +++ b/sysdeps/pthread/tst-tsd5.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2024 Free Software Foundation, Inc. +/* Copyright (C) 2004-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-tss-basic.c b/sysdeps/pthread/tst-tss-basic.c index cc79a0a..87f67fc 100644 --- a/sysdeps/pthread/tst-tss-basic.c +++ b/sysdeps/pthread/tst-tss-basic.c @@ -1,5 +1,5 @@ /* C11 threads specific storage tests. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-umask1.c b/sysdeps/pthread/tst-umask1.c index 93716e5..7b9a2a5 100644 --- a/sysdeps/pthread/tst-umask1.c +++ b/sysdeps/pthread/tst-umask1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2024 Free Software Foundation, Inc. +/* Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/pthread/tst-unload.c b/sysdeps/pthread/tst-unload.c index 4a9c0f7..9344fd0 100644 --- a/sysdeps/pthread/tst-unload.c +++ b/sysdeps/pthread/tst-unload.c @@ -1,5 +1,5 @@ /* Tests for non-unloading of libpthread. - Copyright (C) 2000-2024 Free Software Foundation, Inc. + Copyright (C) 2000-2025 Free Software Foundation, Inc. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as |