aboutsummaryrefslogtreecommitdiff
path: root/src/libthread/ref.c
blob: a3b2cbae53acefe2830c7680aaa145e9562249cb (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
/*
 * Atomic reference counts - used by applications.
 *
 * We use locks to avoid the assembly of the Plan 9 versions.
 */

#include "threadimpl.h"

void
incref(Ref *r)
{
	lock(&r->lk);
	r->ref++;
	unlock(&r->lk);
}

long
decref(Ref *r)
{
	long n;

	lock(&r->lk);
	n = --r->ref;
	unlock(&r->lk);
	return n;
}