projects
/
musl
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
dns: fix workaround for systems defaulting to ipv6-only sockets
[musl]
/
src
/
thread
/
sem_trywait.c
1
#include <semaphore.h>
2
#include <limits.h>
3
#include "pthread_impl.h"
4
5
int sem_trywait(sem_t *sem)
6
{
7
int val;
8
while ((val=sem->__val[0]) & SEM_VALUE_MAX) {
9
if (a_cas(sem->__val, val, val-1)==val) return 0;
10
}
11
errno = EAGAIN;
12
return -1;
13
}