projects
/
musl
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
d0e928ef67d2048f4bbf1f1214a30407d8dbe7c8
[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 = a_fetch_add(sem->__val, -1);
7
if (val > 0) return 0;
8
a_inc(sem->__val);
9
errno = EAGAIN;
10
return -1;
11
}