~ubuntu-branches/ubuntu/lucid/9base/lucid

« back to all changes in this revision

Viewing changes to lib9/priv.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2006-01-25 15:33:00 UTC
  • Revision ID: james.westby@ubuntu.com-20060125153300-6hh4p9wx8iqqply5
Tags: upstream-2
ImportĀ upstreamĀ versionĀ 2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <u.h>
 
2
#include <libc.h>
 
3
#include "9proc.h"
 
4
 
 
5
static Lock privlock;
 
6
static ulong privmap;
 
7
 
 
8
int
 
9
privalloc(void)
 
10
{
 
11
        int i;
 
12
 
 
13
        lock(&privlock);
 
14
        for(i=0; i<NPRIV; i++)
 
15
                if((privmap&(1<<i)) == 0){
 
16
                        privmap |= (1<<i);
 
17
                        unlock(&privlock);
 
18
                        return i;
 
19
                }
 
20
        unlock(&privlock);
 
21
        return -1;
 
22
}
 
23
 
 
24
void**
 
25
privmem(int i)
 
26
{
 
27
        Uproc *up;
 
28
 
 
29
        up = _p9uproc(0);
 
30
        return &up->priv[i];
 
31
}
 
32