Blob


1 /*
2 * Atomic reference counts - used by applications.
3 *
4 * We use locks to avoid the assembly of the Plan 9 versions.
5 */
7 #include "threadimpl.h"
9 void
10 incref(Ref *r)
11 {
12 lock(&r->lk);
13 r->ref++;
14 unlock(&r->lk);
15 }
17 long
18 decref(Ref *r)
19 {
20 long n;
22 lock(&r->lk);
23 n = --r->ref;
24 unlock(&r->lk);
25 return n;
26 }