plan9port/src/lib9/priv.c

33 lines
376 B
C
Raw Normal View History

2003-11-23 18:12:54 +00:00
#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();
return &up->priv[i];
}