Skip to content
Snippets Groups Projects
Commit d4dfc0c7 authored by deuce's avatar deuce
Browse files

The old sem_getvalue() implementation only worked under Win9x...

The new one doesn't care, but someone with Win-fu should make it
a critical section as it actually diddles the sem value briefly.
parent b04ace4a
No related branches found
No related tags found
No related merge requests found
......@@ -96,8 +96,23 @@ int sem_post(sem_t* psem)
int sem_getvalue(sem_t* psem, int* vp)
{
#if 0 /* This only works on 9x *sniff* */
ReleaseSemaphore(*(psem),0,(LPLONG)vp);
return 0;
#else
/* Note, this should REALLY be in a critical section... */
int retval=0;
if(WaitForSingleObject(*(psem),0)!=WAIT_OBJECT_0)
*vp=0;
else {
if(ReleaseSemaphore(*(psem),1,(LPLONG)vp))
(*vp)++;
else
retval=-1;
}
return(retval);
#endif
}
int sem_destroy(sem_t* psem)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment