for 386, libc has this definition for ainc
TEXT ainc(SB), $0 /* int ainc(int *); */
MOVLaddr+0(FP), BX
ainclp:
MOVL(BX), AX
MOVLAX, CX
INCLCX
LOCK
BYTE$0x0F; BYTE $0xB1; BYTE $0x0B /* CMPXCHGL CX, (BX) */
JNZ
% cat ../port/ref.c
#include u.h
#include ../port/lib.h
#include mem.h
#include dat.h
#include fns.h
int
incref(Ref *r)
{
int x;
x = ainc(r-ref);
if(x = 0)
panic(incref pc=%#p, getcallerpc(r));
return x;
}
int
decref(Ref *r)
{
int x;
x = adec(r-ref);
if(x 0)
panic(decref pc=%#p,
int
incref(Ref *r)
{
int x;
x = ainc(r-ref);
if(x = 0)
panic(incref pc=%#p, getcallerpc(r));
return x;
}
ah, yes. i'd not remembered this nice implementation.
then your ainc is guard-free? and your Ref is struct Ref {int ref;}?
also, did you decide that any reuse of the ref lock is
On Wed May 14 17:27:58 EDT 2014, quans...@quanstro.net wrote:
int
incref(Ref *r)
{
int x;
x = ainc(r-ref);
if(x = 0)
panic(incref pc=%#p, getcallerpc(r));
return x;
}
ah, yes. i'd not remembered this nice implementation.
then your ainc is guard-free? and your Ref is