From a44e68e652347fb4e44de6fef72b767fdebca1a6 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Thu, 24 Oct 2019 17:43:31 +0200 Subject: [PATCH] remove MP_IS_* macros --- mp_add_d.c | 2 +- mp_cnt_lsb.c | 2 +- mp_count_bits.c | 2 +- mp_div.c | 2 +- mp_div_d.c | 2 +- mp_exptmod.c | 2 +- mp_exteuclid.c | 2 +- mp_gcd.c | 6 +++--- mp_invmod.c | 2 +- mp_is_square.c | 2 +- mp_kronecker.c | 6 +++--- mp_log_u32.c | 2 +- mp_lshd.c | 2 +- mp_mod.c | 2 +- mp_neg.c | 2 +- mp_prime_frobenius_underwood.c | 2 +- mp_prime_is_prime.c | 2 +- mp_prime_next_prime.c | 2 +- mp_prime_strong_lucas_selfridge.c | 12 ++++++------ mp_radix_size.c | 2 +- mp_read_radix.c | 2 +- mp_set_double.c | 2 +- mp_sqrt.c | 2 +- mp_sqrtmod_prime.c | 2 +- mp_sub_d.c | 2 +- mp_to_radix.c | 4 ++-- s_mp_div_small.c | 4 ++-- s_mp_invmod_fast.c | 14 +++++++------- s_mp_invmod_slow.c | 14 +++++++------- tommath_private.h | 6 +----- 30 files changed, 53 insertions(+), 57 deletions(-) diff --git a/mp_add_d.c b/mp_add_d.c index 3be2d23..cd0d47a 100644 --- a/mp_add_d.c +++ b/mp_add_d.c @@ -12,7 +12,7 @@ mp_err mp_add_d(const mp_int *a, mp_digit b, mp_int *c) /* fast path for a == c */ if (a == c && - !MP_IS_ZERO(c) && + !mp_iszero(c) && c->sign == MP_ZPOS && c->dp[0] + b < MP_DIGIT_MAX) { c->dp[0] += b; diff --git a/mp_cnt_lsb.c b/mp_cnt_lsb.c index a2cd5f8..7ae8bc1 100644 --- a/mp_cnt_lsb.c +++ b/mp_cnt_lsb.c @@ -14,7 +14,7 @@ int mp_cnt_lsb(const mp_int *a) mp_digit q, qq; /* easy out */ - if (MP_IS_ZERO(a)) { + if (mp_iszero(a)) { return 0; } diff --git a/mp_count_bits.c b/mp_count_bits.c index 76257c8..52b463d 100644 --- a/mp_count_bits.c +++ b/mp_count_bits.c @@ -10,7 +10,7 @@ int mp_count_bits(const mp_int *a) mp_digit q; /* shortcut */ - if (MP_IS_ZERO(a)) { + if (mp_iszero(a)) { return 0; } diff --git a/mp_div.c b/mp_div.c index e9f4f50..23a2acf 100644 --- a/mp_div.c +++ b/mp_div.c @@ -8,7 +8,7 @@ mp_err mp_div(const mp_int *a, const mp_int *b, mp_int *c, mp_int *d) mp_err err; /* is divisor zero ? */ - if (MP_IS_ZERO(b)) { + if (mp_iszero(b)) { return MP_VAL; } diff --git a/mp_div_d.c b/mp_div_d.c index 331b285..98b6b24 100644 --- a/mp_div_d.c +++ b/mp_div_d.c @@ -18,7 +18,7 @@ mp_err mp_div_d(const mp_int *a, mp_digit b, mp_int *c, mp_digit *d) } /* quick outs */ - if ((b == 1u) || MP_IS_ZERO(a)) { + if ((b == 1u) || mp_iszero(a)) { if (d != NULL) { *d = 0; } diff --git a/mp_exptmod.c b/mp_exptmod.c index fcc894b..8f8a9e9 100644 --- a/mp_exptmod.c +++ b/mp_exptmod.c @@ -62,7 +62,7 @@ LBL_ERR: } /* if the modulus is odd or dr != 0 use the montgomery method */ - if (MP_HAS(S_MP_EXPTMOD_FAST) && (MP_IS_ODD(P) || (dr != 0))) { + if (MP_HAS(S_MP_EXPTMOD_FAST) && (mp_isodd(P) || (dr != 0))) { return s_mp_exptmod_fast(G, X, P, Y, dr); } else if (MP_HAS(S_MP_EXPTMOD)) { /* otherwise use the generic Barrett reduction technique */ diff --git a/mp_exteuclid.c b/mp_exteuclid.c index 5b850da..eb8ad37 100644 --- a/mp_exteuclid.c +++ b/mp_exteuclid.c @@ -24,7 +24,7 @@ mp_err mp_exteuclid(const mp_int *a, const mp_int *b, mp_int *U1, mp_int *U2, mp if ((err = mp_copy(b, &v3)) != MP_OKAY) goto LBL_ERR; /* loop while v3 != 0 */ - while (!MP_IS_ZERO(&v3)) { + while (!mp_iszero(&v3)) { /* q = u3/v3 */ if ((err = mp_div(&u3, &v3, &q, NULL)) != MP_OKAY) goto LBL_ERR; diff --git a/mp_gcd.c b/mp_gcd.c index 79b6749..4f6b6cc 100644 --- a/mp_gcd.c +++ b/mp_gcd.c @@ -11,10 +11,10 @@ mp_err mp_gcd(const mp_int *a, const mp_int *b, mp_int *c) mp_err err; /* either zero than gcd is the largest */ - if (MP_IS_ZERO(a)) { + if (mp_iszero(a)) { return mp_abs(b, c); } - if (MP_IS_ZERO(b)) { + if (mp_iszero(b)) { return mp_abs(a, c); } @@ -59,7 +59,7 @@ mp_err mp_gcd(const mp_int *a, const mp_int *b, mp_int *c) } } - while (!MP_IS_ZERO(&v)) { + while (!mp_iszero(&v)) { /* make sure v is the largest */ if (mp_cmp_mag(&u, &v) == MP_GT) { /* swap u and v to make sure v is >= u */ diff --git a/mp_invmod.c b/mp_invmod.c index b797d4e..e43eb3e 100644 --- a/mp_invmod.c +++ b/mp_invmod.c @@ -12,7 +12,7 @@ mp_err mp_invmod(const mp_int *a, const mp_int *b, mp_int *c) } /* if the modulus is odd we can use a faster routine instead */ - if (MP_HAS(S_MP_INVMOD_FAST) && MP_IS_ODD(b)) { + if (MP_HAS(S_MP_INVMOD_FAST) && mp_isodd(b)) { return s_mp_invmod_fast(a, b, c); } diff --git a/mp_is_square.c b/mp_is_square.c index c2428f8..f1df73e 100644 --- a/mp_is_square.c +++ b/mp_is_square.c @@ -40,7 +40,7 @@ mp_err mp_is_square(const mp_int *arg, mp_bool *ret) return MP_VAL; } - if (MP_IS_ZERO(arg)) { + if (mp_iszero(arg)) { return MP_OKAY; } diff --git a/mp_kronecker.c b/mp_kronecker.c index 3111a78..0ac6338 100644 --- a/mp_kronecker.c +++ b/mp_kronecker.c @@ -25,7 +25,7 @@ mp_err mp_kronecker(const mp_int *a, const mp_int *p, int *c) static const int table[8] = {0, 1, 0, -1, 0, -1, 0, 1}; - if (MP_IS_ZERO(p)) { + if (mp_iszero(p)) { if ((a->used == 1) && (a->dp[0] == 1u)) { *c = 1; } else { @@ -34,7 +34,7 @@ mp_err mp_kronecker(const mp_int *a, const mp_int *p, int *c) return MP_OKAY; } - if (MP_IS_EVEN(a) && MP_IS_EVEN(p)) { + if (mp_iseven(a) && mp_iseven(p)) { *c = 0; return MP_OKAY; } @@ -69,7 +69,7 @@ mp_err mp_kronecker(const mp_int *a, const mp_int *p, int *c) } for (;;) { - if (MP_IS_ZERO(&a1)) { + if (mp_iszero(&a1)) { if (mp_cmp_d(&p1, 1uL) == MP_EQ) { *c = k; goto LBL_KRON; diff --git a/mp_log_u32.c b/mp_log_u32.c index cff9e48..31d9662 100644 --- a/mp_log_u32.c +++ b/mp_log_u32.c @@ -9,7 +9,7 @@ mp_err mp_log_u32(const mp_int *a, uint32_t base, uint32_t *c) return MP_VAL; } - if (MP_IS_ZERO(a)) { + if (mp_iszero(a)) { return MP_VAL; } diff --git a/mp_lshd.c b/mp_lshd.c index eb9a5c3..b0a8454 100644 --- a/mp_lshd.c +++ b/mp_lshd.c @@ -15,7 +15,7 @@ mp_err mp_lshd(mp_int *a, int b) return MP_OKAY; } /* no need to shift 0 around */ - if (MP_IS_ZERO(a)) { + if (mp_iszero(a)) { return MP_OKAY; } diff --git a/mp_mod.c b/mp_mod.c index 349fece..3eced35 100644 --- a/mp_mod.c +++ b/mp_mod.c @@ -17,7 +17,7 @@ mp_err mp_mod(const mp_int *a, const mp_int *b, mp_int *c) goto LBL_ERR; } - if (MP_IS_ZERO(&t) || (t.sign == b->sign)) { + if (mp_iszero(&t) || (t.sign == b->sign)) { err = MP_OKAY; mp_exch(&t, c); } else { diff --git a/mp_neg.c b/mp_neg.c index 01fb276..2fc1854 100644 --- a/mp_neg.c +++ b/mp_neg.c @@ -13,7 +13,7 @@ mp_err mp_neg(const mp_int *a, mp_int *b) } } - if (!MP_IS_ZERO(b)) { + if (!mp_iszero(b)) { b->sign = (a->sign == MP_ZPOS) ? MP_NEG : MP_ZPOS; } else { b->sign = MP_ZPOS; diff --git a/mp_prime_frobenius_underwood.c b/mp_prime_frobenius_underwood.c index 0e2ba64..bb56ea7 100644 --- a/mp_prime_frobenius_underwood.c +++ b/mp_prime_frobenius_underwood.c @@ -112,7 +112,7 @@ mp_err mp_prime_frobenius_underwood(const mp_int *N, mp_bool *result) mp_set_u32(&T1z, (uint32_t)((2 * a) + 5)); if ((err = mp_mod(&T1z, N, &T1z)) != MP_OKAY) goto LBL_FU_ERR; - if (MP_IS_ZERO(&sz) && (mp_cmp(&tz, &T1z) == MP_EQ)) { + if (mp_iszero(&sz) && (mp_cmp(&tz, &T1z) == MP_EQ)) { *result = MP_YES; } diff --git a/mp_prime_is_prime.c b/mp_prime_is_prime.c index 1a61bb6..e4f9214 100644 --- a/mp_prime_is_prime.c +++ b/mp_prime_is_prime.c @@ -39,7 +39,7 @@ mp_err mp_prime_is_prime(const mp_int *a, int t, mp_bool *result) } /* N must be odd */ - if (MP_IS_EVEN(a)) { + if (mp_iseven(a)) { return MP_OKAY; } /* N is not a perfect square: floor(sqrt(N))^2 != N */ diff --git a/mp_prime_next_prime.c b/mp_prime_next_prime.c index 3256e37..c8f7603 100644 --- a/mp_prime_next_prime.c +++ b/mp_prime_next_prime.c @@ -58,7 +58,7 @@ mp_err mp_prime_next_prime(mp_int *a, int t, mp_bool bbs_style) } } } else { - if (MP_IS_EVEN(a)) { + if (mp_iseven(a)) { /* force odd */ if ((err = mp_sub_d(a, 1uL, a)) != MP_OKAY) { return err; diff --git a/mp_prime_strong_lucas_selfridge.c b/mp_prime_strong_lucas_selfridge.c index 895a481..0aee33d 100644 --- a/mp_prime_strong_lucas_selfridge.c +++ b/mp_prime_strong_lucas_selfridge.c @@ -206,7 +206,7 @@ mp_err mp_prime_strong_lucas_selfridge(const mp_int *a, mp_bool *result) if ((err = mp_mul(&U2mz, &Uz, &T4z)) != MP_OKAY) goto LBL_LS_ERR; if ((err = s_mp_mul_si(&T4z, Ds, &T4z)) != MP_OKAY) goto LBL_LS_ERR; if ((err = mp_add(&T1z, &T2z, &Uz)) != MP_OKAY) goto LBL_LS_ERR; - if (MP_IS_ODD(&Uz)) { + if (mp_isodd(&Uz)) { if ((err = mp_add(&Uz, a, &Uz)) != MP_OKAY) goto LBL_LS_ERR; } /* CZ @@ -214,16 +214,16 @@ mp_err mp_prime_strong_lucas_selfridge(const mp_int *a, mp_bool *result) * Thomas R. Nicely used GMP's mpz_fdiv_q_2exp(). * But mp_div_2() does not do so, it is truncating instead. */ - oddness = MP_IS_ODD(&Uz) ? MP_YES : MP_NO; + oddness = mp_isodd(&Uz) ? MP_YES : MP_NO; if ((err = mp_div_2(&Uz, &Uz)) != MP_OKAY) goto LBL_LS_ERR; if ((Uz.sign == MP_NEG) && (oddness != MP_NO)) { if ((err = mp_sub_d(&Uz, 1uL, &Uz)) != MP_OKAY) goto LBL_LS_ERR; } if ((err = mp_add(&T3z, &T4z, &Vz)) != MP_OKAY) goto LBL_LS_ERR; - if (MP_IS_ODD(&Vz)) { + if (mp_isodd(&Vz)) { if ((err = mp_add(&Vz, a, &Vz)) != MP_OKAY) goto LBL_LS_ERR; } - oddness = MP_IS_ODD(&Vz) ? MP_YES : MP_NO; + oddness = mp_isodd(&Vz) ? MP_YES : MP_NO; if ((err = mp_div_2(&Vz, &Vz)) != MP_OKAY) goto LBL_LS_ERR; if ((Vz.sign == MP_NEG) && (oddness != MP_NO)) { if ((err = mp_sub_d(&Vz, 1uL, &Vz)) != MP_OKAY) goto LBL_LS_ERR; @@ -239,7 +239,7 @@ mp_err mp_prime_strong_lucas_selfridge(const mp_int *a, mp_bool *result) /* If U_d or V_d is congruent to 0 mod N, then N is a prime or a strong Lucas pseudoprime. */ - if (MP_IS_ZERO(&Uz) || MP_IS_ZERO(&Vz)) { + if (mp_iszero(&Uz) || mp_iszero(&Vz)) { *result = MP_YES; goto LBL_LS_ERR; } @@ -262,7 +262,7 @@ mp_err mp_prime_strong_lucas_selfridge(const mp_int *a, mp_bool *result) if ((err = mp_sqr(&Vz, &Vz)) != MP_OKAY) goto LBL_LS_ERR; if ((err = mp_sub(&Vz, &Q2kdz, &Vz)) != MP_OKAY) goto LBL_LS_ERR; if ((err = mp_mod(&Vz, a, &Vz)) != MP_OKAY) goto LBL_LS_ERR; - if (MP_IS_ZERO(&Vz)) { + if (mp_iszero(&Vz)) { *result = MP_YES; goto LBL_LS_ERR; } diff --git a/mp_radix_size.c b/mp_radix_size.c index 6c3e582..47f2f68 100644 --- a/mp_radix_size.c +++ b/mp_radix_size.c @@ -15,7 +15,7 @@ mp_err mp_radix_size(const mp_int *a, int radix, size_t *size) return MP_VAL; } - if (MP_IS_ZERO(a)) { + if (mp_iszero(a)) { *size = 2; return MP_OKAY; } diff --git a/mp_read_radix.c b/mp_read_radix.c index dc5e167..0e4f848 100644 --- a/mp_read_radix.c +++ b/mp_read_radix.c @@ -71,7 +71,7 @@ mp_err mp_read_radix(mp_int *a, const char *str, int radix) } /* set the sign only if a != 0 */ - if (!MP_IS_ZERO(a)) { + if (!mp_iszero(a)) { a->sign = neg; } return MP_OKAY; diff --git a/mp_set_double.c b/mp_set_double.c index f7e3b8d..467d7fd 100644 --- a/mp_set_double.c +++ b/mp_set_double.c @@ -30,7 +30,7 @@ mp_err mp_set_double(mp_int *a, double b) return err; } - if (((cast.bits >> 63) != 0uLL) && !MP_IS_ZERO(a)) { + if (((cast.bits >> 63) != 0uLL) && !mp_iszero(a)) { a->sign = MP_NEG; } diff --git a/mp_sqrt.c b/mp_sqrt.c index 2839868..b51f615 100644 --- a/mp_sqrt.c +++ b/mp_sqrt.c @@ -15,7 +15,7 @@ mp_err mp_sqrt(const mp_int *arg, mp_int *ret) } /* easy out */ - if (MP_IS_ZERO(arg)) { + if (mp_iszero(arg)) { mp_zero(ret); return MP_OKAY; } diff --git a/mp_sqrtmod_prime.c b/mp_sqrtmod_prime.c index 723332f..96b2836 100644 --- a/mp_sqrtmod_prime.c +++ b/mp_sqrtmod_prime.c @@ -51,7 +51,7 @@ mp_err mp_sqrtmod_prime(const mp_int *n, const mp_int *prime, mp_int *ret) /* Q = prime - 1 */ mp_zero(&S); /* S = 0 */ - while (MP_IS_EVEN(&Q)) { + while (mp_iseven(&Q)) { if ((err = mp_div_2(&Q, &Q)) != MP_OKAY) goto cleanup; /* Q = Q / 2 */ if ((err = mp_add_d(&S, 1uL, &S)) != MP_OKAY) goto cleanup; diff --git a/mp_sub_d.c b/mp_sub_d.c index a8a0d38..e453d36 100644 --- a/mp_sub_d.c +++ b/mp_sub_d.c @@ -12,7 +12,7 @@ mp_err mp_sub_d(const mp_int *a, mp_digit b, mp_int *c) /* fast path for a == c */ if (a == c && - !MP_IS_ZERO(c) && + !mp_iszero(c) && c->sign == MP_ZPOS && c->dp[0] > b) { c->dp[0] -= b; diff --git a/mp_to_radix.c b/mp_to_radix.c index b0564a1..78ad989 100644 --- a/mp_to_radix.c +++ b/mp_to_radix.c @@ -42,7 +42,7 @@ mp_err mp_to_radix(const mp_int *a, char *str, size_t maxlen, size_t *written, i } /* quick out if its zero */ - if (MP_IS_ZERO(a)) { + if (mp_iszero(a)) { *str++ = '0'; *str = '\0'; if (written != NULL) { @@ -68,7 +68,7 @@ mp_err mp_to_radix(const mp_int *a, char *str, size_t maxlen, size_t *written, i --maxlen; } digs = 0u; - while (!MP_IS_ZERO(&t)) { + while (!mp_iszero(&t)) { if (--maxlen < 1u) { /* no more room */ err = MP_BUF; diff --git a/s_mp_div_small.c b/s_mp_div_small.c index 56b1335..c89023a 100644 --- a/s_mp_div_small.c +++ b/s_mp_div_small.c @@ -37,11 +37,11 @@ mp_err s_mp_div_small(const mp_int *a, const mp_int *b, mp_int *c, mp_int *d) sign = (a->sign == b->sign) ? MP_ZPOS : MP_NEG; if (c != NULL) { mp_exch(c, &q); - c->sign = MP_IS_ZERO(c) ? MP_ZPOS : sign; + c->sign = mp_iszero(c) ? MP_ZPOS : sign; } if (d != NULL) { mp_exch(d, &ta); - d->sign = MP_IS_ZERO(d) ? MP_ZPOS : a->sign; + d->sign = mp_iszero(d) ? MP_ZPOS : a->sign; } LBL_ERR: mp_clear_multi(&ta, &tb, &tq, &q, NULL); diff --git a/s_mp_invmod_fast.c b/s_mp_invmod_fast.c index 0d00ea9..ed1fc4a 100644 --- a/s_mp_invmod_fast.c +++ b/s_mp_invmod_fast.c @@ -16,7 +16,7 @@ mp_err s_mp_invmod_fast(const mp_int *a, const mp_int *b, mp_int *c) mp_err err; /* 2. [modified] b must be odd */ - if (MP_IS_EVEN(b)) { + if (mp_iseven(b)) { return MP_VAL; } @@ -32,7 +32,7 @@ mp_err s_mp_invmod_fast(const mp_int *a, const mp_int *b, mp_int *c) if ((err = mp_mod(a, b, &y)) != MP_OKAY) goto LBL_ERR; /* if one of x,y is zero return an error! */ - if (MP_IS_ZERO(&x) || MP_IS_ZERO(&y)) { + if (mp_iszero(&x) || mp_iszero(&y)) { err = MP_VAL; goto LBL_ERR; } @@ -44,12 +44,12 @@ mp_err s_mp_invmod_fast(const mp_int *a, const mp_int *b, mp_int *c) top: /* 4. while u is even do */ - while (MP_IS_EVEN(&u)) { + while (mp_iseven(&u)) { /* 4.1 u = u/2 */ if ((err = mp_div_2(&u, &u)) != MP_OKAY) goto LBL_ERR; /* 4.2 if B is odd then */ - if (MP_IS_ODD(&B)) { + if (mp_isodd(&B)) { if ((err = mp_sub(&B, &x, &B)) != MP_OKAY) goto LBL_ERR; } /* B = B/2 */ @@ -57,12 +57,12 @@ top: } /* 5. while v is even do */ - while (MP_IS_EVEN(&v)) { + while (mp_iseven(&v)) { /* 5.1 v = v/2 */ if ((err = mp_div_2(&v, &v)) != MP_OKAY) goto LBL_ERR; /* 5.2 if D is odd then */ - if (MP_IS_ODD(&D)) { + if (mp_isodd(&D)) { /* D = (D-x)/2 */ if ((err = mp_sub(&D, &x, &D)) != MP_OKAY) goto LBL_ERR; } @@ -84,7 +84,7 @@ top: } /* if not zero goto step 4 */ - if (!MP_IS_ZERO(&u)) { + if (!mp_iszero(&u)) { goto top; } diff --git a/s_mp_invmod_slow.c b/s_mp_invmod_slow.c index 4fecfb8..28cd6cd 100644 --- a/s_mp_invmod_slow.c +++ b/s_mp_invmod_slow.c @@ -10,7 +10,7 @@ mp_err s_mp_invmod_slow(const mp_int *a, const mp_int *b, mp_int *c) mp_err err; /* b cannot be negative */ - if ((b->sign == MP_NEG) || MP_IS_ZERO(b)) { + if ((b->sign == MP_NEG) || mp_iszero(b)) { return MP_VAL; } @@ -25,7 +25,7 @@ mp_err s_mp_invmod_slow(const mp_int *a, const mp_int *b, mp_int *c) if ((err = mp_copy(b, &y)) != MP_OKAY) goto LBL_ERR; /* 2. [modified] if x,y are both even then return an error! */ - if (MP_IS_EVEN(&x) && MP_IS_EVEN(&y)) { + if (mp_iseven(&x) && mp_iseven(&y)) { err = MP_VAL; goto LBL_ERR; } @@ -38,12 +38,12 @@ mp_err s_mp_invmod_slow(const mp_int *a, const mp_int *b, mp_int *c) top: /* 4. while u is even do */ - while (MP_IS_EVEN(&u)) { + while (mp_iseven(&u)) { /* 4.1 u = u/2 */ if ((err = mp_div_2(&u, &u)) != MP_OKAY) goto LBL_ERR; /* 4.2 if A or B is odd then */ - if (MP_IS_ODD(&A) || MP_IS_ODD(&B)) { + if (mp_isodd(&A) || mp_isodd(&B)) { /* A = (A+y)/2, B = (B-x)/2 */ if ((err = mp_add(&A, &y, &A)) != MP_OKAY) goto LBL_ERR; if ((err = mp_sub(&B, &x, &B)) != MP_OKAY) goto LBL_ERR; @@ -54,12 +54,12 @@ top: } /* 5. while v is even do */ - while (MP_IS_EVEN(&v)) { + while (mp_iseven(&v)) { /* 5.1 v = v/2 */ if ((err = mp_div_2(&v, &v)) != MP_OKAY) goto LBL_ERR; /* 5.2 if C or D is odd then */ - if (MP_IS_ODD(&C) || MP_IS_ODD(&D)) { + if (mp_isodd(&C) || mp_isodd(&D)) { /* C = (C+y)/2, D = (D-x)/2 */ if ((err = mp_add(&C, &y, &C)) != MP_OKAY) goto LBL_ERR; if ((err = mp_sub(&D, &x, &D)) != MP_OKAY) goto LBL_ERR; @@ -87,7 +87,7 @@ top: } /* if not zero goto step 4 */ - if (!MP_IS_ZERO(&u)) { + if (!mp_iszero(&u)) { goto top; } diff --git a/tommath_private.h b/tommath_private.h index e26025f..07a8985 100644 --- a/tommath_private.h +++ b/tommath_private.h @@ -1,3 +1,4 @@ + /* LibTomMath, multiple-precision integer library -- Tom St Denis */ /* SPDX-License-Identifier: Unlicense */ @@ -149,11 +150,6 @@ extern void MP_FREE(void *mem, size_t size); /* Static assertion */ #define MP_STATIC_ASSERT(msg, cond) typedef char mp_static_assert_##msg[(cond) ? 1 : -1]; -/* ---> Basic Manipulations <--- */ -#define MP_IS_ZERO(a) ((a)->used == 0) -#define MP_IS_EVEN(a) (((a)->used == 0) || (((a)->dp[0] & 1u) == 0u)) -#define MP_IS_ODD(a) (((a)->used > 0) && (((a)->dp[0] & 1u) == 1u)) - #define MP_SIZEOF_BITS(type) ((size_t)CHAR_BIT * sizeof(type)) #define MP_MAXFAST (int)(1uL << (MP_SIZEOF_BITS(mp_word) - (2u * (size_t)MP_DIGIT_BIT)))