summaryrefslogtreecommitdiff
path: root/libpthread/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c
diff options
context:
space:
mode:
Diffstat (limited to 'libpthread/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c')
-rw-r--r--libpthread/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/libpthread/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c b/libpthread/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c
index 2fdcc49f9..dc00f2a08 100644
--- a/libpthread/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c
+++ b/libpthread/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003.
@@ -26,12 +26,13 @@
/* Acquire read lock for RWLOCK. */
int
-__pthread_rwlock_rdlock (pthread_rwlock_t *rwlock)
+__pthread_rwlock_rdlock (
+ pthread_rwlock_t *rwlock)
{
int result = 0;
/* Make sure we are along. */
- lll_mutex_lock (rwlock->__data.__lock);
+ lll_lock (rwlock->__data.__lock, rwlock->__data.__shared);
while (1)
{
@@ -39,7 +40,7 @@ __pthread_rwlock_rdlock (pthread_rwlock_t *rwlock)
if (rwlock->__data.__writer == 0
/* ...and if either no writer is waiting or we prefer readers. */
&& (!rwlock->__data.__nr_writers_queued
- || rwlock->__data.__flags == 0))
+ || PTHREAD_RWLOCK_PREFER_READER_P (rwlock)))
{
/* Increment the reader counter. Avoid overflow. */
if (__builtin_expect (++rwlock->__data.__nr_readers == 0, 0))
@@ -73,19 +74,20 @@ __pthread_rwlock_rdlock (pthread_rwlock_t *rwlock)
int waitval = rwlock->__data.__readers_wakeup;
/* Free the lock. */
- lll_mutex_unlock (rwlock->__data.__lock);
+ lll_unlock (rwlock->__data.__lock, rwlock->__data.__shared);
/* Wait for the writer to finish. */
- lll_futex_wait (&rwlock->__data.__readers_wakeup, waitval);
+ lll_futex_wait (&rwlock->__data.__readers_wakeup, waitval,
+ rwlock->__data.__shared);
/* Get the lock. */
- lll_mutex_lock (rwlock->__data.__lock);
+ lll_lock (rwlock->__data.__lock, rwlock->__data.__shared);
--rwlock->__data.__nr_readers_queued;
}
/* We are done, free the lock. */
- lll_mutex_unlock (rwlock->__data.__lock);
+ lll_unlock (rwlock->__data.__lock, rwlock->__data.__shared);
return result;
}