From 29f03ba4e74ec58b87e3e6470aadfb58ee804f48 Mon Sep 17 00:00:00 2001 From: aiju Date: Tue, 24 Apr 2018 12:20:07 +0100 Subject: [PATCH 1/2] libsat, forp: fix va_list hack on amd64 --- sys/include/sat.h | 1 + sys/src/cmd/forp/logic.c | 3 +++ sys/src/libsat/satadd.c | 16 ++++++++++++++++ sys/src/libsat/satrange.c | 1 + 4 files changed, 21 insertions(+) diff --git a/sys/include/sat.h b/sys/include/sat.h index 6251b43ae..416241f59 100644 --- a/sys/include/sat.h +++ b/sys/include/sat.h @@ -106,3 +106,4 @@ int satval(SATSolve *, int); void satfree(SATSolve *); void satreset(SATSolve *); int satget(SATSolve *, int, int *, int); +void satvafix(va_list); diff --git a/sys/src/cmd/forp/logic.c b/sys/src/cmd/forp/logic.c index b266e3bca..542065074 100644 --- a/sys/src/cmd/forp/logic.c +++ b/sys/src/cmd/forp/logic.c @@ -46,6 +46,7 @@ satandv(SATSolve *sat, ...) va_list va; va_start(va, sat); + satvafix(va); r = satand1(sat, (int*)va, -1); va_end(va); return r; @@ -90,6 +91,7 @@ satorv(SATSolve *sat, ...) int r; va_start(va, sat); + satvafix(va); r = sator1(sat, (int*)va, -1); va_end(va); return r; @@ -267,6 +269,7 @@ satlogicv(SATSolve *sat, u64int op, ...) int r; va_start(va, op); + satvafix(va); r = satlogic1(sat, op, (int*)va, -1); va_end(va); return r; diff --git a/sys/src/libsat/satadd.c b/sys/src/libsat/satadd.c index 3a0cf0c3a..e10dd8346 100644 --- a/sys/src/libsat/satadd.c +++ b/sys/src/libsat/satadd.c @@ -217,6 +217,21 @@ satadd1(SATSolve *s, int *a, int n) return s; } +void +satvafix(va_list va) +{ + int *d; + uintptr *s; + + if(sizeof(int)==sizeof(uintptr)) return; + d = (int *) va; + s = (uintptr *) va; + do + *d++ = *s; + while((int)*s++ != 0); + +} + SATSolve * sataddv(SATSolve *s, ...) { @@ -224,6 +239,7 @@ sataddv(SATSolve *s, ...) va_start(va, s); /* horrible hack */ + satvafix(va); s = satadd1(s, (int*)va, -1); va_end(va); return s; diff --git a/sys/src/libsat/satrange.c b/sys/src/libsat/satrange.c index 76caa5713..c202a8fc1 100644 --- a/sys/src/libsat/satrange.c +++ b/sys/src/libsat/satrange.c @@ -62,6 +62,7 @@ satrangev(SATSolve *s, int min, int max, ...) va_start(va, max); /* horrible hack */ + satvafix(va); s = satrange1(s, (int*)va, -1, min, max); va_end(va); return s; From 3c53021357e9ce86f77422877e36cdc73761e05b Mon Sep 17 00:00:00 2001 From: aiju Date: Tue, 24 Apr 2018 12:58:54 +0100 Subject: [PATCH 2/2] forp: fix ternary operator --- sys/src/cmd/forp/cvt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/src/cmd/forp/cvt.c b/sys/src/cmd/forp/cvt.c index de5dccba9..f0b9308fd 100644 --- a/sys/src/cmd/forp/cvt.c +++ b/sys/src/cmd/forp/cvt.c @@ -323,8 +323,8 @@ optern(Node *rn, Node *n1, Node *n2, Node *n3, uint sz) uint m; int i, a, b, q; - m = n1->size; - if(n2->size > m) m = n2->size; + m = n2->size; + if(n3->size > m) m = n3->size; if(m > sz) m = sz; nodevars(rn, m); q = tologic(n1);