diff mbox series

[4/5] c11: Switch to use pthread_mutex_clocklock and pthread_cond_clockwait to implement cnd and mtx lock and wait

Message ID 20230619222052.682-5-luoyonggang@gmail.com
State New
Headers show
Series c2y proposal add monotonicwait support for mtx and ctx | expand

Commit Message

Yonggang Luo June 19, 2023, 10:20 p.m. UTC
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 sysdeps/pthread/cnd_timedwait.c         | 8 ++++----
 sysdeps/pthread/mtx_timedlock.c         | 6 +++---
 sysdeps/unix/sysv/linux/cnd_timedwait.c | 4 ++--
 sysdeps/unix/sysv/linux/mtx_timedlock.c | 4 ++--
 4 files changed, 11 insertions(+), 11 deletions(-)

Comments

Florian Weimer June 20, 2023, 9:15 a.m. UTC | #1
* Yonggang Luo via Libc-alpha:

> Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
> ---
>  sysdeps/pthread/cnd_timedwait.c         | 8 ++++----
>  sysdeps/pthread/mtx_timedlock.c         | 6 +++---
>  sysdeps/unix/sysv/linux/cnd_timedwait.c | 4 ++--
>  sysdeps/unix/sysv/linux/mtx_timedlock.c | 4 ++--
>  4 files changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/sysdeps/pthread/cnd_timedwait.c b/sysdeps/pthread/cnd_timedwait.c
> index 25df50cb3a..3785fd21ba 100644
> --- a/sysdeps/pthread/cnd_timedwait.c
> +++ b/sysdeps/pthread/cnd_timedwait.c
> @@ -20,10 +20,10 @@
>  
>  int
>  cnd_timedwait (cnd_t *restrict cond, mtx_t *restrict mutex,
> -	       const struct timespec* restrict time_point)
> +               const struct timespec *restrict time_point)
>  {
> -  int err_code = __pthread_cond_timedwait ((pthread_cond_t *) cond,
> -					   (pthread_mutex_t *) mutex,
> -					   time_point);
> +  int err_code = pthread_cond_clockwait ((pthread_cond_t *) cond,
> +                                         (pthread_mutex_t *) mutex,
> +                                         CLOCK_REALTIME, time_point);
>    return thrd_err_map (err_code);
>  }

Doesn't this cause linknamespace failures during “make check”?

Thanks,
Florian
diff mbox series

Patch

diff --git a/sysdeps/pthread/cnd_timedwait.c b/sysdeps/pthread/cnd_timedwait.c
index 25df50cb3a..3785fd21ba 100644
--- a/sysdeps/pthread/cnd_timedwait.c
+++ b/sysdeps/pthread/cnd_timedwait.c
@@ -20,10 +20,10 @@ 
 
 int
 cnd_timedwait (cnd_t *restrict cond, mtx_t *restrict mutex,
-	       const struct timespec* restrict time_point)
+               const struct timespec *restrict time_point)
 {
-  int err_code = __pthread_cond_timedwait ((pthread_cond_t *) cond,
-					   (pthread_mutex_t *) mutex,
-					   time_point);
+  int err_code = pthread_cond_clockwait ((pthread_cond_t *) cond,
+                                         (pthread_mutex_t *) mutex,
+                                         CLOCK_REALTIME, time_point);
   return thrd_err_map (err_code);
 }
diff --git a/sysdeps/pthread/mtx_timedlock.c b/sysdeps/pthread/mtx_timedlock.c
index a3d236f3e1..763f07d2f8 100644
--- a/sysdeps/pthread/mtx_timedlock.c
+++ b/sysdeps/pthread/mtx_timedlock.c
@@ -20,9 +20,9 @@ 
 
 int
 mtx_timedlock (mtx_t *restrict mutex,
-	       const struct timespec *restrict time_point)
+               const struct timespec *restrict time_point)
 {
-  int err_code = __pthread_mutex_timedlock ((pthread_mutex_t *)mutex,
-					    time_point);
+  int err_code = pthread_mutex_clocklock ((pthread_mutex_t *) mutex,
+                                          CLOCK_REALTIME, time_point);
   return thrd_err_map (err_code);
 }
diff --git a/sysdeps/unix/sysv/linux/cnd_timedwait.c b/sysdeps/unix/sysv/linux/cnd_timedwait.c
index 9fa6d71d1a..c612d4f94d 100644
--- a/sysdeps/unix/sysv/linux/cnd_timedwait.c
+++ b/sysdeps/unix/sysv/linux/cnd_timedwait.c
@@ -24,9 +24,9 @@  int
 __cnd_timedwait64 (cnd_t *restrict cond, mtx_t *restrict mutex,
                    const struct __timespec64 *restrict time_point)
 {
-  int err_code = __pthread_cond_timedwait64 ((pthread_cond_t *) cond,
+  int err_code = __pthread_cond_clockwait64 ((pthread_cond_t *) cond,
                                              (pthread_mutex_t *) mutex,
-                                             time_point);
+                                             CLOCK_REALTIME, time_point);
   return thrd_err_map (err_code);
 }
 
diff --git a/sysdeps/unix/sysv/linux/mtx_timedlock.c b/sysdeps/unix/sysv/linux/mtx_timedlock.c
index 8019792868..b8f6d51940 100644
--- a/sysdeps/unix/sysv/linux/mtx_timedlock.c
+++ b/sysdeps/unix/sysv/linux/mtx_timedlock.c
@@ -24,8 +24,8 @@  int
 __mtx_timedlock64 (mtx_t *restrict mutex,
                    const struct __timespec64 *restrict time_point)
 {
-  int err_code = __pthread_mutex_timedlock64 ((pthread_mutex_t *)mutex,
-                                              time_point);
+  int err_code = __pthread_mutex_clocklock64 ((pthread_mutex_t *) mutex,
+                                              CLOCK_REALTIME, time_point);
   return thrd_err_map (err_code);
 }