mirror of
https://github.com/fluencelabs/musl
synced 2025-06-12 06:21:39 +00:00
implement POSIX semaphores
This commit is contained in:
11
src/thread/sem_trywait.c
Normal file
11
src/thread/sem_trywait.c
Normal file
@ -0,0 +1,11 @@
|
||||
#include <semaphore.h>
|
||||
#include "pthread_impl.h"
|
||||
|
||||
int sem_trywait(sem_t *sem)
|
||||
{
|
||||
int val = a_fetch_add(sem->__val, -1);
|
||||
if (val > 0) return 0;
|
||||
a_inc(sem->__val);
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
}
|
Reference in New Issue
Block a user