aboutsummaryrefslogtreecommitdiff
path: root/linuxthreads/rwlock.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-10-29 15:17:25 +0000
committerUlrich Drepper <drepper@redhat.com>1998-10-29 15:17:25 +0000
commitc5e340c71ba6f4563ca5fa245baa82b6363ddb2e (patch)
tree3ff655dfee624df411e1f3ebc062181fc0f3f338 /linuxthreads/rwlock.c
parent05e951cd1ae7917ce25ec96cc17ebcbf401e345c (diff)
downloadglibc-c5e340c71ba6f4563ca5fa245baa82b6363ddb2e.tar
glibc-c5e340c71ba6f4563ca5fa245baa82b6363ddb2e.tar.gz
glibc-c5e340c71ba6f4563ca5fa245baa82b6363ddb2e.tar.bz2
glibc-c5e340c71ba6f4563ca5fa245baa82b6363ddb2e.zip
Update.
1998-10-29 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/sysv/linux/ttyname_r.c (ttyname_r): Try reading /prof/self/fd/FD first. * sysdeps/unix/sysv/linux/ttyname.c (ttyname): Likewise. * stdio-common/_itoa.h (_fitoa_word): New inline function. Write formatted number starting at given position and return pointer to following byte. (_fitoa): Likewise, for long long.
Diffstat (limited to 'linuxthreads/rwlock.c')
-rw-r--r--linuxthreads/rwlock.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/linuxthreads/rwlock.c b/linuxthreads/rwlock.c
index bff4e38fa8..1fb18a3f9e 100644
--- a/linuxthreads/rwlock.c
+++ b/linuxthreads/rwlock.c
@@ -57,7 +57,7 @@ pthread_rwlock_destroy (pthread_rwlock_t *rwlock)
int readers;
_pthread_descr writer;
- __pthread_lock (&rwlock->__rw_lock);
+ __pthread_lock (&rwlock->__rw_lock, NULL);
readers = rwlock->__rw_readers;
writer = rwlock->__rw_writer;
__pthread_unlock (&rwlock->__rw_lock);
@@ -72,11 +72,11 @@ pthread_rwlock_destroy (pthread_rwlock_t *rwlock)
int
pthread_rwlock_rdlock (pthread_rwlock_t *rwlock)
{
- pthread_descr self;
+ pthread_descr self = NULL;
while (1)
{
- __pthread_lock (&rwlock->__rw_lock);
+ __pthread_lock (&rwlock->__rw_lock, self);
if (rwlock->__rw_writer == NULL
|| (rwlock->__rw_kind == PTHREAD_RWLOCK_PREFER_READER_NP
&& rwlock->__rw_readers != 0))
@@ -84,7 +84,8 @@ pthread_rwlock_rdlock (pthread_rwlock_t *rwlock)
break;
/* Suspend ourselves, then try again */
- self = thread_self ();
+ if (self == NULL)
+ self = thread_self ();
enqueue (&rwlock->__rw_read_waiting, self);
__pthread_unlock (&rwlock->__rw_lock);
suspend (self); /* This is not a cancellation point */
@@ -102,7 +103,7 @@ pthread_rwlock_tryrdlock (pthread_rwlock_t *rwlock)
{
int result = EBUSY;
- __pthread_lock (&rwlock->__rw_lock);
+ __pthread_lock (&rwlock->__rw_lock, NULL);
if (rwlock->__rw_writer == NULL
|| (rwlock->__rw_kind == PTHREAD_RWLOCK_PREFER_READER_NP
&& rwlock->__rw_readers != 0))
@@ -123,7 +124,7 @@ pthread_rwlock_wrlock (pthread_rwlock_t *rwlock)
while(1)
{
- __pthread_lock (&rwlock->__rw_lock);
+ __pthread_lock (&rwlock->__rw_lock, self);
if (rwlock->__rw_readers == 0 && rwlock->__rw_writer == NULL)
{
rwlock->__rw_writer = self;
@@ -144,7 +145,7 @@ pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock)
{
int result = EBUSY;
- __pthread_lock (&rwlock->__rw_lock);
+ __pthread_lock (&rwlock->__rw_lock, NULL);
if (rwlock->__rw_readers == 0 && rwlock->__rw_writer == NULL)
{
rwlock->__rw_writer = thread_self ();
@@ -162,7 +163,7 @@ pthread_rwlock_unlock (pthread_rwlock_t *rwlock)
pthread_descr torestart;
pthread_descr th;
- __pthread_lock (&rwlock->__rw_lock);
+ __pthread_lock (&rwlock->__rw_lock, NULL);
if (rwlock->__rw_writer != NULL)
{
/* Unlocking a write lock. */