plan9port/src/libthread/ref.c

27 lines
309 B
C
Raw Normal View History

/*
* Atomic reference counts - used by applications.
*
* We use locks to avoid the assembly of the Plan 9 versions.
*/
2003-09-30 17:47:42 +00:00
#include "threadimpl.h"
void
incref(Ref *r)
{
lock(&r->lk);
r->ref++;
unlock(&r->lk);
2003-09-30 17:47:42 +00:00
}
long
decref(Ref *r)
{
long n;
lock(&r->lk);
n = --r->ref;
unlock(&r->lk);
return n;
2003-09-30 17:47:42 +00:00
}