mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-15 11:20:03 +00:00
7966faa931
Clean up thread library a bit too.
26 lines
309 B
C
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;
|
|
}
|