mirror of https://git.musl-libc.org/git/musl
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
249 B
13 lines
249 B
#include <semaphore.h>
|
|
#include "pthread_impl.h"
|
|
|
|
int sem_trywait(sem_t *sem)
|
|
{
|
|
int val = sem->__val[0];
|
|
if (val>0) {
|
|
int new = val-1-(val==1 && sem->__val[1]);
|
|
if (a_cas(sem->__val, val, new)==val) return 0;
|
|
}
|
|
errno = EAGAIN;
|
|
return -1;
|
|
}
|
|
|