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

Message ID 20230620171731.230-4-luoyonggang@gmail.com
State RFC
Headers
Series c2y proposal add monotonicwait support for mtx and ctx |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 fail Testing failed
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm fail Testing failed

Commit Message

Yonggang Luo June 20, 2023, 5:17 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(-)
  

Patch

diff --git a/sysdeps/pthread/cnd_timedwait.c b/sysdeps/pthread/cnd_timedwait.c
index 25df50cb3a..ea2921a35c 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..77ab39a72c 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);
 }