* [hurd,commited 04/10] pthread: Move key tests from nptl to sysdeps/pthread
2020-02-10 1:13 [hurd,commited 01/10] htl: clean __pthread_get_cleanup_stack hidden proto Samuel Thibault
` (4 preceding siblings ...)
2020-02-10 1:05 ` [hurd,commited 03/10] hurd: Make nanosleep a cancellation point Samuel Thibault
@ 2020-02-10 1:05 ` Samuel Thibault
2020-02-10 1:05 ` [hurd,commited 05/10] htl: Add support for semaphore maximum value Samuel Thibault
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Samuel Thibault @ 2020-02-10 1:05 UTC (permalink / raw)
To: libc-alpha; +Cc: Samuel Thibault, commit-hurd
So they can be checked with htl too.
---
nptl/Makefile | 1 -
sysdeps/pthread/Makefile | 1 +
{nptl => sysdeps/pthread}/tst-key1.c | 0
{nptl => sysdeps/pthread}/tst-key2.c | 0
{nptl => sysdeps/pthread}/tst-key3.c | 0
{nptl => sysdeps/pthread}/tst-key4.c | 0
6 files changed, 1 insertion(+), 1 deletion(-)
rename {nptl => sysdeps/pthread}/tst-key1.c (100%)
rename {nptl => sysdeps/pthread}/tst-key2.c (100%)
rename {nptl => sysdeps/pthread}/tst-key3.c (100%)
rename {nptl => sysdeps/pthread}/tst-key4.c (100%)
diff --git a/nptl/Makefile b/nptl/Makefile
index 3ad3024a39..8e53ff6a49 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -249,7 +249,6 @@ tests = tst-attr2 tst-attr3 tst-default-attr \
tst-rwlock9 tst-rwlock10 tst-rwlock11 tst-rwlock12 \
tst-rwlock14 tst-rwlock15 tst-rwlock17 tst-rwlock18 \
tst-once5 \
- tst-key1 tst-key2 tst-key3 tst-key4 \
tst-sem1 tst-sem2 tst-sem3 tst-sem4 tst-sem5 tst-sem6 tst-sem7 \
tst-sem8 tst-sem9 tst-sem10 tst-sem14 \
tst-sem15 tst-sem16 tst-sem17 \
diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile
index cceaa91837..8143eeb1ad 100644
--- a/sysdeps/pthread/Makefile
+++ b/sysdeps/pthread/Makefile
@@ -50,6 +50,7 @@ tests += tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \
tst-cond14 tst-cond15 tst-cond16 tst-cond17 tst-cond18 tst-cond19 \
tst-cond23 tst-cond24 tst-cond25 \
tst-cond-except \
+ tst-key1 tst-key2 tst-key3 tst-key4 \
tst-mutex1 tst-mutex2 tst-mutex3 tst-mutex4 tst-mutex6 tst-mutex10 \
tst-once1 tst-once2 tst-once3 tst-once4 \
tst-rwlock1 tst-rwlock4 tst-rwlock5 tst-rwlock13 tst-rwlock16 \
diff --git a/nptl/tst-key1.c b/sysdeps/pthread/tst-key1.c
similarity index 100%
rename from nptl/tst-key1.c
rename to sysdeps/pthread/tst-key1.c
diff --git a/nptl/tst-key2.c b/sysdeps/pthread/tst-key2.c
similarity index 100%
rename from nptl/tst-key2.c
rename to sysdeps/pthread/tst-key2.c
diff --git a/nptl/tst-key3.c b/sysdeps/pthread/tst-key3.c
similarity index 100%
rename from nptl/tst-key3.c
rename to sysdeps/pthread/tst-key3.c
diff --git a/nptl/tst-key4.c b/sysdeps/pthread/tst-key4.c
similarity index 100%
rename from nptl/tst-key4.c
rename to sysdeps/pthread/tst-key4.c
--
2.24.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [hurd,commited 02/10] htl: Add support for libc cancellation points
2020-02-10 1:13 [hurd,commited 01/10] htl: clean __pthread_get_cleanup_stack hidden proto Samuel Thibault
2020-02-10 1:05 ` [hurd,commited 09/10] htl: Fix barrier_wait with one thread Samuel Thibault
2020-02-10 1:05 ` [hurd,commited 07/10] htl: Make sem_wait/sem_timedwait interruptible Samuel Thibault
@ 2020-02-10 1:05 ` Samuel Thibault
2020-02-10 1:05 ` [hurd,commited 10/10] pthread: Move most barrier tests from nptl to sysdeps/pthread Samuel Thibault
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Samuel Thibault @ 2020-02-10 1:05 UTC (permalink / raw)
To: libc-alpha; +Cc: Samuel Thibault, commit-hurd
---
htl/Makefile | 1 +
htl/Versions | 2 ++
htl/cancellation.c | 45 +++++++++++++++++++++++++++++++
htl/pt-testcancel.c | 3 ++-
sysdeps/htl/pthreadP.h | 1 +
sysdeps/mach/hurd/sysdep-cancel.h | 20 ++++++++++++--
6 files changed, 69 insertions(+), 3 deletions(-)
create mode 100644 htl/cancellation.c
diff --git a/htl/Makefile b/htl/Makefile
index b2dc797ee4..1b33748934 100644
--- a/htl/Makefile
+++ b/htl/Makefile
@@ -132,6 +132,7 @@ libpthread-routines := pt-attr pt-attr-destroy pt-attr-getdetachstate \
\
shm-directory \
\
+ cancellation \
cthreads-compat \
herrno \
$(SYSDEPS)
diff --git a/htl/Versions b/htl/Versions
index 4f5f727753..1ec6f363d5 100644
--- a/htl/Versions
+++ b/htl/Versions
@@ -168,6 +168,8 @@ libpthread {
__pthread_mutex_init;
__pthread_mutex_destroy;
__pthread_mutex_timedlock;
+ __pthread_enable_asynccancel;
+ __pthread_disable_asynccancel;
_pthread_mutex_lock; _pthread_mutex_trylock; _pthread_mutex_unlock;
_pthread_rwlock_destroy; _pthread_rwlock_init;
diff --git a/htl/cancellation.c b/htl/cancellation.c
new file mode 100644
index 0000000000..598f911d91
--- /dev/null
+++ b/htl/cancellation.c
@@ -0,0 +1,45 @@
+/* Set the cancel type during blocking calls.
+ Copyright (C) 2020 Free Software 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 <pthreadP.h>
+#include <pt-internal.h>
+
+int __pthread_enable_asynccancel (void)
+{
+ struct __pthread *p = _pthread_self ();
+ int oldtype;
+
+ __pthread_mutex_lock (&p->cancel_lock);
+ oldtype = p->cancel_type;
+ p->cancel_type = PTHREAD_CANCEL_ASYNCHRONOUS;
+ __pthread_mutex_unlock (&p->cancel_lock);
+
+ __pthread_testcancel ();
+
+ return oldtype;
+}
+
+void __pthread_disable_asynccancel (int oldtype)
+{
+ struct __pthread *p = _pthread_self ();
+
+ __pthread_mutex_lock (&p->cancel_lock);
+ p->cancel_type = oldtype;
+ __pthread_mutex_unlock (&p->cancel_lock);
+}
diff --git a/htl/pt-testcancel.c b/htl/pt-testcancel.c
index 1ec324b95f..37326280ee 100644
--- a/htl/pt-testcancel.c
+++ b/htl/pt-testcancel.c
@@ -22,7 +22,7 @@
#include <pthreadP.h>
void
-pthread_testcancel (void)
+__pthread_testcancel (void)
{
struct __pthread *p = _pthread_self ();
int cancelled;
@@ -34,3 +34,4 @@ pthread_testcancel (void)
if (cancelled)
__pthread_exit (PTHREAD_CANCELED);
}
+strong_alias (__pthread_testcancel, pthread_testcancel)
diff --git a/sysdeps/htl/pthreadP.h b/sysdeps/htl/pthreadP.h
index 7de96120a4..2bb4baa249 100644
--- a/sysdeps/htl/pthreadP.h
+++ b/sysdeps/htl/pthreadP.h
@@ -84,6 +84,7 @@ int __pthread_attr_setstacksize (pthread_attr_t *__attr, size_t __stacksize);
int __pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
size_t __stacksize);
int __pthread_attr_getstack (const pthread_attr_t *, void **, size_t *);
+void __pthread_testcancel (void);
#if IS_IN (libpthread)
hidden_proto (__pthread_key_create)
diff --git a/sysdeps/mach/hurd/sysdep-cancel.h b/sysdeps/mach/hurd/sysdep-cancel.h
index f686a39024..669c17151a 100644
--- a/sysdeps/mach/hurd/sysdep-cancel.h
+++ b/sysdeps/mach/hurd/sysdep-cancel.h
@@ -1,8 +1,24 @@
#include <sysdep.h>
+int __pthread_enable_asynccancel (void);
+void __pthread_disable_asynccancel (int oldtype);
+
+#pragma weak __pthread_enable_asynccancel
+#pragma weak __pthread_disable_asynccancel
+
/* Always multi-thread (since there's at least the sig handler), but no
handling enabled. */
#define SINGLE_THREAD_P (0)
#define RTLD_SINGLE_THREAD_P (0)
-#define LIBC_CANCEL_ASYNC() 0 /* Just a dummy value. */
-#define LIBC_CANCEL_RESET(val) ((void)(val)) /* Nothing, but evaluate it. */
+
+#define LIBC_CANCEL_ASYNC() ({ \
+ int __cancel_oldtype = 0; \
+ if (__pthread_enable_asynccancel) \
+ __cancel_oldtype = __pthread_enable_asynccancel(); \
+ __cancel_oldtype; \
+})
+
+#define LIBC_CANCEL_RESET(val) do { \
+ if (__pthread_disable_asynccancel) \
+ __pthread_disable_asynccancel (val); \
+} while (0)
--
2.24.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [hurd,commited 05/10] htl: Add support for semaphore maximum value
2020-02-10 1:13 [hurd,commited 01/10] htl: clean __pthread_get_cleanup_stack hidden proto Samuel Thibault
` (5 preceding siblings ...)
2020-02-10 1:05 ` [hurd,commited 04/10] pthread: Move key tests from nptl to sysdeps/pthread Samuel Thibault
@ 2020-02-10 1:05 ` Samuel Thibault
2020-02-10 1:13 ` [hurd,commited 06/10] htl: Make sem_open return ENOSYS Samuel Thibault
2020-02-10 1:13 ` [hurd,commited 08/10] pthread: Move most sem tests from nptl to sysdeps/pthread Samuel Thibault
8 siblings, 0 replies; 10+ messages in thread
From: Samuel Thibault @ 2020-02-10 1:05 UTC (permalink / raw)
To: libc-alpha; +Cc: Samuel Thibault, commit-hurd
---
sysdeps/htl/sem-post.c | 7 +++++++
sysdeps/mach/hurd/bits/local_lim.h | 3 +++
2 files changed, 10 insertions(+)
diff --git a/sysdeps/htl/sem-post.c b/sysdeps/htl/sem-post.c
index 77f297314e..2e0be8fc49 100644
--- a/sysdeps/htl/sem-post.c
+++ b/sysdeps/htl/sem-post.c
@@ -30,6 +30,13 @@ __sem_post (sem_t *sem)
if (sem->__value > 0)
/* Do a quick up. */
{
+ if (sem->__value == SEM_VALUE_MAX)
+ {
+ __pthread_spin_unlock (&sem->__lock);
+ errno = EOVERFLOW;
+ return -1;
+ }
+
assert (sem->__queue == NULL);
sem->__value++;
__pthread_spin_unlock (&sem->__lock);
diff --git a/sysdeps/mach/hurd/bits/local_lim.h b/sysdeps/mach/hurd/bits/local_lim.h
index 348eee74bb..8e781e4965 100644
--- a/sysdeps/mach/hurd/bits/local_lim.h
+++ b/sysdeps/mach/hurd/bits/local_lim.h
@@ -41,3 +41,6 @@
/* The number of threads per process. */
#define _POSIX_THREAD_THREADS_MAX 64
+
+/* Maximum value the semaphore can have. */
+#define SEM_VALUE_MAX (2147483647)
--
2.24.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [hurd,commited 09/10] htl: Fix barrier_wait with one thread
2020-02-10 1:13 [hurd,commited 01/10] htl: clean __pthread_get_cleanup_stack hidden proto Samuel Thibault
@ 2020-02-10 1:05 ` Samuel Thibault
2020-02-10 1:05 ` [hurd,commited 07/10] htl: Make sem_wait/sem_timedwait interruptible Samuel Thibault
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Samuel Thibault @ 2020-02-10 1:05 UTC (permalink / raw)
To: libc-alpha; +Cc: Samuel Thibault, commit-hurd
---
sysdeps/htl/pt-barrier-wait.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sysdeps/htl/pt-barrier-wait.c b/sysdeps/htl/pt-barrier-wait.c
index 47ec440b26..146605abd8 100644
--- a/sysdeps/htl/pt-barrier-wait.c
+++ b/sysdeps/htl/pt-barrier-wait.c
@@ -29,7 +29,9 @@ pthread_barrier_wait (pthread_barrier_t *barrier)
{
barrier->__pending = barrier->__count;
- if (barrier->__count > 1)
+ if (barrier->__count == 1)
+ __pthread_spin_unlock (&barrier->__lock);
+ else
{
struct __pthread *wakeup;
unsigned n = 0;
--
2.24.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [hurd,commited 10/10] pthread: Move most barrier tests from nptl to sysdeps/pthread
2020-02-10 1:13 [hurd,commited 01/10] htl: clean __pthread_get_cleanup_stack hidden proto Samuel Thibault
` (2 preceding siblings ...)
2020-02-10 1:05 ` [hurd,commited 02/10] htl: Add support for libc cancellation points Samuel Thibault
@ 2020-02-10 1:05 ` Samuel Thibault
2020-02-10 1:05 ` [hurd,commited 03/10] hurd: Make nanosleep a cancellation point Samuel Thibault
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Samuel Thibault @ 2020-02-10 1:05 UTC (permalink / raw)
To: libc-alpha; +Cc: Samuel Thibault, commit-hurd
So they can be checked with htl too.
---
nptl/Makefile | 1 -
sysdeps/mach/hurd/i386/Makefile | 1 +
sysdeps/pthread/Makefile | 1 +
{nptl => sysdeps/pthread}/tst-barrier1.c | 0
{nptl => sysdeps/pthread}/tst-barrier2.c | 0
{nptl => sysdeps/pthread}/tst-barrier3.c | 0
{nptl => sysdeps/pthread}/tst-barrier4.c | 0
7 files changed, 2 insertions(+), 1 deletion(-)
rename {nptl => sysdeps/pthread}/tst-barrier1.c (100%)
rename {nptl => sysdeps/pthread}/tst-barrier2.c (100%)
rename {nptl => sysdeps/pthread}/tst-barrier3.c (100%)
rename {nptl => sysdeps/pthread}/tst-barrier4.c (100%)
diff --git a/nptl/Makefile b/nptl/Makefile
index 80e293209c..a72022a052 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -250,7 +250,6 @@ tests = tst-attr2 tst-attr3 tst-default-attr \
tst-rwlock14 tst-rwlock15 tst-rwlock17 tst-rwlock18 \
tst-once5 \
tst-sem5 tst-sem17 \
- tst-barrier1 tst-barrier2 tst-barrier3 tst-barrier4 \
tst-align tst-align3 \
tst-kill1 tst-kill2 tst-kill3 tst-kill4 tst-kill5 tst-kill6 \
tst-raise1 \
diff --git a/sysdeps/mach/hurd/i386/Makefile b/sysdeps/mach/hurd/i386/Makefile
index a5ccab0956..445724f85f 100644
--- a/sysdeps/mach/hurd/i386/Makefile
+++ b/sysdeps/mach/hurd/i386/Makefile
@@ -112,6 +112,7 @@ test-xfail-tst-cond23 = yes
test-xfail-tst-rwlock4 = yes
test-xfail-tst-rwlock12 = yes
test-xfail-tst-sem3 = yes
+test-xfail-tst-barrier2 = yes
endif
# For bug 25522
diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile
index 2f07c0cfe6..c102f45b6a 100644
--- a/sysdeps/pthread/Makefile
+++ b/sysdeps/pthread/Makefile
@@ -43,6 +43,7 @@ tests += tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \
tst-cnd-timedwait tst-thrd-detach tst-mtx-basic tst-thrd-sleep \
tst-mtx-recursive tst-tss-basic tst-call-once tst-mtx-timedlock \
tst-attr1 \
+ tst-barrier1 tst-barrier2 tst-barrier3 tst-barrier4 \
tst-basic1 tst-basic2 tst-basic3 tst-basic4 tst-basic5 tst-basic6 \
tst-basic7 \
tst-cond1 tst-cond2 tst-cond3 tst-cond4 tst-cond5 tst-cond6 tst-cond7 \
diff --git a/nptl/tst-barrier1.c b/sysdeps/pthread/tst-barrier1.c
similarity index 100%
rename from nptl/tst-barrier1.c
rename to sysdeps/pthread/tst-barrier1.c
diff --git a/nptl/tst-barrier2.c b/sysdeps/pthread/tst-barrier2.c
similarity index 100%
rename from nptl/tst-barrier2.c
rename to sysdeps/pthread/tst-barrier2.c
diff --git a/nptl/tst-barrier3.c b/sysdeps/pthread/tst-barrier3.c
similarity index 100%
rename from nptl/tst-barrier3.c
rename to sysdeps/pthread/tst-barrier3.c
diff --git a/nptl/tst-barrier4.c b/sysdeps/pthread/tst-barrier4.c
similarity index 100%
rename from nptl/tst-barrier4.c
rename to sysdeps/pthread/tst-barrier4.c
--
2.24.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [hurd,commited 03/10] hurd: Make nanosleep a cancellation point
2020-02-10 1:13 [hurd,commited 01/10] htl: clean __pthread_get_cleanup_stack hidden proto Samuel Thibault
` (3 preceding siblings ...)
2020-02-10 1:05 ` [hurd,commited 10/10] pthread: Move most barrier tests from nptl to sysdeps/pthread Samuel Thibault
@ 2020-02-10 1:05 ` Samuel Thibault
2020-02-10 1:05 ` [hurd,commited 04/10] pthread: Move key tests from nptl to sysdeps/pthread Samuel Thibault
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Samuel Thibault @ 2020-02-10 1:05 UTC (permalink / raw)
To: libc-alpha; +Cc: Samuel Thibault, commit-hurd
---
sysdeps/mach/clock_nanosleep.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/sysdeps/mach/clock_nanosleep.c b/sysdeps/mach/clock_nanosleep.c
index ae9335cb2b..23ebc15274 100644
--- a/sysdeps/mach/clock_nanosleep.c
+++ b/sysdeps/mach/clock_nanosleep.c
@@ -22,6 +22,7 @@
#include <unistd.h>
#include <posix-timer.h>
#include <shlib-compat.h>
+#include <sysdep-cancel.h>
static int
nanosleep_call (const struct timespec *req, struct timespec *rem)
@@ -39,9 +40,13 @@ nanosleep_call (const struct timespec *req, struct timespec *rem)
if (rem != NULL)
__clock_gettime (CLOCK_REALTIME, &before);
+ int cancel_oldtype = LIBC_CANCEL_ASYNC();
err = __mach_msg (NULL, MACH_RCV_MSG|MACH_RCV_TIMEOUT|MACH_RCV_INTERRUPT,
0, 0, recv, ms, MACH_PORT_NULL);
+ LIBC_CANCEL_RESET (cancel_oldtype);
+
__mach_port_destroy (mach_task_self (), recv);
+
if (err == EMACH_RCV_INTERRUPTED)
{
if (rem != NULL)
--
2.24.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [hurd,commited 07/10] htl: Make sem_wait/sem_timedwait interruptible
2020-02-10 1:13 [hurd,commited 01/10] htl: clean __pthread_get_cleanup_stack hidden proto Samuel Thibault
2020-02-10 1:05 ` [hurd,commited 09/10] htl: Fix barrier_wait with one thread Samuel Thibault
@ 2020-02-10 1:05 ` Samuel Thibault
2020-02-10 1:05 ` [hurd,commited 02/10] htl: Add support for libc cancellation points Samuel Thibault
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Samuel Thibault @ 2020-02-10 1:05 UTC (permalink / raw)
To: libc-alpha; +Cc: Samuel Thibault, commit-hurd
---
htl/Makefile | 2 ++
htl/pt-internal.h | 8 ++++++++
sysdeps/htl/sem-timedwait.c | 10 ++++------
sysdeps/mach/htl/pt-block-intr.c | 6 ++++++
sysdeps/mach/htl/pt-block.c | 19 +++++++++++++++++--
sysdeps/mach/htl/pt-timedblock-intr.c | 3 +++
sysdeps/mach/htl/pt-timedblock.c | 8 +++++++-
7 files changed, 47 insertions(+), 9 deletions(-)
create mode 100644 sysdeps/mach/htl/pt-block-intr.c
create mode 100644 sysdeps/mach/htl/pt-timedblock-intr.c
diff --git a/htl/Makefile b/htl/Makefile
index 1b33748934..39294c64d1 100644
--- a/htl/Makefile
+++ b/htl/Makefile
@@ -108,6 +108,8 @@ libpthread-routines := pt-attr pt-attr-destroy pt-attr-getdetachstate \
\
pt-block \
pt-timedblock \
+ pt-block-intr \
+ pt-timedblock-intr \
pt-wakeup \
pt-docancel \
pt-sysdep \
diff --git a/htl/pt-internal.h b/htl/pt-internal.h
index 8ffe1bd970..918c207c3e 100644
--- a/htl/pt-internal.h
+++ b/htl/pt-internal.h
@@ -270,6 +270,14 @@ extern error_t __pthread_timedblock (struct __pthread *__restrict thread,
const struct timespec *__restrict abstime,
clockid_t clock_id);
+/* Block THREAD with interrupts. */
+extern error_t __pthread_block_intr (struct __pthread *thread);
+
+/* Block THREAD until *ABSTIME is reached, with interrupts. */
+extern error_t __pthread_timedblock_intr (struct __pthread *__restrict thread,
+ const struct timespec *__restrict abstime,
+ clockid_t clock_id);
+
/* Wakeup THREAD. */
extern void __pthread_wakeup (struct __pthread *thread);
diff --git a/sysdeps/htl/sem-timedwait.c b/sysdeps/htl/sem-timedwait.c
index 656da41184..a61acfd43f 100644
--- a/sysdeps/htl/sem-timedwait.c
+++ b/sysdeps/htl/sem-timedwait.c
@@ -30,6 +30,7 @@ __sem_timedwait_internal (sem_t *restrict sem,
error_t err;
int drain;
struct __pthread *self;
+ clockid_t clock_id = CLOCK_REALTIME;
__pthread_spin_lock (&sem->__lock);
if (sem->__value > 0)
@@ -54,12 +55,9 @@ __sem_timedwait_internal (sem_t *restrict sem,
/* Block the thread. */
if (timeout != NULL)
- err = __pthread_timedblock (self, timeout, CLOCK_REALTIME);
+ err = __pthread_timedblock_intr (self, timeout, clock_id);
else
- {
- err = 0;
- __pthread_block (self);
- }
+ err = __pthread_block_intr (self);
__pthread_spin_lock (&sem->__lock);
if (self->prevp == NULL)
@@ -82,7 +80,7 @@ __sem_timedwait_internal (sem_t *restrict sem,
if (err)
{
- assert (err == ETIMEDOUT);
+ assert (err == ETIMEDOUT || err == EINTR);
errno = err;
return -1;
}
diff --git a/sysdeps/mach/htl/pt-block-intr.c b/sysdeps/mach/htl/pt-block-intr.c
new file mode 100644
index 0000000000..f15beb3a0f
--- /dev/null
+++ b/sysdeps/mach/htl/pt-block-intr.c
@@ -0,0 +1,6 @@
+#include <pt-internal.h>
+#define RETTYPE error_t
+#define RETURN(val) return val
+#define __pthread_block __pthread_block_intr
+#define MSG_OPTIONS MACH_RCV_INTERRUPT
+#include "pt-block.c"
diff --git a/sysdeps/mach/htl/pt-block.c b/sysdeps/mach/htl/pt-block.c
index e1500dce33..28bae157d1 100644
--- a/sysdeps/mach/htl/pt-block.c
+++ b/sysdeps/mach/htl/pt-block.c
@@ -24,15 +24,30 @@
#include <pt-internal.h>
+#ifndef MSG_OPTIONS
+# define MSG_OPTIONS 0
+#endif
+
+#ifndef RETTYPE
+# define RETTYPE void
+#endif
+
+#ifndef RETURN
+# define RETURN(val)
+#endif
+
/* Block THREAD. */
-void
+RETTYPE
__pthread_block (struct __pthread *thread)
{
mach_msg_header_t msg;
error_t err;
- err = __mach_msg (&msg, MACH_RCV_MSG, 0, sizeof msg,
+ err = __mach_msg (&msg, MACH_RCV_MSG | MSG_OPTIONS, 0, sizeof msg,
thread->wakeupmsg.msgh_remote_port,
MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
+ if ((MSG_OPTIONS & MACH_RCV_INTERRUPT) && err == MACH_RCV_INTERRUPTED)
+ RETURN(EINTR);
assert_perror (err);
+ RETURN(0);
}
diff --git a/sysdeps/mach/htl/pt-timedblock-intr.c b/sysdeps/mach/htl/pt-timedblock-intr.c
new file mode 100644
index 0000000000..70e132716b
--- /dev/null
+++ b/sysdeps/mach/htl/pt-timedblock-intr.c
@@ -0,0 +1,3 @@
+#define __pthread_timedblock __pthread_timedblock_intr
+#define MSG_OPTIONS MACH_RCV_INTERRUPT
+#include "pt-timedblock.c"
diff --git a/sysdeps/mach/htl/pt-timedblock.c b/sysdeps/mach/htl/pt-timedblock.c
index 63af869c90..ead070e397 100644
--- a/sysdeps/mach/htl/pt-timedblock.c
+++ b/sysdeps/mach/htl/pt-timedblock.c
@@ -26,6 +26,10 @@
#include <pt-internal.h>
+#ifndef MSG_OPTIONS
+# define MSG_OPTIONS 0
+#endif
+
/* Block THREAD. */
error_t
__pthread_timedblock (struct __pthread *thread,
@@ -54,11 +58,13 @@ __pthread_timedblock (struct __pthread *thread,
/* Need to do a carry. */
timeout -= (now.tv_nsec - abstime->tv_nsec + 999999) / 1000000;
- err = __mach_msg (&msg, MACH_RCV_MSG | MACH_RCV_TIMEOUT, 0,
+ err = __mach_msg (&msg, MACH_RCV_MSG | MACH_RCV_TIMEOUT | MSG_OPTIONS, 0,
sizeof msg, thread->wakeupmsg.msgh_remote_port,
timeout, MACH_PORT_NULL);
if (err == EMACH_RCV_TIMED_OUT)
return ETIMEDOUT;
+ if ((MSG_OPTIONS & MACH_RCV_INTERRUPT) && err == MACH_RCV_INTERRUPTED)
+ return EINTR;
assert_perror (err);
return 0;
--
2.24.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [hurd,commited 08/10] pthread: Move most sem tests from nptl to sysdeps/pthread
2020-02-10 1:13 [hurd,commited 01/10] htl: clean __pthread_get_cleanup_stack hidden proto Samuel Thibault
` (7 preceding siblings ...)
2020-02-10 1:13 ` [hurd,commited 06/10] htl: Make sem_open return ENOSYS Samuel Thibault
@ 2020-02-10 1:13 ` Samuel Thibault
8 siblings, 0 replies; 10+ messages in thread
From: Samuel Thibault @ 2020-02-10 1:13 UTC (permalink / raw)
To: libc-alpha; +Cc: Samuel Thibault, commit-hurd
So they can be checked with htl too.
---
nptl/Makefile | 4 +---
sysdeps/mach/hurd/i386/Makefile | 9 +++++++++
sysdeps/pthread/Makefile | 2 ++
{nptl => sysdeps/pthread}/tst-sem1.c | 0
{nptl => sysdeps/pthread}/tst-sem10.c | 0
{nptl => sysdeps/pthread}/tst-sem14.c | 0
{nptl => sysdeps/pthread}/tst-sem15.c | 0
{nptl => sysdeps/pthread}/tst-sem16.c | 0
{nptl => sysdeps/pthread}/tst-sem2.c | 0
{nptl => sysdeps/pthread}/tst-sem3.c | 0
{nptl => sysdeps/pthread}/tst-sem4.c | 0
{nptl => sysdeps/pthread}/tst-sem6.c | 0
{nptl => sysdeps/pthread}/tst-sem7.c | 0
{nptl => sysdeps/pthread}/tst-sem8.c | 0
{nptl => sysdeps/pthread}/tst-sem9.c | 0
15 files changed, 12 insertions(+), 3 deletions(-)
rename {nptl => sysdeps/pthread}/tst-sem1.c (100%)
rename {nptl => sysdeps/pthread}/tst-sem10.c (100%)
rename {nptl => sysdeps/pthread}/tst-sem14.c (100%)
rename {nptl => sysdeps/pthread}/tst-sem15.c (100%)
rename {nptl => sysdeps/pthread}/tst-sem16.c (100%)
rename {nptl => sysdeps/pthread}/tst-sem2.c (100%)
rename {nptl => sysdeps/pthread}/tst-sem3.c (100%)
rename {nptl => sysdeps/pthread}/tst-sem4.c (100%)
rename {nptl => sysdeps/pthread}/tst-sem6.c (100%)
rename {nptl => sysdeps/pthread}/tst-sem7.c (100%)
rename {nptl => sysdeps/pthread}/tst-sem8.c (100%)
rename {nptl => sysdeps/pthread}/tst-sem9.c (100%)
diff --git a/nptl/Makefile b/nptl/Makefile
index 8e53ff6a49..80e293209c 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -249,9 +249,7 @@ tests = tst-attr2 tst-attr3 tst-default-attr \
tst-rwlock9 tst-rwlock10 tst-rwlock11 tst-rwlock12 \
tst-rwlock14 tst-rwlock15 tst-rwlock17 tst-rwlock18 \
tst-once5 \
- tst-sem1 tst-sem2 tst-sem3 tst-sem4 tst-sem5 tst-sem6 tst-sem7 \
- tst-sem8 tst-sem9 tst-sem10 tst-sem14 \
- tst-sem15 tst-sem16 tst-sem17 \
+ tst-sem5 tst-sem17 \
tst-barrier1 tst-barrier2 tst-barrier3 tst-barrier4 \
tst-align tst-align3 \
tst-kill1 tst-kill2 tst-kill3 tst-kill4 tst-kill5 tst-kill6 \
diff --git a/sysdeps/mach/hurd/i386/Makefile b/sysdeps/mach/hurd/i386/Makefile
index e303945b2a..a5ccab0956 100644
--- a/sysdeps/mach/hurd/i386/Makefile
+++ b/sysdeps/mach/hurd/i386/Makefile
@@ -111,6 +111,7 @@ test-xfail-tst-cond13 = yes
test-xfail-tst-cond23 = yes
test-xfail-tst-rwlock4 = yes
test-xfail-tst-rwlock12 = yes
+test-xfail-tst-sem3 = yes
endif
# For bug 25522
@@ -119,6 +120,14 @@ test-xfail-tst-cond24 = yes
test-xfail-tst-cond25 = yes
endif
+# For bug 25524
+ifeq ($(subdir),htl)
+test-xfail-tst-sem4 = yes
+test-xfail-tst-sem7 = yes
+test-xfail-tst-sem8 = yes
+test-xfail-tst-sem9 = yes
+endif
+
ifeq ($(subdir),elf)
# We do use nested functions involving creation of trampolines, notably for
# callbacks whose parameters don't permit to get the context parameters.
diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile
index 8143eeb1ad..2f07c0cfe6 100644
--- a/sysdeps/pthread/Makefile
+++ b/sysdeps/pthread/Makefile
@@ -55,6 +55,8 @@ tests += tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \
tst-once1 tst-once2 tst-once3 tst-once4 \
tst-rwlock1 tst-rwlock4 tst-rwlock5 tst-rwlock13 tst-rwlock16 \
tst-rwlock-tryrdlock-stall tst-rwlock-trywrlock-stall \
+ tst-sem1 tst-sem2 tst-sem3 tst-sem4 tst-sem6 tst-sem7 \
+ tst-sem8 tst-sem9 tst-sem10 tst-sem14 tst-sem15 tst-sem16 \
tst-spin1 tst-spin2 tst-spin3 tst-spin4
tests += tst-oncex3 tst-oncex4
diff --git a/nptl/tst-sem1.c b/sysdeps/pthread/tst-sem1.c
similarity index 100%
rename from nptl/tst-sem1.c
rename to sysdeps/pthread/tst-sem1.c
diff --git a/nptl/tst-sem10.c b/sysdeps/pthread/tst-sem10.c
similarity index 100%
rename from nptl/tst-sem10.c
rename to sysdeps/pthread/tst-sem10.c
diff --git a/nptl/tst-sem14.c b/sysdeps/pthread/tst-sem14.c
similarity index 100%
rename from nptl/tst-sem14.c
rename to sysdeps/pthread/tst-sem14.c
diff --git a/nptl/tst-sem15.c b/sysdeps/pthread/tst-sem15.c
similarity index 100%
rename from nptl/tst-sem15.c
rename to sysdeps/pthread/tst-sem15.c
diff --git a/nptl/tst-sem16.c b/sysdeps/pthread/tst-sem16.c
similarity index 100%
rename from nptl/tst-sem16.c
rename to sysdeps/pthread/tst-sem16.c
diff --git a/nptl/tst-sem2.c b/sysdeps/pthread/tst-sem2.c
similarity index 100%
rename from nptl/tst-sem2.c
rename to sysdeps/pthread/tst-sem2.c
diff --git a/nptl/tst-sem3.c b/sysdeps/pthread/tst-sem3.c
similarity index 100%
rename from nptl/tst-sem3.c
rename to sysdeps/pthread/tst-sem3.c
diff --git a/nptl/tst-sem4.c b/sysdeps/pthread/tst-sem4.c
similarity index 100%
rename from nptl/tst-sem4.c
rename to sysdeps/pthread/tst-sem4.c
diff --git a/nptl/tst-sem6.c b/sysdeps/pthread/tst-sem6.c
similarity index 100%
rename from nptl/tst-sem6.c
rename to sysdeps/pthread/tst-sem6.c
diff --git a/nptl/tst-sem7.c b/sysdeps/pthread/tst-sem7.c
similarity index 100%
rename from nptl/tst-sem7.c
rename to sysdeps/pthread/tst-sem7.c
diff --git a/nptl/tst-sem8.c b/sysdeps/pthread/tst-sem8.c
similarity index 100%
rename from nptl/tst-sem8.c
rename to sysdeps/pthread/tst-sem8.c
diff --git a/nptl/tst-sem9.c b/sysdeps/pthread/tst-sem9.c
similarity index 100%
rename from nptl/tst-sem9.c
rename to sysdeps/pthread/tst-sem9.c
--
2.24.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [hurd,commited 01/10] htl: clean __pthread_get_cleanup_stack hidden proto
@ 2020-02-10 1:13 Samuel Thibault
2020-02-10 1:05 ` [hurd,commited 09/10] htl: Fix barrier_wait with one thread Samuel Thibault
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: Samuel Thibault @ 2020-02-10 1:13 UTC (permalink / raw)
To: libc-alpha; +Cc: Samuel Thibault, commit-hurd
---
htl/pt-cleanup.c | 4 ++--
htl/pt-exit.c | 2 +-
htl/pt-join.c | 2 --
sysdeps/htl/pthreadP.h | 2 +-
4 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/htl/pt-cleanup.c b/htl/pt-cleanup.c
index 3f5f43f253..a9a7c95847 100644
--- a/htl/pt-cleanup.c
+++ b/htl/pt-cleanup.c
@@ -21,8 +21,8 @@
#include <pt-internal.h>
struct __pthread_cancelation_handler **
-___pthread_get_cleanup_stack (void)
+__pthread_get_cleanup_stack (void)
{
return &_pthread_self ()->cancelation_handlers;
}
-strong_alias (___pthread_get_cleanup_stack, __pthread_get_cleanup_stack)
+hidden_def(__pthread_get_cleanup_stack)
diff --git a/htl/pt-exit.c b/htl/pt-exit.c
index 9a4db2da51..94e3cd9dc0 100644
--- a/htl/pt-exit.c
+++ b/htl/pt-exit.c
@@ -41,7 +41,7 @@ __pthread_exit (void *status)
disabled. */
__pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &oldstate);
- for (handlers = ___pthread_get_cleanup_stack ();
+ for (handlers = __pthread_get_cleanup_stack ();
*handlers != NULL;
*handlers = (*handlers)->__next)
(*handlers)->__handler ((*handlers)->__arg);
diff --git a/htl/pt-join.c b/htl/pt-join.c
index b141c4c8b9..43878a3d52 100644
--- a/htl/pt-join.c
+++ b/htl/pt-join.c
@@ -22,8 +22,6 @@
#include <pt-internal.h>
-#define __pthread_get_cleanup_stack ___pthread_get_cleanup_stack
-
/* Make calling thread wait for termination of thread THREAD. Return
the exit status of the thread in *STATUS. */
int
diff --git a/sysdeps/htl/pthreadP.h b/sysdeps/htl/pthreadP.h
index fd1e697e39..7de96120a4 100644
--- a/sysdeps/htl/pthreadP.h
+++ b/sysdeps/htl/pthreadP.h
@@ -84,7 +84,6 @@ int __pthread_attr_setstacksize (pthread_attr_t *__attr, size_t __stacksize);
int __pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
size_t __stacksize);
int __pthread_attr_getstack (const pthread_attr_t *, void **, size_t *);
-struct __pthread_cancelation_handler **___pthread_get_cleanup_stack (void) attribute_hidden;
#if IS_IN (libpthread)
hidden_proto (__pthread_key_create)
@@ -93,6 +92,7 @@ hidden_proto (__pthread_setspecific)
hidden_proto (__pthread_mutex_init)
hidden_proto (__pthread_mutex_destroy)
hidden_proto (__pthread_mutex_timedlock)
+hidden_proto (__pthread_get_cleanup_stack)
#endif
#define ASSERT_TYPE_SIZE(type, size) \
--
2.24.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [hurd,commited 06/10] htl: Make sem_open return ENOSYS
2020-02-10 1:13 [hurd,commited 01/10] htl: clean __pthread_get_cleanup_stack hidden proto Samuel Thibault
` (6 preceding siblings ...)
2020-02-10 1:05 ` [hurd,commited 05/10] htl: Add support for semaphore maximum value Samuel Thibault
@ 2020-02-10 1:13 ` Samuel Thibault
2020-02-10 1:13 ` [hurd,commited 08/10] pthread: Move most sem tests from nptl to sysdeps/pthread Samuel Thibault
8 siblings, 0 replies; 10+ messages in thread
From: Samuel Thibault @ 2020-02-10 1:13 UTC (permalink / raw)
To: libc-alpha; +Cc: Samuel Thibault, commit-hurd
instead of EOPNOTSUPP, which is for sockets.
---
sysdeps/htl/sem-open.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sysdeps/htl/sem-open.c b/sysdeps/htl/sem-open.c
index 28483ef6a5..682f0e1a88 100644
--- a/sysdeps/htl/sem-open.c
+++ b/sysdeps/htl/sem-open.c
@@ -24,7 +24,7 @@
sem_t *
__sem_open (const char *name, int open_flags, ...)
{
- errno = EOPNOTSUPP;
+ errno = ENOSYS;
return SEM_FAILED;
}
--
2.24.1
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2020-02-10 1:13 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-10 1:13 [hurd,commited 01/10] htl: clean __pthread_get_cleanup_stack hidden proto Samuel Thibault
2020-02-10 1:05 ` [hurd,commited 09/10] htl: Fix barrier_wait with one thread Samuel Thibault
2020-02-10 1:05 ` [hurd,commited 07/10] htl: Make sem_wait/sem_timedwait interruptible Samuel Thibault
2020-02-10 1:05 ` [hurd,commited 02/10] htl: Add support for libc cancellation points Samuel Thibault
2020-02-10 1:05 ` [hurd,commited 10/10] pthread: Move most barrier tests from nptl to sysdeps/pthread Samuel Thibault
2020-02-10 1:05 ` [hurd,commited 03/10] hurd: Make nanosleep a cancellation point Samuel Thibault
2020-02-10 1:05 ` [hurd,commited 04/10] pthread: Move key tests from nptl to sysdeps/pthread Samuel Thibault
2020-02-10 1:05 ` [hurd,commited 05/10] htl: Add support for semaphore maximum value Samuel Thibault
2020-02-10 1:13 ` [hurd,commited 06/10] htl: Make sem_open return ENOSYS Samuel Thibault
2020-02-10 1:13 ` [hurd,commited 08/10] pthread: Move most sem tests from nptl to sysdeps/pthread Samuel Thibault
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).