change sem_trywait algorithm so it never has to call __wake
[musl] / src / thread / sem_trywait.c
1 #include <semaphore.h>
2 #include "pthread_impl.h"
3
4 int sem_trywait(sem_t *sem)
5 {
6         int val = sem->__val[0];
7         if (val>0 && a_cas(sem->__val, val, val-1)==val) return 0;
8         errno = EAGAIN;
9         return -1;
10 }