Blob


1 #include "u.h"
2 #include "libc.h"
3 #include "thread.h"
5 static long
6 refadd(Ref *r, long a)
7 {
8 long ref;
10 lock(&r->lock);
11 r->ref += a;
12 ref = r->ref;
13 unlock(&r->lock);
14 return ref;
15 }
17 long
18 incref(Ref *r)
19 {
20 return refadd(r, 1);
21 }
23 long
24 decref(Ref *r)
25 {
26 return refadd(r, -1);
27 }