/* 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. */
{
/* The lock is busy. */
if (abstime != NULL && ! valid_nanoseconds (abstime->tv_nsec))
- return EINVAL;
+ {
+ __pthread_spin_unlock (&rwlock->__lock);
+ return EINVAL;
+ }
self = _pthread_self ();
/* 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
__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)