diff options
author | "Steven J. Hill" <sjhill@realitydiluted.com> | 2005-09-13 02:28:34 +0000 |
---|---|---|
committer | "Steven J. Hill" <sjhill@realitydiluted.com> | 2005-09-13 02:28:34 +0000 |
commit | 07a485defae1ef578c5b3ce0d4373201948a7345 (patch) | |
tree | 2184f0f32083bd47ef3b82ad016d8d710f8f221f /libpthread/linuxthreads/oldsemaphore.c | |
parent | 224ca9f63688cdecd80ed01c25f5f62871fe4cfc (diff) | |
download | uClibc-alpine-07a485defae1ef578c5b3ce0d4373201948a7345.tar.bz2 uClibc-alpine-07a485defae1ef578c5b3ce0d4373201948a7345.tar.xz |
Merge with trunk. "So do that funky merge whiiite boy..."
Diffstat (limited to 'libpthread/linuxthreads/oldsemaphore.c')
-rw-r--r-- | libpthread/linuxthreads/oldsemaphore.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/libpthread/linuxthreads/oldsemaphore.c b/libpthread/linuxthreads/oldsemaphore.c index 3a3b3d186..ecf7d7019 100644 --- a/libpthread/linuxthreads/oldsemaphore.c +++ b/libpthread/linuxthreads/oldsemaphore.c @@ -32,9 +32,6 @@ typedef struct { int sem_spinlock; } old_sem_t; -/* Maximum value the semaphore can have. */ -#define SEM_VALUE_MAX ((int) ((~0u) >> 1)) - static inline int sem_compare_and_swap(old_sem_t *sem, long oldval, long newval) { return compare_and_swap(&sem->sem_status, oldval, newval, &sem->sem_spinlock); @@ -63,7 +60,7 @@ int __old_sem_init(old_sem_t *sem, int pshared, unsigned int value) errno = ENOSYS; return -1; } - sem->sem_spinlock = 0; + sem->sem_spinlock = __LT_SPINLOCK_INIT; sem->sem_status = ((long)value << 1) + 1; return 0; } @@ -90,7 +87,7 @@ int __old_sem_wait(old_sem_t * sem) while (1) { /* Register extrication interface */ - __pthread_set_own_extricate_if(self, &extr); + __pthread_set_own_extricate_if(self, &extr); do { oldstatus = sem->sem_status; if ((oldstatus & 1) && (oldstatus != 1)) @@ -103,12 +100,13 @@ int __old_sem_wait(old_sem_t * sem) while (! sem_compare_and_swap(sem, oldstatus, newstatus)); if (newstatus & 1) { /* We got the semaphore. */ - __pthread_set_own_extricate_if(self, 0); + __pthread_set_own_extricate_if(self, 0); + self->p_nextwaiting = NULL; return 0; } /* Wait for sem_post or cancellation */ suspend(self); - __pthread_set_own_extricate_if(self, 0); + __pthread_set_own_extricate_if(self, 0); /* This is a cancellation point */ if (self->p_canceled && self->p_cancelstate == PTHREAD_CANCEL_ENABLE) { |