Exemplo n.º 1
0
void
mach_semacquire(uint32 sem)
{
	int32 r;

	while((r = mach_semaphore_wait(sem)) != 0) {
		if(r == KERN_ABORTED)	// interrupted
			continue;
		macherror(r, "semaphore_wait");
	}
}
Exemplo n.º 2
0
int32
runtime·mach_semacquire(uint32 sem, int64 ns)
{
	int32 r;

	if(ns >= 0) {
		r = runtime·mach_semaphore_timedwait(sem, ns/1000000000LL, ns%1000000000LL);
		if(r == KERN_ABORTED || r == KERN_OPERATION_TIMED_OUT)
			return -1;
		if(r != 0)
			macherror(r, "semaphore_wait");
		return 0;
	}
	while((r = runtime·mach_semaphore_wait(sem)) != 0) {
		if(r == KERN_ABORTED)	// interrupted
			continue;
		macherror(r, "semaphore_wait");
	}
	return 0;
}