libsat, forp: fix va_list hack on amd64

This commit is contained in:
aiju 2018-04-24 12:20:07 +01:00
parent 8666ec6b55
commit 29f03ba4e7
4 changed files with 21 additions and 0 deletions

View file

@ -106,3 +106,4 @@ int satval(SATSolve *, int);
void satfree(SATSolve *);
void satreset(SATSolve *);
int satget(SATSolve *, int, int *, int);
void satvafix(va_list);

View file

@ -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;

View file

@ -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;

View file

@ -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;