TFM NO 64-BIT

When diabling 64-bit fastmath using the flag NO_TFM_64BIT, the sizes of
fp_digit and fp_word get smaller. Using them in math with an int gives
incorrect values. Changed the fp_cmp_mag_ct to return a fp_digit since
its return value is used with an fp_digit. Compare its result against
a FP_LT cast as a fp_digit.
This commit is contained in:
John Safranek
2020-09-23 12:17:41 -07:00
parent 8816577824
commit 9dfbf896a8

View File

@ -103,7 +103,7 @@ word32 CheckRunTimeFastMath(void)
/* Functions */ /* Functions */
static int fp_cmp_mag_ct(fp_int *a, fp_int *b, int len) static fp_digit fp_cmp_mag_ct(fp_int *a, fp_int *b, int len)
{ {
int i; int i;
fp_digit r = FP_EQ; fp_digit r = FP_EQ;
@ -120,7 +120,7 @@ static int fp_cmp_mag_ct(fp_int *a, fp_int *b, int len)
mask &= (ad < bd) - 1; mask &= (ad < bd) - 1;
} }
return (int)r; return r;
} }
int fp_add(fp_int *a, fp_int *b, fp_int *c) int fp_add(fp_int *a, fp_int *b, fp_int *c)
@ -1599,7 +1599,7 @@ int fp_submod_ct(fp_int *a, fp_int *b, fp_int *c, fp_int *d)
fp_digit mask; fp_digit mask;
int i; int i;
mask = 0 - (fp_cmp_mag_ct(a, b, c->used + 1) == FP_LT); mask = 0 - (fp_cmp_mag_ct(a, b, c->used + 1) == (fp_digit)FP_LT);
for (i = 0; i < c->used + 1; i++) { for (i = 0; i < c->used + 1; i++) {
fp_digit mask_a = 0 - (i < a->used); fp_digit mask_a = 0 - (i < a->used);
@ -1625,7 +1625,7 @@ int fp_addmod_ct(fp_int *a, fp_int *b, fp_int *c, fp_int *d)
int i; int i;
s_fp_add(a, b, d); s_fp_add(a, b, d);
mask = 0 - (fp_cmp_mag_ct(d, c, c->used + 1) != FP_LT); mask = 0 - (fp_cmp_mag_ct(d, c, c->used + 1) != (fp_digit)FP_LT);
for (i = 0; i < c->used; i++) { for (i = 0; i < c->used; i++) {
w += c->dp[i] & mask; w += c->dp[i] & mask;
w = d->dp[i] - w; w = d->dp[i] - w;