plan9port/src/libthread/ref.c
rsc 7966faa931 Continue fighting pthreads.
Clean up thread library a bit too.
2004-09-23 03:01:36 +00:00

26 lines
309 B
C

/*
* 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;
}