projects
/
oweals
/
musl.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
use a separate signal from SIGCANCEL for SIGEV_THREAD timers
[oweals/musl.git]
/
src
/
thread
/
sem_trywait.c
1
#include <semaphore.h>
2
#include "pthread_impl.h"
3
4
int sem_trywait(sem_t *sem)
5
{
6
if (a_fetch_add(sem->__val, -1) > 0) return 0;
7
if (!a_fetch_add(sem->__val, 1) && sem->__val[1])
8
__wake(sem->__val, 1, 0);
9
errno = EAGAIN;
10
return -1;
11
}