shithub: riscv

Download patch

ref: 6940bbc50beffcd7912abfc8756936add39183bb
parent: ee6ffe998bdef7b5780a373589ff90f123198821
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Fri Jan 6 15:54:49 EST 2023

libmp: parentesis (from drawterm)

--- a/sys/src/libmp/port/cnfield.c
+++ b/sys/src/libmp/port/cnfield.c
@@ -86,7 +86,7 @@
 		return nil;
 	f = nil;
 	d = N->p[N->top-1];
-	for(s = 0; (d & (mpdigit)1<<Dbits-1) == 0; s++)
+	for(s = 0; (d & (mpdigit)1<<(Dbits-1)) == 0; s++)
 		d <<= 1;
 	C = mpnew(0);
 	M = mpcopy(N);
--- a/sys/src/libmp/port/mpcmp.c
+++ b/sys/src/libmp/port/mpcmp.c
@@ -26,5 +26,5 @@
 	int sign;
 
 	sign = (b1->sign - b2->sign) >> 1;	// -1, 0, 1
-	return sign | (sign&1)-1 & mpmagcmp(b1, b2)*b1->sign;
+	return sign | (((sign&1)-1) & mpmagcmp(b1, b2)*b1->sign);
 }
--- a/sys/src/libmp/port/mpdiv.c
+++ b/sys/src/libmp/port/mpdiv.c
@@ -21,10 +21,10 @@
 		abort();
 
 	// division by one or small powers of two
-	if(divisor->top == 1 && (divisor->p[0] & divisor->p[0]-1) == 0){
+	if(divisor->top == 1 && (divisor->p[0] & (divisor->p[0]-1)) == 0){
 		vlong r = 0;
 		if(dividend->top > 0)
-			r = (vlong)dividend->sign * (dividend->p[0] & divisor->p[0]-1);
+			r = (vlong)dividend->sign * (dividend->p[0] & (divisor->p[0]-1));
 		if(quotient != nil){
 			sign = divisor->sign;
 			for(s = 0; ((divisor->p[0] >> s) & 1) == 0; s++)
--- a/sys/src/libmp/port/mpfmt.c
+++ b/sys/src/libmp/port/mpfmt.c
@@ -33,7 +33,7 @@
 	for(p = &b->p[b->top-1]; p >= b->p; p--){
 		x = *p;
 		for(i = Dbits-s; i >= 0; i -= s){
-			j = x >> i & sn - 1;
+			j = (x >> i) & (sn - 1);
 			if(j != 0 || out != buf){
 				if(out >= eout)
 					return -1;
@@ -130,7 +130,7 @@
 			else if(x != 0)
 				return -1;
 			*out = '0' + (x & 7);
-			x = y >> Dbits-i;
+			x = y >> (Dbits-i);
 		}
 	}
 	if(i > 0)
--- a/sys/src/libmp/port/mplogic.c
+++ b/sys/src/libmp/port/mplogic.c
@@ -34,7 +34,7 @@
 		t = b1;
 		b1 = b2;
 		b2 = t;
-		fl = fl >> 2 & 0x03 | fl << 2 & 0x0c | fl & 0x30;
+		fl = ((fl >> 2) & 0x03) | ((fl << 2) & 0x0c) | (fl & 0x30);
 	}
 	mpbits(sum, b1->top*Dbits+1);
 	dp1 = b1->p;
@@ -165,7 +165,7 @@
 			for(i = 0; i < d; i++)
 				r->p[i] = b->p[i];
 		if(m != 0)
-			r->p[d] = b->p[d] & (1<<m)-1;
+			r->p[d] = b->p[d] & ((1<<m)-1);
 	}
 	r->sign = 1;
 	mpnorm(r);
--- a/sys/src/libmp/port/mpsel.c
+++ b/sys/src/libmp/port/mpsel.c
@@ -21,7 +21,7 @@
 	mpbits(res, Dbits*(n >= m ? n : m));
 	res->top = n >= m ? n : m;
 
-	s = (-s^s|s)>>(sizeof(s)*8-1);
+	s = ((-s^s)|s)>>(sizeof(s)*8-1);
 	res->sign = (b1->sign & s) | (b2->sign & ~s);
 
 	d = -((mpdigit)s & 1);
--- a/sys/src/libmp/port/mpvectscmp.c
+++ b/sys/src/libmp/port/mpvectscmp.c
@@ -12,12 +12,12 @@
 		v = 0;
 		while(alen > blen)
 			v |= a[--alen];
-		m = p = (-v^v|v)>>Dbits-1;
+		m = p = ((-v^v)|v)>>(Dbits-1);
 	} else if(blen > alen){
 		v = 0;
 		while(blen > alen)
 			v |= b[--blen];
-		m = (-v^v|v)>>Dbits-1;
+		m = ((-v^v)|v)>>(Dbits-1);
 		p = m^1;
 	} else
 		m = p = 0;
@@ -26,8 +26,8 @@
 		y = b[alen];
 		z = x - y;
 		x = ~x;
-		v = ((-z^z|z)>>Dbits-1) & ~m;
-		p = ((~(x&y|x&z|y&z)>>Dbits-1) & v) | (p & ~v);
+		v = (((-z^z)|z)>>(Dbits-1)) & ~m;
+		p = ((~((x&y)|(x&z)|(y&z))>>(Dbits-1)) & v) | (p & ~v);
 		m |= v;
 	}
 	return (p-m) | m;
--- a/sys/src/libmp/port/strtomp.c
+++ b/sys/src/libmp/port/strtomp.c
@@ -53,7 +53,7 @@
 Digout:
 			i -= Dbits;
 			b->p[b->top++] = x;
-			x = y >> 3-i;
+			x = y >> (3-i);
 		}
 	}
 	if(i > 0)