summaryrefslogtreecommitdiff
path: root/sys/src/ape/lib/ap/sparc/lock.c
blob: 5b1d72c46d4e64dec232d012f8a9aca04fdb0e8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#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;
}