mirror of
https://github.com/ziglang/zig.git
synced 2025-12-22 06:03:16 +00:00
also start prefering NtDll API. so far: * NtQueryInformationFile * NtClose adds a performance workaround for windows unicode conversion. but that should probably be removed before merging
14 lines
254 B
C
Vendored
14 lines
254 B
C
Vendored
#include <semaphore.h>
|
|
#include "pthread_impl.h"
|
|
|
|
int sem_trywait(sem_t *sem)
|
|
{
|
|
int val;
|
|
while ((val=sem->__val[0]) > 0) {
|
|
int new = val-1-(val==1 && sem->__val[1]);
|
|
if (a_cas(sem->__val, val, new)==val) return 0;
|
|
}
|
|
errno = EAGAIN;
|
|
return -1;
|
|
}
|