tref.c - plan9port - [fork] Plan 9 from user space
HTML git clone git://src.adamsgaard.dk/plan9port
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
tref.c (278B)
---
1 #include "u.h"
2 #include "libc.h"
3 #include "thread.h"
4
5 static long
6 refadd(Ref *r, long a)
7 {
8 long ref;
9
10 lock(&r->lock);
11 r->ref += a;
12 ref = r->ref;
13 unlock(&r->lock);
14 return ref;
15 }
16
17 long
18 incref(Ref *r)
19 {
20 return refadd(r, 1);
21 }
22
23 long
24 decref(Ref *r)
25 {
26 return refadd(r, -1);
27 }