]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - sysdeps/htl/pt-rwlock-timedwrlock.c
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / htl / pt-rwlock-timedwrlock.c
index 2316321d79bad5603777cfa6871aa0f92162e1c6..4cd50fb154fd2e36ec1c20e8fe561de73d7bcd80 100644 (file)
@@ -1,5 +1,5 @@
 /* Acquire a rwlock for writing.  Generic version.
-   Copyright (C) 2002-2019 Free Software Foundation, Inc.
+   Copyright (C) 2002-2021 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
    shall not time out.  */
 int
 __pthread_rwlock_timedwrlock_internal (struct __pthread_rwlock *rwlock,
+                                      clockid_t clockid,
                                       const struct timespec *abstime)
 {
   error_t err;
   int drain;
   struct __pthread *self;
 
-  __pthread_spin_lock (&rwlock->__lock);
+  __pthread_spin_wait (&rwlock->__lock);
   if (__pthread_spin_trylock (&rwlock->__held) == 0)
     /* Successfully acquired the lock.  */
     {
@@ -48,7 +49,10 @@ __pthread_rwlock_timedwrlock_internal (struct __pthread_rwlock *rwlock,
   /* The lock is busy.  */
 
   if (abstime != NULL && ! valid_nanoseconds (abstime->tv_nsec))
-    return EINVAL;
+    {
+      __pthread_spin_unlock (&rwlock->__lock);
+      return EINVAL;
+    }
 
   self = _pthread_self ();
 
@@ -58,14 +62,14 @@ __pthread_rwlock_timedwrlock_internal (struct __pthread_rwlock *rwlock,
 
   /* Block the thread.  */
   if (abstime != NULL)
-    err = __pthread_timedblock (self, abstime, CLOCK_REALTIME);
+    err = __pthread_timedblock (self, abstime, clockid);
   else
     {
       err = 0;
       __pthread_block (self);
     }
 
-  __pthread_spin_lock (&rwlock->__lock);
+  __pthread_spin_wait (&rwlock->__lock);
   if (self->prevp == NULL)
     /* Another thread removed us from the queue, which means a wakeup message
        has been sent.  It was either consumed while we were blocking, or
@@ -99,6 +103,15 @@ int
 __pthread_rwlock_timedwrlock (struct __pthread_rwlock *rwlock,
                              const struct timespec *abstime)
 {
-  return __pthread_rwlock_timedwrlock_internal (rwlock, abstime);
+  return __pthread_rwlock_timedwrlock_internal (rwlock, CLOCK_REALTIME, abstime);
 }
 weak_alias (__pthread_rwlock_timedwrlock, pthread_rwlock_timedwrlock)
+
+int
+__pthread_rwlock_clockwrlock (struct __pthread_rwlock *rwlock,
+                             clockid_t clockid,
+                             const struct timespec *abstime)
+{
+  return __pthread_rwlock_timedwrlock_internal (rwlock, clockid, abstime);
+}
+weak_alias (__pthread_rwlock_clockwrlock, pthread_rwlock_clockwrlock)