aboutsummaryrefslogtreecommitdiff
path: root/src/lib9/priv.c
blob: e64e9194f3ce007722cd24b76e3e4b2059f7c5b1 (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
25
26
27
28
29
30
31
32
#include <u.h>
#include <libc.h>
#include "9proc.h"

static Lock privlock;
static ulong privmap;

int
privalloc(void)
{
	int i;

	lock(&privlock);
	for(i=0; i<NPRIV; i++)
		if((privmap&(1<<i)) == 0){
			privmap |= (1<<i);
			unlock(&privlock);
			return i;
		}
	unlock(&privlock);
	return -1;
}

void**
privmem(int i)
{
	Uproc *up;

	up = _p9uproc(0);
	return &up->priv[i];
}