projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
implement memrchr (nonstandard) and optimize strrchr in terms of it
[musl]
/
src
/
thread
/
sem_trywait.c
diff --git
a/src/thread/sem_trywait.c
b/src/thread/sem_trywait.c
index
d0e928e
..
beb7aa5
100644
(file)
--- a/
src/thread/sem_trywait.c
+++ b/
src/thread/sem_trywait.c
@@
-3,9
+3,9
@@
int sem_trywait(sem_t *sem)
{
int sem_trywait(sem_t *sem)
{
- i
nt val = a_fetch_add(sem->__val, -1)
;
- if (
val > 0) return 0;
-
a_inc(sem->__val
);
+ i
f (a_fetch_add(sem->__val, -1) > 0) return 0
;
+ if (
!a_fetch_add(sem->__val, 1) && sem->__val[1])
+
__wake(sem->__val, 1, 0
);
errno = EAGAIN;
return -1;
}
errno = EAGAIN;
return -1;
}