shithub: gefs

Download patch

ref: 65400ec2148185b59cf4af747ff4dbe4748df944
parent: 6fca09557ed08a206345c9c113a55d1d49564107
author: Ori Bernstein <ori@eigenstate.org>
date: Sat May 13 16:26:56 EDT 2023

atomic: return old value, not boolean

--- a/atomic-amd64.s
+++ b/atomic-amd64.s
@@ -34,22 +34,13 @@
 	MOVL	c+8(FP), AX
 	MOVL	v+16(FP), BX
 	LOCK; CMPXCHGL	BX, (RARG)
-	MOVL	$1, AX				/* use CMOVLEQ etc. here? */
-	JNZ	fail32
 	RET
-fail32:
-	DECL	AX
-	RET
+
 TEXT acasv+0(SB),1,$0
 TEXT acasp+0(SB),1,$0
 	MOVQ	c+8(FP), AX
 	MOVQ	v+16(FP), BX
 	LOCK; CMPXCHGQ BX, (RARG)
-	MOVL	$1, AX				/* use CMOVLEQ etc. here? */
-	JNZ	fail64
-	RET
-fail64:
-	DECL	AX
 	RET
 
 /* barriers (do we want to distinguish types?) */
--- a/blk.c
+++ b/blk.c
@@ -35,7 +35,7 @@
 	while(1){
 		ov = agetl(&b->flag);
 		nv = ov | f;
-		if(acasl(&b->flag, ov, nv))
+		if(acasl(&b->flag, ov, nv) == ov)
 			break;
 	}
 }
@@ -48,7 +48,7 @@
 	while(1){
 		ov = agetl(&b->flag);
 		nv = ov & ~f;
-		if(acasl(&b->flag, ov, nv))
+		if(acasl(&b->flag, ov, nv) == ov)
 			break;
 	}
 }
--- a/fs.c
+++ b/fs.c
@@ -150,7 +150,7 @@
 	long v;
 
 	v = agetl(&c->count);
-	if(v == 0 || !acasl(&c->count, v, v-1))
+	if(v == 0 || acasl(&c->count, v, v-1) != v)
 		semacquire(&c->count, 1);
 	lock(&c->rl);
 	a = *c->rp;
@@ -167,7 +167,7 @@
 	long v;
 
 	v = agetl(&c->avail);
-	if(v == 0 || !acasl(&c->avail, v, v-1))
+	if(v == 0 || acasl(&c->avail, v, v-1) != v)
 		semacquire(&c->avail, 1);
 	lock(&c->wl);
 	*c->wp = m;
@@ -1464,6 +1464,7 @@
 	Xdir d;
 	int nm;
 
+	e = nil;
 	if(okname(m->name) == -1){
 		rerror(m, Ename);
 		return;