git: 9front

ref: 8f63d48a00251d74b67e7244c908e436cb540d2c
dir: /sys/src/ape/lib/ap/68020/lock.c/

View raw version
#define _LOCK_EXTENSION
#include "../plan9/sys9.h"
#include <lock.h>

void
lock(Lock *lk)
{
	while(tas((int*)&lk->key))
		_SLEEP(0);
}

int
canlock(Lock *lk)
{
	if(tas((int*)&lk->key))
		return 0;
	return 1;
}

void
unlock(Lock *lk)
{
	lk->key = 0;
}