aboutsummaryrefslogtreecommitdiff
path: root/src/libthread/ref.c
blob: 30c932edb13e24b88cd3163bd20b7ebe55820dd1 (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
#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);
}