diff options
author | Ulrich Drepper <drepper@redhat.com> | 1998-10-29 15:17:25 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1998-10-29 15:17:25 +0000 |
commit | c5e340c71ba6f4563ca5fa245baa82b6363ddb2e (patch) | |
tree | 3ff655dfee624df411e1f3ebc062181fc0f3f338 /linuxthreads/semaphore.c | |
parent | 05e951cd1ae7917ce25ec96cc17ebcbf401e345c (diff) | |
download | glibc-c5e340c71ba6f4563ca5fa245baa82b6363ddb2e.tar.gz glibc-c5e340c71ba6f4563ca5fa245baa82b6363ddb2e.tar.xz 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/semaphore.c')
-rw-r--r-- | linuxthreads/semaphore.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/linuxthreads/semaphore.c b/linuxthreads/semaphore.c index af5f115a16..cb23a71a78 100644 --- a/linuxthreads/semaphore.c +++ b/linuxthreads/semaphore.c @@ -40,15 +40,14 @@ int sem_init(sem_t *sem, int pshared, unsigned int value) int sem_wait(sem_t * sem) { - volatile pthread_descr self; + volatile pthread_descr self = thread_self(); - __pthread_lock((struct _pthread_fastlock *) &sem->sem_lock); + __pthread_lock((struct _pthread_fastlock *) &sem->sem_lock, self); if (sem->sem_value > 0) { sem->sem_value--; __pthread_unlock((struct _pthread_fastlock *) &sem->sem_lock); return 0; } - self = thread_self(); enqueue(&sem->sem_waiting, self); /* Wait for sem_post or cancellation */ __pthread_unlock((struct _pthread_fastlock *) &sem->sem_lock); @@ -57,7 +56,7 @@ int sem_wait(sem_t * sem) if (THREAD_GETMEM(self, p_canceled) && THREAD_GETMEM(self, p_cancelstate) == PTHREAD_CANCEL_ENABLE) { /* Remove ourselves from the waiting list if we're still on it */ - __pthread_lock((struct _pthread_fastlock *) &sem->sem_lock); + __pthread_lock((struct _pthread_fastlock *) &sem->sem_lock, self); remove_from_queue(&sem->sem_waiting, self); __pthread_unlock((struct _pthread_fastlock *) &sem->sem_lock); pthread_exit(PTHREAD_CANCELED); @@ -70,7 +69,7 @@ int sem_trywait(sem_t * sem) { int retval; - __pthread_lock((struct _pthread_fastlock *) &sem->sem_lock); + __pthread_lock((struct _pthread_fastlock *) &sem->sem_lock, NULL); if (sem->sem_value == 0) { errno = EAGAIN; retval = -1; @@ -88,7 +87,7 @@ int sem_post(sem_t * sem) struct pthread_request request; if (THREAD_GETMEM(self, p_in_sighandler) == NULL) { - __pthread_lock((struct _pthread_fastlock *) &sem->sem_lock); + __pthread_lock((struct _pthread_fastlock *) &sem->sem_lock, self); if (sem->sem_waiting == NULL) { if (sem->sem_value >= SEM_VALUE_MAX) { /* Overflow */ |