* [PATCH v2 1/2] support: Add xpthread_cond_signal wrapper
@ 2022-09-30 12:19 Yu Chien Peter Lin
2022-09-30 12:19 ` [PATCH v2 2/2] nptl: Convert tst-setuid2 to test-driver Yu Chien Peter Lin
2022-09-30 14:09 ` [PATCH v2 1/2] support: Add xpthread_cond_signal wrapper Adhemerval Zanella Netto
0 siblings, 2 replies; 4+ messages in thread
From: Yu Chien Peter Lin @ 2022-09-30 12:19 UTC (permalink / raw)
To: libc-alpha; +Cc: alankao, ycliang, fw, dylan, Yu Chien Peter Lin
Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
---
support/Makefile | 1 +
support/xpthread_cond_signal.c | 26 ++++++++++++++++++++++++++
support/xthread.h | 1 +
3 files changed, 28 insertions(+)
create mode 100644 support/xpthread_cond_signal.c
diff --git a/support/Makefile b/support/Makefile
index 551d02941f..4046b12fbd 100644
--- a/support/Makefile
+++ b/support/Makefile
@@ -159,6 +159,7 @@ libsupport-routines = \
xpthread_cancel \
xpthread_check_return \
xpthread_cond_wait \
+ xpthread_cond_signal \
xpthread_create \
xpthread_detach \
xpthread_join \
diff --git a/support/xpthread_cond_signal.c b/support/xpthread_cond_signal.c
new file mode 100644
index 0000000000..ed0be1a8ab
--- /dev/null
+++ b/support/xpthread_cond_signal.c
@@ -0,0 +1,26 @@
+/* pthread_cond_signal with error checking.
+ Copyright (C) 2022 Free Software 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 <support/xthread.h>
+
+void
+xpthread_cond_signal (pthread_cond_t *cond)
+{
+ xpthread_check_return
+ ("pthread_cond_signal", pthread_cond_signal (cond));
+}
diff --git a/support/xthread.h b/support/xthread.h
index af06715f46..ae09649325 100644
--- a/support/xthread.h
+++ b/support/xthread.h
@@ -62,6 +62,7 @@ void xpthread_mutex_consistent (pthread_mutex_t *);
void xpthread_spin_lock (pthread_spinlock_t *lock);
void xpthread_spin_unlock (pthread_spinlock_t *lock);
void xpthread_cond_wait (pthread_cond_t * cond, pthread_mutex_t * mutex);
+void xpthread_cond_signal (pthread_cond_t *cond);
pthread_t xpthread_create (pthread_attr_t *attr,
void *(*thread_func) (void *), void *closure);
void xpthread_detach (pthread_t thr);
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] nptl: Convert tst-setuid2 to test-driver
2022-09-30 12:19 [PATCH v2 1/2] support: Add xpthread_cond_signal wrapper Yu Chien Peter Lin
@ 2022-09-30 12:19 ` Yu Chien Peter Lin
2022-09-30 14:10 ` Adhemerval Zanella Netto
2022-09-30 14:09 ` [PATCH v2 1/2] support: Add xpthread_cond_signal wrapper Adhemerval Zanella Netto
1 sibling, 1 reply; 4+ messages in thread
From: Yu Chien Peter Lin @ 2022-09-30 12:19 UTC (permalink / raw)
To: libc-alpha; +Cc: alankao, ycliang, fw, dylan, Yu Chien Peter Lin
Use <support/test-driver.c> and replace pthread calls to its xpthread
equivalents.
Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
---
nptl/tst-setuid2.c | 52 +++++++++++++---------------------------------
1 file changed, 15 insertions(+), 37 deletions(-)
diff --git a/nptl/tst-setuid2.c b/nptl/tst-setuid2.c
index aff3b1a97d..9b7799991c 100644
--- a/nptl/tst-setuid2.c
+++ b/nptl/tst-setuid2.c
@@ -20,6 +20,7 @@
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
+#include <support/xthread.h>
#include <sys/syscall.h>
#include <unistd.h>
@@ -36,30 +37,21 @@ static pthread_cond_t cond_recv;
static void *
thread_func (void *ctx __attribute__ ((unused)))
{
- int ret = pthread_mutex_lock (&mutex);
- if (ret != 0)
- FAIL ("pthread_mutex_lock (thread): %d", ret);
-
+ xpthread_mutex_lock (&mutex);
while (true)
{
if (func_sent != NULL)
{
void (*func) (void) = func_sent;
- ret = pthread_mutex_unlock (&mutex);
- if (ret != 0)
- FAIL ("pthread_mutex_unlock (thread): %d", ret);
+ xpthread_mutex_unlock (&mutex);
+
func ();
- ret = pthread_mutex_lock (&mutex);
- if (ret != 0)
- FAIL ("pthread_mutex_lock (thread): %d", ret);
+
+ xpthread_mutex_lock (&mutex);
func_sent = NULL;
- ret = pthread_cond_signal (&cond_recv);
- if (ret != 0)
- FAIL ("pthread_cond_signal (recv): %d", ret);
+ xpthread_cond_signal (&cond_recv);
}
- ret = pthread_cond_wait (&cond_send, &mutex);
- if (ret != 0)
- FAIL ("pthread_cond_wait (send): %d", ret);
+ xpthread_cond_wait (&cond_send, &mutex);
}
return NULL;
}
@@ -67,31 +59,18 @@ thread_func (void *ctx __attribute__ ((unused)))
static void
run_on_thread (void (*func) (void))
{
- int ret = pthread_mutex_lock (&mutex);
- if (ret != 0)
- FAIL ("pthread_mutex_lock (%s): %d", __func__, ret);
+ xpthread_mutex_lock (&mutex);
func_sent = func;
- ret = pthread_mutex_unlock (&mutex);
- if (ret != 0)
- FAIL ("pthread_mutex_unlock (%s): %d", __func__, ret);
+ xpthread_mutex_unlock (&mutex);
- ret = pthread_cond_signal (&cond_send);
- if (ret != 0)
- FAIL ("pthread_mutex_lock (%s): %d", __func__, ret);
-
- ret = pthread_mutex_lock (&mutex);
- if (ret != 0)
- FAIL ("pthread_mutex_lock (%s): %d", __func__, ret);
+ xpthread_cond_signal (&cond_send);
+ xpthread_mutex_lock (&mutex);
while (func_sent != NULL)
{
- ret = pthread_cond_wait (&cond_recv, &mutex);
- if (ret != 0)
- FAIL ("pthread_mutex_wait (%s): %d", __func__, ret);
+ xpthread_cond_wait (&cond_recv, &mutex);
}
- ret = pthread_mutex_unlock (&mutex);
- if (ret != 0)
- FAIL ("pthread_mutex_unlock (%s): %d", __func__, ret);
+ xpthread_mutex_unlock (&mutex);
}
static void
@@ -141,5 +120,4 @@ do_test (void)
return 0;
}
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/2] support: Add xpthread_cond_signal wrapper
2022-09-30 12:19 [PATCH v2 1/2] support: Add xpthread_cond_signal wrapper Yu Chien Peter Lin
2022-09-30 12:19 ` [PATCH v2 2/2] nptl: Convert tst-setuid2 to test-driver Yu Chien Peter Lin
@ 2022-09-30 14:09 ` Adhemerval Zanella Netto
1 sibling, 0 replies; 4+ messages in thread
From: Adhemerval Zanella Netto @ 2022-09-30 14:09 UTC (permalink / raw)
To: Yu Chien Peter Lin, libc-alpha; +Cc: fw, ycliang, dylan, alankao
LGTM, thanks.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
On 30/09/22 09:19, Yu Chien Peter Lin wrote:
> Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
> ---
> support/Makefile | 1 +
> support/xpthread_cond_signal.c | 26 ++++++++++++++++++++++++++
> support/xthread.h | 1 +
> 3 files changed, 28 insertions(+)
> create mode 100644 support/xpthread_cond_signal.c
>
> diff --git a/support/Makefile b/support/Makefile
> index 551d02941f..4046b12fbd 100644
> --- a/support/Makefile
> +++ b/support/Makefile
> @@ -159,6 +159,7 @@ libsupport-routines = \
> xpthread_cancel \
> xpthread_check_return \
> xpthread_cond_wait \
> + xpthread_cond_signal \
> xpthread_create \
> xpthread_detach \
> xpthread_join \
> diff --git a/support/xpthread_cond_signal.c b/support/xpthread_cond_signal.c
> new file mode 100644
> index 0000000000..ed0be1a8ab
> --- /dev/null
> +++ b/support/xpthread_cond_signal.c
> @@ -0,0 +1,26 @@
> +/* pthread_cond_signal with error checking.
> + Copyright (C) 2022 Free Software 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 <support/xthread.h>
> +
> +void
> +xpthread_cond_signal (pthread_cond_t *cond)
> +{
> + xpthread_check_return
> + ("pthread_cond_signal", pthread_cond_signal (cond));
> +}
> diff --git a/support/xthread.h b/support/xthread.h
> index af06715f46..ae09649325 100644
> --- a/support/xthread.h
> +++ b/support/xthread.h
> @@ -62,6 +62,7 @@ void xpthread_mutex_consistent (pthread_mutex_t *);
> void xpthread_spin_lock (pthread_spinlock_t *lock);
> void xpthread_spin_unlock (pthread_spinlock_t *lock);
> void xpthread_cond_wait (pthread_cond_t * cond, pthread_mutex_t * mutex);
> +void xpthread_cond_signal (pthread_cond_t *cond);
> pthread_t xpthread_create (pthread_attr_t *attr,
> void *(*thread_func) (void *), void *closure);
> void xpthread_detach (pthread_t thr);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 2/2] nptl: Convert tst-setuid2 to test-driver
2022-09-30 12:19 ` [PATCH v2 2/2] nptl: Convert tst-setuid2 to test-driver Yu Chien Peter Lin
@ 2022-09-30 14:10 ` Adhemerval Zanella Netto
0 siblings, 0 replies; 4+ messages in thread
From: Adhemerval Zanella Netto @ 2022-09-30 14:10 UTC (permalink / raw)
To: Yu Chien Peter Lin, libc-alpha; +Cc: fw, ycliang, dylan, alankao
On 30/09/22 09:19, Yu Chien Peter Lin wrote:
> Use <support/test-driver.c> and replace pthread calls to its xpthread
> equivalents.
>
> Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
LGTM, thanks.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> ---
> nptl/tst-setuid2.c | 52 +++++++++++++---------------------------------
> 1 file changed, 15 insertions(+), 37 deletions(-)
>
> diff --git a/nptl/tst-setuid2.c b/nptl/tst-setuid2.c
> index aff3b1a97d..9b7799991c 100644
> --- a/nptl/tst-setuid2.c
> +++ b/nptl/tst-setuid2.c
> @@ -20,6 +20,7 @@
> #include <signal.h>
> #include <stdbool.h>
> #include <stdio.h>
> +#include <support/xthread.h>
> #include <sys/syscall.h>
> #include <unistd.h>
>
> @@ -36,30 +37,21 @@ static pthread_cond_t cond_recv;
> static void *
> thread_func (void *ctx __attribute__ ((unused)))
> {
> - int ret = pthread_mutex_lock (&mutex);
> - if (ret != 0)
> - FAIL ("pthread_mutex_lock (thread): %d", ret);
> -
> + xpthread_mutex_lock (&mutex);
> while (true)
> {
> if (func_sent != NULL)
> {
> void (*func) (void) = func_sent;
> - ret = pthread_mutex_unlock (&mutex);
> - if (ret != 0)
> - FAIL ("pthread_mutex_unlock (thread): %d", ret);
> + xpthread_mutex_unlock (&mutex);
> +
> func ();
> - ret = pthread_mutex_lock (&mutex);
> - if (ret != 0)
> - FAIL ("pthread_mutex_lock (thread): %d", ret);
> +
> + xpthread_mutex_lock (&mutex);
> func_sent = NULL;
> - ret = pthread_cond_signal (&cond_recv);
> - if (ret != 0)
> - FAIL ("pthread_cond_signal (recv): %d", ret);
> + xpthread_cond_signal (&cond_recv);
> }
> - ret = pthread_cond_wait (&cond_send, &mutex);
> - if (ret != 0)
> - FAIL ("pthread_cond_wait (send): %d", ret);
> + xpthread_cond_wait (&cond_send, &mutex);
> }
> return NULL;
> }
> @@ -67,31 +59,18 @@ thread_func (void *ctx __attribute__ ((unused)))
> static void
> run_on_thread (void (*func) (void))
> {
> - int ret = pthread_mutex_lock (&mutex);
> - if (ret != 0)
> - FAIL ("pthread_mutex_lock (%s): %d", __func__, ret);
> + xpthread_mutex_lock (&mutex);
> func_sent = func;
> - ret = pthread_mutex_unlock (&mutex);
> - if (ret != 0)
> - FAIL ("pthread_mutex_unlock (%s): %d", __func__, ret);
> + xpthread_mutex_unlock (&mutex);
>
> - ret = pthread_cond_signal (&cond_send);
> - if (ret != 0)
> - FAIL ("pthread_mutex_lock (%s): %d", __func__, ret);
> -
> - ret = pthread_mutex_lock (&mutex);
> - if (ret != 0)
> - FAIL ("pthread_mutex_lock (%s): %d", __func__, ret);
> + xpthread_cond_signal (&cond_send);
>
> + xpthread_mutex_lock (&mutex);
> while (func_sent != NULL)
> {
> - ret = pthread_cond_wait (&cond_recv, &mutex);
> - if (ret != 0)
> - FAIL ("pthread_mutex_wait (%s): %d", __func__, ret);
> + xpthread_cond_wait (&cond_recv, &mutex);
> }
> - ret = pthread_mutex_unlock (&mutex);
> - if (ret != 0)
> - FAIL ("pthread_mutex_unlock (%s): %d", __func__, ret);
> + xpthread_mutex_unlock (&mutex);
> }
>
> static void
> @@ -141,5 +120,4 @@ do_test (void)
> return 0;
> }
>
> -#define TEST_FUNCTION do_test ()
> -#include "../test-skeleton.c"
> +#include <support/test-driver.c>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-09-30 14:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-30 12:19 [PATCH v2 1/2] support: Add xpthread_cond_signal wrapper Yu Chien Peter Lin
2022-09-30 12:19 ` [PATCH v2 2/2] nptl: Convert tst-setuid2 to test-driver Yu Chien Peter Lin
2022-09-30 14:10 ` Adhemerval Zanella Netto
2022-09-30 14:09 ` [PATCH v2 1/2] support: Add xpthread_cond_signal wrapper Adhemerval Zanella Netto
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).