more new libthread

This commit is contained in:
rsc 2004-12-25 21:57:50 +00:00
parent 1544f90960
commit 619085f0b4
7 changed files with 800 additions and 0 deletions

27
src/libthread/ref.c Normal file
View file

@ -0,0 +1,27 @@
#include "u.h"
#include "libc.h"
#include "thread.h"
static long
refadd(Ref *r, long a)
{
long ref;
lock(&r->lock);
r->ref += a;
ref = r->ref;
unlock(&r->lock);
return ref;
}
long
incref(Ref *r)
{
return refadd(r, 1);
}
long
decref(Ref *r)
{
return refadd(r, -1);
}