diff options
58 files changed, 165 insertions, 102 deletions
@@ -1,3 +1,72 @@ +2010-11-10 Torbjorn Granlund <tege@gmplib.org> + + Make it possible to compile GMP with g++: + + * gmp-impl.h: Declare __gmp_digit_value_tab here. + * mpbsd/min.c: ...not here. + * mpbsd/xtom.c: ...nor here. + * mpf/set_str.c: ...nor here. + * mpz/inp_str.c: ...nor here. + * mpz/set_str.c: ...nor here. + + * mpn/generic/toom43_mul.c: Add casts for logical operations on enums. + * mpn/generic/toom44_mul.c: Likewise. + * mpn/generic/toom4_sqr.c: Likewise. + * mpn/generic/toom52_mul.c: Likewise. + * mpn/generic/toom53_mul.c: Likewise. + * mpn/generic/toom62_mul.c: Likewise. + + * mpz/clrbit.c: Clean up typing using MPZ_REALLOC. + * mpz/setbit.c: Likewise. + + * mpz/powm.c: Avoid variable name 'new'. + + * randlc2x.c: Add explicit casts for type conversions. + * tests/misc/t-printf.c: Likewise. + * tests/misc/t-scanf.c: Likewise. + * tests/misc.c: Likewise. + * tests/mpz/convert.c: Likewise. + * tests/refmpn.c: Likewise. + + * tests/tests.h: Unconditionally use <sstream> for now. + + * tests/memory.c: Include "tests.h. + + * mp_get_fns.c: Add a __GMP_NOTHROW for coherency with prototype. + * mp_set_fns.c: Likewise. + * mpf/cmp.c: Likewise. + * mpf/cmp_si.c: Likewise. + * mpf/cmp_ui.c: Likewise. + * mpf/fits_s.h: Likewise. + * mpf/fits_u.h: Likewise. + * mpf/get_dfl_prec.c: Likewise. + * mpf/get_prc.c: Likewise. + * mpf/get_si.c: Likewise. + * mpf/get_ui.c: Likewise. + * mpf/int_p.c: Likewise. + * mpf/set_dfl_prec.c: Likewise. + * mpf/set_prc_raw.c: Likewise. + * mpf/size.c: Likewise. + * mpf/swap.c: Likewise. + * mpq/equal.c: Likewise. + * mpq/swap.c: Likewise. + * mpz/cmp.c: Likewise. + * mpz/cmp_si.c: Likewise. + * mpz/cmp_ui.c: Likewise. + * mpz/cmpabs.c: Likewise. + * mpz/cmpabs_ui.c: Likewise. + * mpz/cong_2exp.c: Likewise. + * mpz/divis_2exp.c: Likewise. + * mpz/fits_s.h: Likewise. + * mpz/get_si.c: Likewise. + * mpz/hamdist.c: Likewise. + * mpz/scan0.c: Likewise. + * mpz/scan1.c: Likewise. + * mpz/sizeinbase.c: Likewise. + * mpz/swap.c: Likewise. + * mpz/tstbit.c: Likewise. + * tal-reent.c: Likewise. + 2010-11-09 Torbjorn Granlund <tege@gmplib.org> * configure.in: Get rid of K&R support. diff --git a/gmp-impl.h b/gmp-impl.h index a414445ad..5ae0d29d0 100644 --- a/gmp-impl.h +++ b/gmp-impl.h @@ -3518,6 +3518,8 @@ __GMP_DECLSPEC double mpn_get_d __GMP_PROTO ((mp_srcptr, mp_size_t, mp_size_t, l #endif +__GMP_DECLSPEC extern const unsigned char __gmp_digit_value_tab[]; + __GMP_DECLSPEC extern int __gmp_junk; __GMP_DECLSPEC extern const int __gmp_0; __GMP_DECLSPEC void __gmp_exception __GMP_PROTO ((int)) ATTRIBUTE_NORETURN; diff --git a/mp_get_fns.c b/mp_get_fns.c index c8c9f9997..8d7c69f4f 100644 --- a/mp_get_fns.c +++ b/mp_get_fns.c @@ -24,7 +24,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ void mp_get_memory_functions (void *(**alloc_func) (size_t), void *(**realloc_func) (void *, size_t, size_t), - void (**free_func) (void *, size_t)) + void (**free_func) (void *, size_t)) __GMP_NOTHROW { if (alloc_func != NULL) *alloc_func = __gmp_allocate_func; diff --git a/mp_set_fns.c b/mp_set_fns.c index f5402c6fd..3d2aaf3ec 100644 --- a/mp_set_fns.c +++ b/mp_set_fns.c @@ -24,7 +24,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ void mp_set_memory_functions (void *(*alloc_func) (size_t), void *(*realloc_func) (void *, size_t, size_t), - void (*free_func) (void *, size_t)) + void (*free_func) (void *, size_t)) __GMP_NOTHROW { if (alloc_func == 0) alloc_func = __gmp_default_allocate; diff --git a/mpbsd/min.c b/mpbsd/min.c index 113cc173a..4502dfc03 100644 --- a/mpbsd/min.c +++ b/mpbsd/min.c @@ -24,7 +24,6 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp.h" #include "gmp-impl.h" -extern const unsigned char __gmp_digit_value_tab[]; #define digit_value_tab __gmp_digit_value_tab void diff --git a/mpbsd/xtom.c b/mpbsd/xtom.c index 75fa88a81..0161b4248 100644 --- a/mpbsd/xtom.c +++ b/mpbsd/xtom.c @@ -25,7 +25,6 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp.h" #include "gmp-impl.h" -extern const unsigned char __gmp_digit_value_tab[]; #define digit_value __gmp_digit_value_tab MINT * @@ -21,7 +21,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp-impl.h" int -mpf_cmp (mpf_srcptr u, mpf_srcptr v) +mpf_cmp (mpf_srcptr u, mpf_srcptr v) __GMP_NOTHROW { mp_srcptr up, vp; mp_size_t usize, vsize; diff --git a/mpf/cmp_si.c b/mpf/cmp_si.c index 541ac36e3..7e4009c22 100644 --- a/mpf/cmp_si.c +++ b/mpf/cmp_si.c @@ -22,7 +22,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp-impl.h" int -mpf_cmp_si (mpf_srcptr u, long int vval) +mpf_cmp_si (mpf_srcptr u, long int vval) __GMP_NOTHROW { mp_srcptr up; mp_size_t usize; diff --git a/mpf/cmp_ui.c b/mpf/cmp_ui.c index 33f418c73..5e5ed00ef 100644 --- a/mpf/cmp_ui.c +++ b/mpf/cmp_ui.c @@ -21,7 +21,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp-impl.h" int -mpf_cmp_ui (mpf_srcptr u, unsigned long int vval) +mpf_cmp_ui (mpf_srcptr u, unsigned long int vval) __GMP_NOTHROW { mp_srcptr up; mp_size_t usize; diff --git a/mpf/fits_s.h b/mpf/fits_s.h index 6306930a0..f10f2c741 100644 --- a/mpf/fits_s.h +++ b/mpf/fits_s.h @@ -24,7 +24,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ /* Notice this is equivalent to mpz_set_f + mpz_fits_s*_p. */ int -FUNCTION (mpf_srcptr f) +FUNCTION (mpf_srcptr f) __GMP_NOTHROW { mp_size_t fs, fn; mp_srcptr fp; diff --git a/mpf/fits_u.h b/mpf/fits_u.h index 724f06c35..4503f037f 100644 --- a/mpf/fits_u.h +++ b/mpf/fits_u.h @@ -24,7 +24,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ /* Notice this is equivalent to mpz_set_f + mpz_fits_u*_p. */ int -FUNCTION (mpf_srcptr f) +FUNCTION (mpf_srcptr f) __GMP_NOTHROW { mp_size_t fn; mp_srcptr fp; diff --git a/mpf/get_dfl_prec.c b/mpf/get_dfl_prec.c index e48a3a1f4..14606f037 100644 --- a/mpf/get_dfl_prec.c +++ b/mpf/get_dfl_prec.c @@ -22,7 +22,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ mp_bitcnt_t -mpf_get_default_prec (void) +mpf_get_default_prec (void) __GMP_NOTHROW { return __GMPF_PREC_TO_BITS (__gmp_default_fp_limb_precision); } diff --git a/mpf/get_prc.c b/mpf/get_prc.c index c413582b9..ca7a05629 100644 --- a/mpf/get_prc.c +++ b/mpf/get_prc.c @@ -21,7 +21,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp-impl.h" mp_bitcnt_t -mpf_get_prec (mpf_srcptr x) +mpf_get_prec (mpf_srcptr x) __GMP_NOTHROW { return __GMPF_PREC_TO_BITS (x->_mp_prec); } diff --git a/mpf/get_si.c b/mpf/get_si.c index a0beb2c03..5c6fd5e19 100644 --- a/mpf/get_si.c +++ b/mpf/get_si.c @@ -40,7 +40,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ -0x80000000 instead of the desired 0. */ long -mpf_get_si (mpf_srcptr f) +mpf_get_si (mpf_srcptr f) __GMP_NOTHROW { mp_exp_t exp; mp_size_t size, abs_size; diff --git a/mpf/get_ui.c b/mpf/get_ui.c index 0acaf94a8..0d909d4ab 100644 --- a/mpf/get_ui.c +++ b/mpf/get_ui.c @@ -61,7 +61,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ tested first we ensure MP_EXP_T_MIN doesn't reach exp>1. */ unsigned long -mpf_get_ui (mpf_srcptr f) +mpf_get_ui (mpf_srcptr f) __GMP_NOTHROW { mp_size_t size; mp_exp_t exp; diff --git a/mpf/int_p.c b/mpf/int_p.c index d43dcf813..316831466 100644 --- a/mpf/int_p.c +++ b/mpf/int_p.c @@ -23,7 +23,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ int -mpf_integer_p (mpf_srcptr f) +mpf_integer_p (mpf_srcptr f) __GMP_NOTHROW { mp_srcptr ptr; mp_exp_t exp; diff --git a/mpf/set_dfl_prec.c b/mpf/set_dfl_prec.c index df5248860..c209dd997 100644 --- a/mpf/set_dfl_prec.c +++ b/mpf/set_dfl_prec.c @@ -23,7 +23,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ mp_size_t __gmp_default_fp_limb_precision = __GMPF_BITS_TO_PREC (53); void -mpf_set_default_prec (mp_bitcnt_t prec_in_bits) +mpf_set_default_prec (mp_bitcnt_t prec_in_bits) __GMP_NOTHROW { __gmp_default_fp_limb_precision = __GMPF_BITS_TO_PREC (prec_in_bits); } diff --git a/mpf/set_prc_raw.c b/mpf/set_prc_raw.c index c42e7a0dc..0473b5d13 100644 --- a/mpf/set_prc_raw.c +++ b/mpf/set_prc_raw.c @@ -23,7 +23,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp-impl.h" void -mpf_set_prec_raw (mpf_ptr x, mp_bitcnt_t prec_in_bits) +mpf_set_prec_raw (mpf_ptr x, mp_bitcnt_t prec_in_bits) __GMP_NOTHROW { x->_mp_prec = __GMPF_BITS_TO_PREC (prec_in_bits); } diff --git a/mpf/set_str.c b/mpf/set_str.c index 434937061..f9f1c4a50 100644 --- a/mpf/set_str.c +++ b/mpf/set_str.c @@ -47,7 +47,6 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp-impl.h" #include "longlong.h" -extern const unsigned char __gmp_digit_value_tab[]; #define digit_value_tab __gmp_digit_value_tab /* Compute base^exp and return the most significant prec limbs in rp[]. diff --git a/mpf/size.c b/mpf/size.c index 514873e9b..34dfa5f75 100644 --- a/mpf/size.c +++ b/mpf/size.c @@ -22,7 +22,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp-impl.h" size_t -mpf_size (mpf_srcptr f) +mpf_size (mpf_srcptr f) __GMP_NOTHROW { return __GMP_ABS (f->_mp_size); } diff --git a/mpf/swap.c b/mpf/swap.c index 61c99f5cf..26934f641 100644 --- a/mpf/swap.c +++ b/mpf/swap.c @@ -21,7 +21,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp-impl.h" void -mpf_swap (mpf_ptr u, mpf_ptr v) +mpf_swap (mpf_ptr u, mpf_ptr v) __GMP_NOTHROW { mp_ptr up, vp; mp_size_t usize, vsize; diff --git a/mpn/generic/toom43_mul.c b/mpn/generic/toom43_mul.c index 670049c39..6723e2996 100644 --- a/mpn/generic/toom43_mul.c +++ b/mpn/generic/toom43_mul.c @@ -101,7 +101,7 @@ mpn_toom43_mul (mp_ptr pp, #define b1d bsm1 /* Compute as2 and asm2. */ - flags = toom6_vm2_neg & mpn_toom_eval_dgr3_pm2 (as2, asm2, ap, n, s, a1a3); + flags = (enum toom6_flags) (toom6_vm2_neg & mpn_toom_eval_dgr3_pm2 (as2, asm2, ap, n, s, a1a3)); /* Compute bs2 and bsm2. */ b1d[n] = mpn_lshift (b1d, b1, n, 1); /* 2b1 */ @@ -115,7 +115,7 @@ mpn_toom43_mul (mp_ptr pp, if (mpn_cmp (b0b2, b1d, n+1) < 0) { mpn_add_n_sub_n (bs2, bsm2, b1d, b0b2, n+1); - flags ^= toom6_vm2_neg; + flags = (enum toom6_flags) (flags ^ toom6_vm2_neg); } else { @@ -126,7 +126,7 @@ mpn_toom43_mul (mp_ptr pp, if (mpn_cmp (b0b2, b1d, n+1) < 0) { mpn_sub_n (bsm2, b1d, b0b2, n+1); - flags ^= toom6_vm2_neg; + flags = (enum toom6_flags) (flags ^ toom6_vm2_neg); } else { @@ -135,7 +135,7 @@ mpn_toom43_mul (mp_ptr pp, #endif /* Compute as1 and asm1. */ - flags ^= toom6_vm1_neg & mpn_toom_eval_dgr3_pm1 (as1, asm1, ap, n, s, a0a2); + flags = (enum toom6_flags) (flags ^ toom6_vm1_neg & mpn_toom_eval_dgr3_pm1 (as1, asm1, ap, n, s, a0a2)); /* Compute bs1 and bsm1. */ bsm1[n] = mpn_add (bsm1, b0, n, b2, t); @@ -144,7 +144,7 @@ mpn_toom43_mul (mp_ptr pp, { cy = mpn_add_n_sub_n (bs1, bsm1, b1, bsm1, n); bs1[n] = cy >> 1; - flags ^= toom6_vm1_neg; + flags = (enum toom6_flags) (flags ^ toom6_vm1_neg); } else { @@ -157,7 +157,7 @@ mpn_toom43_mul (mp_ptr pp, if (bsm1[n] == 0 && mpn_cmp (bsm1, b1, n) < 0) { mpn_sub_n (bsm1, b1, bsm1, n); - flags ^= toom6_vm1_neg; + flags = (enum toom6_flags) (flags ^ toom6_vm1_neg); } else { diff --git a/mpn/generic/toom44_mul.c b/mpn/generic/toom44_mul.c index 01a6053b7..05c43820d 100644 --- a/mpn/generic/toom44_mul.c +++ b/mpn/generic/toom44_mul.c @@ -148,10 +148,10 @@ mpn_toom44_mul (mp_ptr pp, gives roughly 32 n/3 + log term. */ /* Compute apx = a0 + 2 a1 + 4 a2 + 8 a3 and amx = a0 - 2 a1 + 4 a2 - 8 a3. */ - flags = toom7_w1_neg & mpn_toom_eval_dgr3_pm2 (apx, amx, ap, n, s, tp); + flags = (enum toom7_flags) (toom7_w1_neg & mpn_toom_eval_dgr3_pm2 (apx, amx, ap, n, s, tp)); /* Compute bpx = b0 + 2 b1 + 4 b2 + 8 b3 and bmx = b0 - 2 b1 + 4 b2 - 8 b3. */ - flags ^= toom7_w1_neg & mpn_toom_eval_dgr3_pm2 (bpx, bmx, bp, n, t, tp); + flags = (enum toom7_flags) (flags ^ toom7_w1_neg & mpn_toom_eval_dgr3_pm2 (bpx, bmx, bp, n, t, tp)); TOOM44_MUL_N_REC (v2, apx, bpx, n + 1, tp); /* v2, 2n+1 limbs */ TOOM44_MUL_N_REC (vm2, amx, bmx, n + 1, tp); /* vm2, 2n+1 limbs */ @@ -206,10 +206,10 @@ mpn_toom44_mul (mp_ptr pp, TOOM44_MUL_N_REC (vh, apx, bpx, n + 1, tp); /* vh, 2n+1 limbs */ /* Compute apx = a0 + a1 + a2 + a3 and amx = a0 - a1 + a2 - a3. */ - flags |= toom7_w3_neg & mpn_toom_eval_dgr3_pm1 (apx, amx, ap, n, s, tp); + flags = (enum toom7_flags) (flags | toom7_w3_neg & mpn_toom_eval_dgr3_pm1 (apx, amx, ap, n, s, tp)); /* Compute bpx = b0 + b1 + b2 + b3 bnd bmx = b0 - b1 + b2 - b3. */ - flags ^= toom7_w3_neg & mpn_toom_eval_dgr3_pm1 (bpx, bmx, bp, n, t, tp); + flags = (enum toom7_flags) (flags ^ toom7_w3_neg & mpn_toom_eval_dgr3_pm1 (bpx, bmx, bp, n, t, tp)); TOOM44_MUL_N_REC (vm1, amx, bmx, n + 1, tp); /* vm1, 2n+1 limbs */ /* Clobbers amx, bmx. */ diff --git a/mpn/generic/toom4_sqr.c b/mpn/generic/toom4_sqr.c index 4050c4580..cf0be2cfd 100644 --- a/mpn/generic/toom4_sqr.c +++ b/mpn/generic/toom4_sqr.c @@ -149,5 +149,5 @@ mpn_toom4_sqr (mp_ptr pp, TOOM4_SQR_REC (v0, a0, n, tp); TOOM4_SQR_REC (vinf, a3, s, tp); /* vinf, 2s limbs */ - mpn_toom_interpolate_7pts (pp, n, 0, vm2, vm1, v2, vh, 2*s, tp); + mpn_toom_interpolate_7pts (pp, n, (enum toom7_flags) 0, vm2, vm1, v2, vh, 2*s, tp); } diff --git a/mpn/generic/toom52_mul.c b/mpn/generic/toom52_mul.c index 21040fdbd..24c4fdd88 100644 --- a/mpn/generic/toom52_mul.c +++ b/mpn/generic/toom52_mul.c @@ -102,7 +102,7 @@ mpn_toom52_mul (mp_ptr pp, #define a1a3 asm1 /* Compute as2 and asm2. */ - flags = toom6_vm2_neg & mpn_toom_eval_pm2 (as2, asm2, 4, ap, n, s, a1a3); + flags = (enum toom6_flags) (toom6_vm2_neg & mpn_toom_eval_pm2 (as2, asm2, 4, ap, n, s, a1a3)); /* Compute bs1 and bsm1. */ if (t == n) @@ -113,7 +113,7 @@ mpn_toom52_mul (mp_ptr pp, if (mpn_cmp (b0, b1, n) < 0) { cy = mpn_add_n_sub_n (bs1, bsm1, b1, b0, n); - flags ^= toom6_vm1_neg; + flags = (enum toom6_flags) (flags ^ toom6_vm1_neg); } else { @@ -125,7 +125,7 @@ mpn_toom52_mul (mp_ptr pp, if (mpn_cmp (b0, b1, n) < 0) { mpn_sub_n (bsm1, b1, b0, n); - flags ^= toom6_vm1_neg; + flags = (enum toom6_flags) (flags ^ toom6_vm1_neg); } else { @@ -140,7 +140,7 @@ mpn_toom52_mul (mp_ptr pp, { mpn_sub_n (bsm1, b1, b0, t); MPN_ZERO (bsm1 + t, n - t); - flags ^= toom6_vm1_neg; + flags = (enum toom6_flags) (flags ^ toom6_vm1_neg); } else { @@ -153,7 +153,7 @@ mpn_toom52_mul (mp_ptr pp, if (flags & toom6_vm1_neg ) { bsm2[n] = mpn_add (bsm2, bsm1, n, b1, t); - flags ^= toom6_vm2_neg; + flags = (enum toom6_flags) (flags ^ toom6_vm2_neg); } else { @@ -163,7 +163,7 @@ mpn_toom52_mul (mp_ptr pp, if (mpn_cmp (bsm1, b1, n) < 0) { mpn_sub_n (bsm2, b1, bsm1, n); - flags ^= toom6_vm2_neg; + flags = (enum toom6_flags) (flags ^ toom6_vm2_neg); } else { @@ -176,7 +176,7 @@ mpn_toom52_mul (mp_ptr pp, { mpn_sub_n (bsm2, b1, bsm1, t); MPN_ZERO (bsm2 + t, n - t); - flags ^= toom6_vm2_neg; + flags = (enum toom6_flags) (flags ^ toom6_vm2_neg); } else { @@ -186,7 +186,7 @@ mpn_toom52_mul (mp_ptr pp, } /* Compute as1 and asm1. */ - flags ^= toom6_vm1_neg & mpn_toom_eval_pm1 (as1, asm1, 4, ap, n, s, a0a2); + flags = (enum toom6_flags) (flags ^ toom6_vm1_neg & mpn_toom_eval_pm1 (as1, asm1, 4, ap, n, s, a0a2)); ASSERT (as1[n] <= 4); ASSERT (bs1[n] <= 1); diff --git a/mpn/generic/toom53_mul.c b/mpn/generic/toom53_mul.c index 8a0807a4c..d62a3dc7e 100644 --- a/mpn/generic/toom53_mul.c +++ b/mpn/generic/toom53_mul.c @@ -96,10 +96,10 @@ mpn_toom53_mul (mp_ptr pp, gp = pp; /* Compute as1 and asm1. */ - flags = toom7_w3_neg & mpn_toom_eval_pm1 (as1, asm1, 4, ap, n, s, gp); + flags = (enum toom7_flags) (toom7_w3_neg & mpn_toom_eval_pm1 (as1, asm1, 4, ap, n, s, gp)); /* Compute as2 and asm2. */ - flags |= toom7_w1_neg & mpn_toom_eval_pm2 (as2, asm2, 4, ap, n, s, gp); + flags = (enum toom7_flags) (flags | toom7_w1_neg & mpn_toom_eval_pm2 (as2, asm2, 4, ap, n, s, gp)); /* Compute ash = 16 a0 + 8 a1 + 4 a2 + 2 a3 + a4 = 2*(2*(2*(2*a0 + a1) + a2) + a3) + a4 */ @@ -134,7 +134,7 @@ mpn_toom53_mul (mp_ptr pp, { bs1[n] = mpn_add_n_sub_n (bs1, bsm1, b1, bs1, n) >> 1; bsm1[n] = 0; - flags ^= toom7_w3_neg; + flags = (enum toom7_flags) (flags ^ toom7_w3_neg); } else { @@ -147,7 +147,7 @@ mpn_toom53_mul (mp_ptr pp, { mpn_sub_n (bsm1, b1, bs1, n); bsm1[n] = 0; - flags ^= toom7_w3_neg; + flags = (enum toom7_flags) (flags ^ toom7_w3_neg); } else { @@ -178,7 +178,7 @@ mpn_toom53_mul (mp_ptr pp, if (mpn_cmp (bs2, gp, n+1) < 0) { ASSERT_NOCARRY (mpn_add_n_sub_n (bs2, bsm2, gp, bs2, n+1)); - flags ^= toom7_w1_neg; + flags = (enum toom7_flags) (flags ^ toom7_w1_neg); } else { @@ -188,7 +188,7 @@ mpn_toom53_mul (mp_ptr pp, if (mpn_cmp (bs2, gp, n+1) < 0) { ASSERT_NOCARRY (mpn_sub_n (bsm2, gp, bs2, n+1)); - flags ^= toom7_w1_neg; + flags = (enum toom7_flags) (flags ^ toom7_w1_neg); } else { diff --git a/mpn/generic/toom62_mul.c b/mpn/generic/toom62_mul.c index c01cfba2c..04664e08b 100644 --- a/mpn/generic/toom62_mul.c +++ b/mpn/generic/toom62_mul.c @@ -97,10 +97,10 @@ mpn_toom62_mul (mp_ptr pp, gp = pp; /* Compute as1 and asm1. */ - aflags = toom7_w3_neg & mpn_toom_eval_pm1 (as1, asm1, 5, ap, n, s, gp); + aflags = (enum toom7_flags) (toom7_w3_neg & mpn_toom_eval_pm1 (as1, asm1, 5, ap, n, s, gp)); /* Compute as2 and asm2. */ - aflags |= toom7_w1_neg & mpn_toom_eval_pm2 (as2, asm2, 5, ap, n, s, gp); + aflags = (enum toom7_flags) (aflags | toom7_w1_neg & mpn_toom_eval_pm2 (as2, asm2, 5, ap, n, s, gp)); /* Compute ash = 32 a0 + 16 a1 + 8 a2 + 4 a3 + 2 a4 + a5 = 2*(2*(2*(2*(2*a0 + a1) + a2) + a3) + a4) + a5 */ @@ -157,7 +157,7 @@ mpn_toom62_mul (mp_ptr pp, else { mpn_sub_n (bsm1, b0, b1, n); - bflags = 0; + bflags = (enum toom7_flags) 0; } #endif } @@ -173,7 +173,7 @@ mpn_toom62_mul (mp_ptr pp, else { mpn_sub (bsm1, b0, n, b1, t); - bflags = 0; + bflags = (enum toom7_flags) 0; } } @@ -183,7 +183,7 @@ mpn_toom62_mul (mp_ptr pp, if (bflags & toom7_w3_neg) { bsm2[n] = mpn_add (bsm2, bsm1, n, b1, t); - bflags |= toom7_w1_neg; + bflags = (enum toom7_flags) (bflags | toom7_w1_neg); } else { @@ -194,7 +194,7 @@ mpn_toom62_mul (mp_ptr pp, { ASSERT_NOCARRY (mpn_sub_n (bsm2, b1, bsm1, t)); MPN_ZERO (bsm2 + t, n + 1 - t); - bflags |= toom7_w1_neg; + bflags = (enum toom7_flags) (bflags | toom7_w1_neg); } else { @@ -207,7 +207,7 @@ mpn_toom62_mul (mp_ptr pp, if (mpn_cmp (bsm1, b1, n) < 0) { ASSERT_NOCARRY (mpn_sub_n (bsm2, b1, bsm1, n)); - bflags |= toom7_w1_neg; + bflags = (enum toom7_flags) (bflags | toom7_w1_neg); } else { @@ -293,7 +293,7 @@ mpn_toom62_mul (mp_ptr pp, if (s > t) mpn_mul (vinf, a5, s, b1, t); else mpn_mul (vinf, b1, t, a5, s); - mpn_toom_interpolate_7pts (pp, n, aflags ^ bflags, + mpn_toom_interpolate_7pts (pp, n, (enum toom7_flags) (aflags ^ bflags), vm2, vm1, v2, vh, s + t, scratch_out); TMP_FREE; diff --git a/mpq/equal.c b/mpq/equal.c index e5c5f8e5e..36f7d372d 100644 --- a/mpq/equal.c +++ b/mpq/equal.c @@ -22,7 +22,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp-impl.h" int -mpq_equal (mpq_srcptr op1, mpq_srcptr op2) +mpq_equal (mpq_srcptr op1, mpq_srcptr op2) __GMP_NOTHROW { mp_size_t num1_size, num2_size, den1_size, den2_size, i; mp_srcptr num1_ptr, num2_ptr, den1_ptr, den2_ptr; diff --git a/mpq/swap.c b/mpq/swap.c index 507e7d51d..e1d96cc47 100644 --- a/mpq/swap.c +++ b/mpq/swap.c @@ -21,7 +21,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp-impl.h" void -mpq_swap (mpq_ptr u, mpq_ptr v) +mpq_swap (mpq_ptr u, mpq_ptr v) __GMP_NOTHROW { mp_ptr up, vp; mp_size_t usize, vsize; diff --git a/mpz/clrbit.c b/mpz/clrbit.c index d08d68477..30857f6bf 100644 --- a/mpz/clrbit.c +++ b/mpz/clrbit.c @@ -74,8 +74,7 @@ mpz_clrbit (mpz_ptr d, mp_bitcnt_t bit_index) { /* Ugh. The bit should be cleared outside of the end of the number. We have to increase the size of the number. */ - if (UNLIKELY (d->_mp_alloc < limb_index + 1)) - dp = _mpz_realloc (d, limb_index + 1); + dp = MPZ_REALLOC (d, limb_index + 1); MPN_ZERO (dp + dsize, limb_index - dsize); dp[limb_index] = (mp_limb_t) 1 << (bit_index % GMP_NUMB_BITS); @@ -99,8 +98,7 @@ mpz_clrbit (mpz_ptr d, mp_bitcnt_t bit_index) /* We got carry all way out beyond the end of D. Increase its size (and allocation if necessary). */ dsize++; - if (UNLIKELY (d->_mp_alloc < dsize)) - dp = _mpz_realloc (d, dsize); + dp = MPZ_REALLOC (d, dsize); dp[i] = 1; d->_mp_size = -dsize; @@ -28,7 +28,7 @@ int #ifdef BERKELEY_MP mcmp (mpz_srcptr u, mpz_srcptr v) #else -mpz_cmp (mpz_srcptr u, mpz_srcptr v) +mpz_cmp (mpz_srcptr u, mpz_srcptr v) __GMP_NOTHROW #endif { mp_size_t usize, vsize, dsize, asize; diff --git a/mpz/cmp_si.c b/mpz/cmp_si.c index f53932e13..a8acdeffe 100644 --- a/mpz/cmp_si.c +++ b/mpz/cmp_si.c @@ -23,7 +23,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp-impl.h" int -_mpz_cmp_si (mpz_srcptr u, signed long int v_digit) +_mpz_cmp_si (mpz_srcptr u, signed long int v_digit) __GMP_NOTHROW { mp_size_t usize = u->_mp_size; mp_size_t vsize; diff --git a/mpz/cmp_ui.c b/mpz/cmp_ui.c index e5702c159..f9f27ba49 100644 --- a/mpz/cmp_ui.c +++ b/mpz/cmp_ui.c @@ -23,7 +23,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp-impl.h" int -_mpz_cmp_ui (mpz_srcptr u, unsigned long int v_digit) +_mpz_cmp_ui (mpz_srcptr u, unsigned long int v_digit) __GMP_NOTHROW { mp_ptr up; mp_size_t un; diff --git a/mpz/cmpabs.c b/mpz/cmpabs.c index ec3e98e5b..f7bbcd7c7 100644 --- a/mpz/cmpabs.c +++ b/mpz/cmpabs.c @@ -24,7 +24,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ int -mpz_cmpabs (mpz_srcptr u, mpz_srcptr v) +mpz_cmpabs (mpz_srcptr u, mpz_srcptr v) __GMP_NOTHROW { mp_size_t usize, vsize, dsize; mp_srcptr up, vp; diff --git a/mpz/cmpabs_ui.c b/mpz/cmpabs_ui.c index 881692de6..f8df4b8c4 100644 --- a/mpz/cmpabs_ui.c +++ b/mpz/cmpabs_ui.c @@ -23,7 +23,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp-impl.h" int -mpz_cmpabs_ui (mpz_srcptr u, unsigned long int v_digit) +mpz_cmpabs_ui (mpz_srcptr u, unsigned long int v_digit) __GMP_NOTHROW { mp_ptr up; mp_size_t un; diff --git a/mpz/cong_2exp.c b/mpz/cong_2exp.c index f9a7f153e..bf3ae54cc 100644 --- a/mpz/cong_2exp.c +++ b/mpz/cong_2exp.c @@ -22,7 +22,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ int -mpz_congruent_2exp_p (mpz_srcptr a, mpz_srcptr c, mp_bitcnt_t d) +mpz_congruent_2exp_p (mpz_srcptr a, mpz_srcptr c, mp_bitcnt_t d) __GMP_NOTHROW { mp_size_t i, dlimbs; unsigned dbits; diff --git a/mpz/divis_2exp.c b/mpz/divis_2exp.c index f01aafeee..814037fdf 100644 --- a/mpz/divis_2exp.c +++ b/mpz/divis_2exp.c @@ -22,7 +22,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ int -mpz_divisible_2exp_p (mpz_srcptr a, mp_bitcnt_t d) +mpz_divisible_2exp_p (mpz_srcptr a, mp_bitcnt_t d) __GMP_NOTHROW { mp_size_t i, dlimbs; unsigned dbits; diff --git a/mpz/fits_s.h b/mpz/fits_s.h index a91e82189..d690c08df 100644 --- a/mpz/fits_s.h +++ b/mpz/fits_s.h @@ -22,7 +22,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ int -FUNCTION (mpz_srcptr z) +FUNCTION (mpz_srcptr z) __GMP_NOTHROW { mp_size_t n = SIZ(z); mp_ptr p = PTR(z); diff --git a/mpz/get_si.c b/mpz/get_si.c index 1308308fe..d24a4e47d 100644 --- a/mpz/get_si.c +++ b/mpz/get_si.c @@ -22,7 +22,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp-impl.h" signed long int -mpz_get_si (mpz_srcptr z) +mpz_get_si (mpz_srcptr z) __GMP_NOTHROW { mp_ptr zp = z->_mp_d; mp_size_t size = z->_mp_size; diff --git a/mpz/hamdist.c b/mpz/hamdist.c index bd4dcd707..06a23411f 100644 --- a/mpz/hamdist.c +++ b/mpz/hamdist.c @@ -22,7 +22,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ mp_bitcnt_t -mpz_hamdist (mpz_srcptr u, mpz_srcptr v) +mpz_hamdist (mpz_srcptr u, mpz_srcptr v) __GMP_NOTHROW { mp_srcptr up, vp; mp_size_t usize, vsize; diff --git a/mpz/inp_str.c b/mpz/inp_str.c index 05c8cde90..b0ebb971f 100644 --- a/mpz/inp_str.c +++ b/mpz/inp_str.c @@ -28,7 +28,6 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp.h" #include "gmp-impl.h" -extern const unsigned char __gmp_digit_value_tab[]; #define digit_value_tab __gmp_digit_value_tab size_t diff --git a/mpz/powm.c b/mpz/powm.c index 29b0132c4..369fd36c3 100644 --- a/mpz/powm.c +++ b/mpz/powm.c @@ -158,11 +158,11 @@ pow (mpz_srcptr b, mpz_srcptr e, mpz_srcptr m, mpz_ptr r) cnt = 0; if (mp[0] % 2 == 0) { - mp_ptr new = TMP_ALLOC_LIMBS (nodd); + mp_ptr newmp = TMP_ALLOC_LIMBS (nodd); count_trailing_zeros (cnt, mp[0]); - mpn_rshift (new, mp, nodd, cnt); - nodd -= new[nodd - 1] == 0; - mp = new; + mpn_rshift (newmp, mp, nodd, cnt); + nodd -= newmp[nodd - 1] == 0; + mp = newmp; ncnt++; } @@ -197,10 +197,10 @@ pow (mpz_srcptr b, mpz_srcptr e, mpz_srcptr m, mpz_ptr r) if (bn < ncnt) { - mp_ptr new = TMP_ALLOC_LIMBS (ncnt); - MPN_COPY (new, bp, bn); - MPN_ZERO (new + bn, ncnt - bn); - bp = new; + mp_ptr newbp = TMP_ALLOC_LIMBS (ncnt); + MPN_COPY (newbp, bp, bn); + MPN_ZERO (newbp + bn, ncnt - bn); + bp = newbp; } r2 = tp; @@ -232,10 +232,10 @@ pow (mpz_srcptr b, mpz_srcptr e, mpz_srcptr m, mpz_ptr r) zero: if (nodd < ncnt) { - mp_ptr new = TMP_ALLOC_LIMBS (ncnt); - MPN_COPY (new, mp, nodd); - MPN_ZERO (new + nodd, ncnt - nodd); - mp = new; + mp_ptr newmp = TMP_ALLOC_LIMBS (ncnt); + MPN_COPY (newmp, mp, nodd); + MPN_ZERO (newmp + nodd, ncnt - nodd); + mp = newmp; } odd_inv_2exp = tp + n; diff --git a/mpz/scan0.c b/mpz/scan0.c index 9cb05337d..d83142ab2 100644 --- a/mpz/scan0.c +++ b/mpz/scan0.c @@ -28,7 +28,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ reasonable to inline that code. */ mp_bitcnt_t -mpz_scan0 (mpz_srcptr u, mp_bitcnt_t starting_bit) +mpz_scan0 (mpz_srcptr u, mp_bitcnt_t starting_bit) __GMP_NOTHROW { mp_srcptr u_ptr = PTR(u); mp_size_t size = SIZ(u); diff --git a/mpz/scan1.c b/mpz/scan1.c index dcf77986f..644fda677 100644 --- a/mpz/scan1.c +++ b/mpz/scan1.c @@ -28,7 +28,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ so it seems reasonable to inline that code. */ mp_bitcnt_t -mpz_scan1 (mpz_srcptr u, mp_bitcnt_t starting_bit) +mpz_scan1 (mpz_srcptr u, mp_bitcnt_t starting_bit) __GMP_NOTHROW { mp_srcptr u_ptr = PTR(u); mp_size_t size = SIZ(u); diff --git a/mpz/set_str.c b/mpz/set_str.c index 550c4866b..cdea7a248 100644 --- a/mpz/set_str.c +++ b/mpz/set_str.c @@ -27,7 +27,6 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp.h" #include "gmp-impl.h" -extern const unsigned char __gmp_digit_value_tab[]; #define digit_value_tab __gmp_digit_value_tab int diff --git a/mpz/setbit.c b/mpz/setbit.c index 6d9b4020d..364e8bb95 100644 --- a/mpz/setbit.c +++ b/mpz/setbit.c @@ -40,8 +40,7 @@ mpz_setbit (mpz_ptr d, mp_bitcnt_t bit_index) { /* Ugh. The bit should be set outside of the end of the number. We have to increase the size of the number. */ - if (UNLIKELY (d->_mp_alloc < limb_index + 1)) - dp = _mpz_realloc (d, limb_index + 1); + dp = MPZ_REALLOC (d, limb_index + 1); MPN_ZERO (dp + dsize, limb_index - dsize); dp[limb_index] = (mp_limb_t) 1 << (bit_index % GMP_NUMB_BITS); d->_mp_size = limb_index + 1; @@ -99,8 +98,7 @@ mpz_setbit (mpz_ptr d, mp_bitcnt_t bit_index) /* We got carry all way out beyond the end of D. Increase its size (and allocation if necessary). */ dsize++; - if (UNLIKELY (d->_mp_alloc < dsize)) - dp = _mpz_realloc (d, dsize); + dp = MPZ_REALLOC (d, dsize); dp[i] = 1; d->_mp_size = -dsize; fin:; diff --git a/mpz/sizeinbase.c b/mpz/sizeinbase.c index 1b2f5b1b4..d70e87832 100644 --- a/mpz/sizeinbase.c +++ b/mpz/sizeinbase.c @@ -24,7 +24,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "longlong.h" size_t -mpz_sizeinbase (mpz_srcptr x, int base) +mpz_sizeinbase (mpz_srcptr x, int base) __GMP_NOTHROW { size_t result; MPN_SIZEINBASE (result, PTR(x), ABSIZ(x), base); diff --git a/mpz/swap.c b/mpz/swap.c index 1fdfcc110..de8195a7d 100644 --- a/mpz/swap.c +++ b/mpz/swap.c @@ -21,7 +21,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp-impl.h" void -mpz_swap (mpz_ptr u, mpz_ptr v) +mpz_swap (mpz_ptr u, mpz_ptr v) __GMP_NOTHROW { mp_ptr up, vp; mp_size_t usize, vsize; diff --git a/mpz/tstbit.c b/mpz/tstbit.c index 02133cc00..c3006c813 100644 --- a/mpz/tstbit.c +++ b/mpz/tstbit.c @@ -38,7 +38,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ the limb_index >= abs_size test covers u=0 too. */ int -mpz_tstbit (mpz_srcptr u, mp_bitcnt_t bit_index) +mpz_tstbit (mpz_srcptr u, mp_bitcnt_t bit_index) __GMP_NOTHROW { mp_srcptr u_ptr = PTR(u); mp_size_t size = SIZ(u); diff --git a/randlc2x.c b/randlc2x.c index ba45b60bd..b95eff254 100644 --- a/randlc2x.c +++ b/randlc2x.c @@ -257,9 +257,9 @@ randiset_lc (gmp_randstate_ptr dst, gmp_randstate_srcptr src) gmp_rand_lc_struct *dstp, *srcp; srcp = (gmp_rand_lc_struct *) RNG_STATE (src); - dstp = (*__gmp_allocate_func) (sizeof (gmp_rand_lc_struct)); + dstp = (gmp_rand_lc_struct *) (*__gmp_allocate_func) (sizeof (gmp_rand_lc_struct)); - RNG_STATE (dst) = (void *) dstp; + RNG_STATE (dst) = (mp_limb_t *) (void *) dstp; RNG_FNPTR (dst) = (void *) &Linear_Congruential_Generator; /* _mp_seed and _mp_a might be unnormalized (high zero limbs), but @@ -291,7 +291,7 @@ gmp_randinit_lc_2exp (gmp_randstate_t rstate, ASSERT_ALWAYS (m2exp != 0); p = __GMP_ALLOCATE_FUNC_TYPE (1, gmp_rand_lc_struct); - RNG_STATE (rstate) = (void *) p; + RNG_STATE (rstate) = (mp_limb_t *) (void *) p; RNG_FNPTR (rstate) = (void *) &Linear_Congruential_Generator; /* allocate m2exp bits of space for p->_mp_seed, and initial seed "1" */ diff --git a/tal-reent.c b/tal-reent.c index 32db9342c..87da7f3c8 100644 --- a/tal-reent.c +++ b/tal-reent.c @@ -50,7 +50,7 @@ __gmp_tmp_reentrant_alloc (struct tmp_reentrant_t **markp, size_t size) #define P ((struct tmp_reentrant_t *) p) total_size = size + HSIZ; - p = (*__gmp_allocate_func) (total_size); + p = (char *) (*__gmp_allocate_func) (total_size); P->size = total_size; P->next = *markp; *markp = P; diff --git a/tests/memory.c b/tests/memory.c index ea1238101..ec7513597 100644 --- a/tests/memory.c +++ b/tests/memory.c @@ -22,6 +22,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include <string.h> /* for memcpy, memcmp */ #include "gmp.h" #include "gmp-impl.h" +#include "tests.h" #if GMP_LIMB_BITS == 64 #define PATTERN1 CNST_LIMB(0xcafebabedeadbeef) diff --git a/tests/misc.c b/tests/misc.c index 3ad27e5d2..76afac513 100644 --- a/tests/misc.c +++ b/tests/misc.c @@ -163,7 +163,7 @@ __gmp_allocate_strdup (const char *s) size_t len; char *t; len = strlen (s); - t = (*__gmp_allocate_func) (len+1); + t = (char *) (*__gmp_allocate_func) (len+1); memcpy (t, s, len+1); return t; } diff --git a/tests/misc/t-printf.c b/tests/misc/t-printf.c index d6026b2d0..ad8fc3081 100644 --- a/tests/misc/t-printf.c +++ b/tests/misc/t-printf.c @@ -100,7 +100,7 @@ check_plain (va_alist) return; fmtsize = strlen (fmt_orig) + 1; - fmt = (*__gmp_allocate_func) (fmtsize); + fmt = (char *) (*__gmp_allocate_func) (fmtsize); for (p = fmt_orig, q = fmt; *p != '\0'; p++) { diff --git a/tests/misc/t-scanf.c b/tests/misc/t-scanf.c index 5a9eda1fc..b948a2df7 100644 --- a/tests/misc/t-scanf.c +++ b/tests/misc/t-scanf.c @@ -229,7 +229,7 @@ fun_sscanf (const char *input, const char *fmt, void *a1, void *a2) int ret; size = strlen (input) + 1; - input_writable = (*__gmp_allocate_func) (size); + input_writable = (char *) (*__gmp_allocate_func) (size); memcpy (input_writable, input, size); if (a2 == NULL) diff --git a/tests/mpz/convert.c b/tests/mpz/convert.c index 2ab420563..7d57bb112 100644 --- a/tests/mpz/convert.c +++ b/tests/mpz/convert.c @@ -129,7 +129,7 @@ main (int argc, char **argv) size_range = mpz_get_ui (bs) % 16 + 1; /* 1..16 */ mpz_urandomb (bs, rands, size_range); /* 1..65536 digits */ len = mpz_get_ui (bs) + 1; - buf = (*__gmp_allocate_func) (len + 1); + buf = (char *) (*__gmp_allocate_func) (len + 1); if (base == 0) base = 10; string_urandomb (buf, len, base, rands); diff --git a/tests/refmpn.c b/tests/refmpn.c index 9572212ef..ec3f09a05 100644 --- a/tests/refmpn.c +++ b/tests/refmpn.c @@ -46,8 +46,8 @@ int byte_overlap_p (const void *v_xp, mp_size_t xsize, const void *v_yp, mp_size_t ysize) { - const char *xp = v_xp; - const char *yp = v_yp; + const char *xp = (const char *) v_xp; + const char *yp = (const char *) v_yp; ASSERT (xsize >= 0); ASSERT (ysize >= 0); diff --git a/tests/tests.h b/tests/tests.h index e82f03283..b433817ef 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -434,7 +434,7 @@ void refmpz_pow_ui __GMP_PROTO ((mpz_ptr w, mpz_srcptr b, unsigned long e)); full implementation, just enough for our purposes. */ #ifdef __cplusplus -#if HAVE_SSTREAM +#if 1 || HAVE_SSTREAM #include <sstream> #else /* ! HAVE_SSTREAM */ #include <string> |