Hello,the latest version of gcc has a new (questionable) warning that complains if a function is declared as taking a mpz_t parameter and redeclared as taking mpz_ptr, or the reverse.
We might as well be consistent and use pointers everywhere, as in the attached patch. Does someone disagree?
-- Marc Glisse
diff -r 632506b00743 gmp-h.in --- a/gmp-h.in Sat May 08 19:34:05 2021 +0200 +++ b/gmp-h.in Wed May 12 15:07:25 2021 +0200 @@ -227,6 +227,8 @@ typedef __mpf_struct *mpf_ptr; typedef const __mpq_struct *mpq_srcptr; typedef __mpq_struct *mpq_ptr; +typedef __gmp_randstate_struct *gmp_randstate_ptr; +typedef const __gmp_randstate_struct *gmp_randstate_srcptr; #if __GMP_LIBGMP_DLL @@ -498,37 +500,37 @@ /* obsolete */ #define gmp_randinit __gmp_randinit -__GMP_DECLSPEC void gmp_randinit (gmp_randstate_t, gmp_randalg_t, ...); +__GMP_DECLSPEC void gmp_randinit (gmp_randstate_ptr, gmp_randalg_t, ...); #define gmp_randinit_default __gmp_randinit_default -__GMP_DECLSPEC void gmp_randinit_default (gmp_randstate_t); +__GMP_DECLSPEC void gmp_randinit_default (gmp_randstate_ptr); #define gmp_randinit_lc_2exp __gmp_randinit_lc_2exp -__GMP_DECLSPEC void gmp_randinit_lc_2exp (gmp_randstate_t, mpz_srcptr, unsigned long int, mp_bitcnt_t); +__GMP_DECLSPEC void gmp_randinit_lc_2exp (gmp_randstate_ptr, mpz_srcptr, unsigned long int, mp_bitcnt_t); #define gmp_randinit_lc_2exp_size __gmp_randinit_lc_2exp_size -__GMP_DECLSPEC int gmp_randinit_lc_2exp_size (gmp_randstate_t, mp_bitcnt_t); +__GMP_DECLSPEC int gmp_randinit_lc_2exp_size (gmp_randstate_ptr, mp_bitcnt_t); #define gmp_randinit_mt __gmp_randinit_mt -__GMP_DECLSPEC void gmp_randinit_mt (gmp_randstate_t); +__GMP_DECLSPEC void gmp_randinit_mt (gmp_randstate_ptr); #define gmp_randinit_set __gmp_randinit_set -__GMP_DECLSPEC void gmp_randinit_set (gmp_randstate_t, const __gmp_randstate_struct *); +__GMP_DECLSPEC void gmp_randinit_set (gmp_randstate_ptr, gmp_randstate_srcptr); #define gmp_randseed __gmp_randseed -__GMP_DECLSPEC void gmp_randseed (gmp_randstate_t, mpz_srcptr); +__GMP_DECLSPEC void gmp_randseed (gmp_randstate_ptr, mpz_srcptr); #define gmp_randseed_ui __gmp_randseed_ui -__GMP_DECLSPEC void gmp_randseed_ui (gmp_randstate_t, unsigned long int); +__GMP_DECLSPEC void gmp_randseed_ui (gmp_randstate_ptr, unsigned long int); #define gmp_randclear __gmp_randclear -__GMP_DECLSPEC void gmp_randclear (gmp_randstate_t); +__GMP_DECLSPEC void gmp_randclear (gmp_randstate_ptr); #define gmp_urandomb_ui __gmp_urandomb_ui -__GMP_DECLSPEC unsigned long gmp_urandomb_ui (gmp_randstate_t, unsigned long); +__GMP_DECLSPEC unsigned long gmp_urandomb_ui (gmp_randstate_ptr, unsigned long); #define gmp_urandomm_ui __gmp_urandomm_ui -__GMP_DECLSPEC unsigned long gmp_urandomm_ui (gmp_randstate_t, unsigned long); +__GMP_DECLSPEC unsigned long gmp_urandomm_ui (gmp_randstate_ptr, unsigned long); /**************** Formatted output routines. ****************/ @@ -1008,7 +1010,7 @@ __GMP_DECLSPEC void mpz_rootrem (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int); #define mpz_rrandomb __gmpz_rrandomb -__GMP_DECLSPEC void mpz_rrandomb (mpz_ptr, gmp_randstate_t, mp_bitcnt_t); +__GMP_DECLSPEC void mpz_rrandomb (mpz_ptr, gmp_randstate_ptr, mp_bitcnt_t); #define mpz_scan0 __gmpz_scan0 __GMP_DECLSPEC mp_bitcnt_t mpz_scan0 (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; @@ -1108,10 +1110,10 @@ __GMP_DECLSPEC void mpz_ui_pow_ui (mpz_ptr, unsigned long int, unsigned long int); #define mpz_urandomb __gmpz_urandomb -__GMP_DECLSPEC void mpz_urandomb (mpz_ptr, gmp_randstate_t, mp_bitcnt_t); +__GMP_DECLSPEC void mpz_urandomb (mpz_ptr, gmp_randstate_ptr, mp_bitcnt_t); #define mpz_urandomm __gmpz_urandomm -__GMP_DECLSPEC void mpz_urandomm (mpz_ptr, gmp_randstate_t, mpz_srcptr); +__GMP_DECLSPEC void mpz_urandomm (mpz_ptr, gmp_randstate_ptr, mpz_srcptr); #define mpz_xor __gmpz_xor #define mpz_eor __gmpz_xor @@ -1457,7 +1459,7 @@ __GMP_DECLSPEC void mpf_ui_sub (mpf_ptr, unsigned long int, mpf_srcptr); #define mpf_urandomb __gmpf_urandomb -__GMP_DECLSPEC void mpf_urandomb (mpf_t, gmp_randstate_t, mp_bitcnt_t); +__GMP_DECLSPEC void mpf_urandomb (mpf_ptr, gmp_randstate_ptr, mp_bitcnt_t); /************ Low level positive-integer (i.e. N) routines. ************/ diff -r 632506b00743 gmp-impl.h --- a/gmp-impl.h Sat May 08 19:34:05 2021 +0200 +++ b/gmp-impl.h Wed May 12 15:07:25 2021 +0200 @@ -1287,14 +1287,11 @@ return itch; } -typedef __gmp_randstate_struct *gmp_randstate_ptr; -typedef const __gmp_randstate_struct *gmp_randstate_srcptr; - /* Pseudo-random number generator function pointers structure. */ typedef struct { - void (*randseed_fn) (gmp_randstate_t, mpz_srcptr); - void (*randget_fn) (gmp_randstate_t, mp_ptr, unsigned long int); - void (*randclear_fn) (gmp_randstate_t); + void (*randseed_fn) (gmp_randstate_ptr, mpz_srcptr); + void (*randget_fn) (gmp_randstate_ptr, mp_ptr, unsigned long int); + void (*randclear_fn) (gmp_randstate_ptr); void (*randiset_fn) (gmp_randstate_ptr, gmp_randstate_srcptr); } gmp_randfnptr_t; @@ -1313,7 +1310,7 @@ (__rstate, rp, bits); \ } while (0) -__GMP_DECLSPEC void __gmp_randinit_mt_noseed (gmp_randstate_t); +__GMP_DECLSPEC void __gmp_randinit_mt_noseed (gmp_randstate_ptr); /* __gmp_rands is the global state for the old-style random functions, and diff -r 632506b00743 mpf/reldiff.c --- a/mpf/reldiff.c Sat May 08 19:34:05 2021 +0200 +++ b/mpf/reldiff.c Wed May 12 15:07:25 2021 +0200 @@ -36,7 +36,7 @@ So rprec+1 == dsize - xsize + 1, hence dprec = rprec+xsize. */ void -mpf_reldiff (mpf_t rdiff, mpf_srcptr x, mpf_srcptr y) +mpf_reldiff (mpf_ptr rdiff, mpf_srcptr x, mpf_srcptr y) { if (UNLIKELY (SIZ(x) == 0)) { diff -r 632506b00743 mpf/set_q.c --- a/mpf/set_q.c Sat May 08 19:34:05 2021 +0200 +++ b/mpf/set_q.c Wed May 12 15:07:25 2021 +0200 @@ -51,7 +51,7 @@ to save one limb in the division. */ void -mpf_set_q (mpf_t r, mpq_srcptr q) +mpf_set_q (mpf_ptr r, mpq_srcptr q) { mp_srcptr np, dp; mp_size_t prec, nsize, dsize, qsize, prospective_qsize, tsize, zeros; diff -r 632506b00743 mpf/urandomb.c --- a/mpf/urandomb.c Sat May 08 19:34:05 2021 +0200 +++ b/mpf/urandomb.c Wed May 12 15:07:25 2021 +0200 @@ -34,7 +34,7 @@ #include "gmp-impl.h" void -mpf_urandomb (mpf_t rop, gmp_randstate_t rstate, mp_bitcnt_t nbits) +mpf_urandomb (mpf_ptr rop, gmp_randstate_ptr rstate, mp_bitcnt_t nbits) { mp_ptr rp; mp_size_t nlimbs; diff -r 632506b00743 mpq/canonicalize.c --- a/mpq/canonicalize.c Sat May 08 19:34:05 2021 +0200 +++ b/mpq/canonicalize.c Wed May 12 15:07:25 2021 +0200 @@ -32,7 +32,7 @@ #include "gmp-impl.h" void -mpq_canonicalize (mpq_t op) +mpq_canonicalize (mpq_ptr op) { mpz_t gcd; TMP_DECL; diff -r 632506b00743 mpq/clear.c --- a/mpq/clear.c Sat May 08 19:34:05 2021 +0200 +++ b/mpq/clear.c Wed May 12 15:07:25 2021 +0200 @@ -32,7 +32,7 @@ #include "gmp-impl.h" void -mpq_clear (mpq_t x) +mpq_clear (mpq_ptr x) { if (ALLOC (NUM(x))) __GMP_FREE_FUNC_LIMBS (PTR(NUM(x)), ALLOC(NUM(x))); diff -r 632506b00743 mpq/init.c --- a/mpq/init.c Sat May 08 19:34:05 2021 +0200 +++ b/mpq/init.c Wed May 12 15:07:25 2021 +0200 @@ -32,7 +32,7 @@ #include "gmp-impl.h" void -mpq_init (mpq_t x) +mpq_init (mpq_ptr x) { static const mp_limb_t dummy_limb=0xc1a0; ALLOC(NUM(x)) = 0; diff -r 632506b00743 mpq/set_si.c --- a/mpq/set_si.c Sat May 08 19:34:05 2021 +0200 +++ b/mpq/set_si.c Wed May 12 15:07:25 2021 +0200 @@ -32,7 +32,7 @@ #include "gmp-impl.h" void -mpq_set_si (mpq_t dest, signed long int num, unsigned long int den) +mpq_set_si (mpq_ptr dest, signed long int num, unsigned long int den) { if (GMP_NUMB_BITS < BITS_PER_ULONG) { diff -r 632506b00743 mpq/set_ui.c --- a/mpq/set_ui.c Sat May 08 19:34:05 2021 +0200 +++ b/mpq/set_ui.c Wed May 12 15:07:25 2021 +0200 @@ -32,7 +32,7 @@ #include "gmp-impl.h" void -mpq_set_ui (mpq_t dest, unsigned long int num, unsigned long int den) +mpq_set_ui (mpq_ptr dest, unsigned long int num, unsigned long int den) { if (GMP_NUMB_BITS < BITS_PER_ULONG) { diff -r 632506b00743 mpz/rrandomb.c --- a/mpz/rrandomb.c Sat May 08 19:34:05 2021 +0200 +++ b/mpz/rrandomb.c Wed May 12 15:07:25 2021 +0200 @@ -32,10 +32,10 @@ #include "gmp-impl.h" -static void gmp_rrandomb (mp_ptr, gmp_randstate_t, mp_bitcnt_t); +static void gmp_rrandomb (mp_ptr, gmp_randstate_ptr, mp_bitcnt_t); void -mpz_rrandomb (mpz_ptr x, gmp_randstate_t rstate, mp_bitcnt_t nbits) +mpz_rrandomb (mpz_ptr x, gmp_randstate_ptr rstate, mp_bitcnt_t nbits) { mp_size_t nl; mp_ptr xp; @@ -60,7 +60,7 @@ #endif static void -gmp_rrandomb (mp_ptr rp, gmp_randstate_t rstate, mp_bitcnt_t nbits) +gmp_rrandomb (mp_ptr rp, gmp_randstate_ptr rstate, mp_bitcnt_t nbits) { mp_bitcnt_t bi; mp_limb_t ranm; /* buffer for random bits */ diff -r 632506b00743 mpz/urandomb.c --- a/mpz/urandomb.c Sat May 08 19:34:05 2021 +0200 +++ b/mpz/urandomb.c Wed May 12 15:07:25 2021 +0200 @@ -33,7 +33,7 @@ #include "gmp-impl.h" void -mpz_urandomb (mpz_ptr rop, gmp_randstate_t rstate, mp_bitcnt_t nbits) +mpz_urandomb (mpz_ptr rop, gmp_randstate_ptr rstate, mp_bitcnt_t nbits) { mp_ptr rp; mp_size_t size; diff -r 632506b00743 mpz/urandomm.c --- a/mpz/urandomm.c Sat May 08 19:34:05 2021 +0200 +++ b/mpz/urandomm.c Wed May 12 15:07:25 2021 +0200 @@ -37,7 +37,7 @@ #define MAX_URANDOMM_ITER 80 void -mpz_urandomm (mpz_ptr rop, gmp_randstate_t rstate, mpz_srcptr n) +mpz_urandomm (mpz_ptr rop, gmp_randstate_ptr rstate, mpz_srcptr n) { mp_ptr rp, np; mp_size_t nbits, size; diff -r 632506b00743 rand/rand.c --- a/rand/rand.c Sat May 08 19:34:05 2021 +0200 +++ b/rand/rand.c Wed May 12 15:07:25 2021 +0200 @@ -33,7 +33,7 @@ #include "gmp-impl.h" void -gmp_randinit (gmp_randstate_t rstate, gmp_randalg_t alg, ...) +gmp_randinit (gmp_randstate_ptr rstate, gmp_randalg_t alg, ...) { va_list ap; va_start (ap, alg); diff -r 632506b00743 rand/randclr.c --- a/rand/randclr.c Sat May 08 19:34:05 2021 +0200 +++ b/rand/randclr.c Wed May 12 15:07:25 2021 +0200 @@ -31,7 +31,7 @@ #include "gmp-impl.h" void -gmp_randclear (gmp_randstate_t rstate) +gmp_randclear (gmp_randstate_ptr rstate) { (*((gmp_randfnptr_t *) RNG_FNPTR (rstate))->randclear_fn) (rstate); } diff -r 632506b00743 rand/randdef.c --- a/rand/randdef.c Sat May 08 19:34:05 2021 +0200 +++ b/rand/randdef.c Wed May 12 15:07:25 2021 +0200 @@ -31,7 +31,7 @@ #include "gmp-impl.h" void -gmp_randinit_default (gmp_randstate_t rstate) +gmp_randinit_default (gmp_randstate_ptr rstate) { gmp_randinit_mt (rstate); } diff -r 632506b00743 rand/randlc2s.c --- a/rand/randlc2s.c Sat May 08 19:34:05 2021 +0200 +++ b/rand/randlc2s.c Wed May 12 15:07:25 2021 +0200 @@ -72,7 +72,7 @@ }; int -gmp_randinit_lc_2exp_size (gmp_randstate_t rstate, mp_bitcnt_t size) +gmp_randinit_lc_2exp_size (gmp_randstate_ptr rstate, mp_bitcnt_t size) { const struct __gmp_rand_lc_scheme_struct *sp; mpz_t a; diff -r 632506b00743 rand/randlc2x.c --- a/rand/randlc2x.c Sat May 08 19:34:05 2021 +0200 +++ b/rand/randlc2x.c Wed May 12 15:07:25 2021 +0200 @@ -69,7 +69,7 @@ result. */ static unsigned long int -lc (mp_ptr rp, gmp_randstate_t rstate) +lc (mp_ptr rp, gmp_randstate_ptr rstate) { mp_ptr tp, seedp, ap; mp_size_t ta; @@ -148,7 +148,7 @@ /* Obtain a sequence of random numbers. */ static void -randget_lc (gmp_randstate_t rstate, mp_ptr rp, unsigned long int nbits) +randget_lc (gmp_randstate_ptr rstate, mp_ptr rp, unsigned long int nbits) { unsigned long int rbitpos; int chunk_nbits; @@ -227,7 +227,7 @@ static void -randseed_lc (gmp_randstate_t rstate, mpz_srcptr seed) +randseed_lc (gmp_randstate_ptr rstate, mpz_srcptr seed) { gmp_rand_lc_struct *p = (gmp_rand_lc_struct *) RNG_STATE (rstate); mpz_ptr seedz = p->_mp_seed; @@ -242,7 +242,7 @@ static void -randclear_lc (gmp_randstate_t rstate) +randclear_lc (gmp_randstate_ptr rstate) { gmp_rand_lc_struct *p = (gmp_rand_lc_struct *) RNG_STATE (rstate); @@ -289,7 +289,7 @@ void -gmp_randinit_lc_2exp (gmp_randstate_t rstate, +gmp_randinit_lc_2exp (gmp_randstate_ptr rstate, mpz_srcptr a, unsigned long int c, mp_bitcnt_t m2exp) diff -r 632506b00743 rand/randmt.c --- a/rand/randmt.c Sat May 08 19:34:05 2021 +0200 +++ b/rand/randmt.c Wed May 12 15:07:25 2021 +0200 @@ -191,7 +191,7 @@ Note that Mersenne Twister is designed to produce outputs in 32-bit words. */ void -__gmp_randget_mt (gmp_randstate_t rstate, mp_ptr dest, unsigned long int nbits) +__gmp_randget_mt (gmp_randstate_ptr rstate, mp_ptr dest, unsigned long int nbits) { gmp_uint_least32_t y; int rbits; @@ -354,7 +354,7 @@ } void -__gmp_randclear_mt (gmp_randstate_t rstate) +__gmp_randclear_mt (gmp_randstate_ptr rstate) { (*__gmp_free_func) ((void *) RNG_STATE (rstate), ALLOC (rstate->_mp_seed) * GMP_LIMB_BYTES); diff -r 632506b00743 rand/randmt.h --- a/rand/randmt.h Sat May 08 19:34:05 2021 +0200 +++ b/rand/randmt.h Wed May 12 15:07:25 2021 +0200 @@ -46,6 +46,6 @@ void __gmp_mt_recalc_buffer (gmp_uint_least32_t *); -void __gmp_randget_mt (gmp_randstate_t, mp_ptr, unsigned long int); -void __gmp_randclear_mt (gmp_randstate_t); +void __gmp_randget_mt (gmp_randstate_ptr, mp_ptr, unsigned long int); +void __gmp_randclear_mt (gmp_randstate_ptr); void __gmp_randiset_mt (gmp_randstate_ptr, gmp_randstate_srcptr); diff -r 632506b00743 rand/randmts.c --- a/rand/randmts.c Sat May 08 19:34:05 2021 +0200 +++ b/rand/randmts.c Wed May 12 15:07:25 2021 +0200 @@ -105,7 +105,7 @@ */ static void -randseed_mt (gmp_randstate_t rstate, mpz_srcptr seed) +randseed_mt (gmp_randstate_ptr rstate, mpz_srcptr seed) { int i; size_t cnt; @@ -157,7 +157,7 @@ /* Initialize MT-specific data. */ void -gmp_randinit_mt (gmp_randstate_t rstate) +gmp_randinit_mt (gmp_randstate_ptr rstate) { __gmp_randinit_mt_noseed (rstate); RNG_FNPTR (rstate) = (void *) &Mersenne_Twister_Generator; diff -r 632506b00743 rand/randsd.c --- a/rand/randsd.c Sat May 08 19:34:05 2021 +0200 +++ b/rand/randsd.c Wed May 12 15:07:25 2021 +0200 @@ -31,7 +31,7 @@ #include "gmp-impl.h" void -gmp_randseed (gmp_randstate_t rstate, +gmp_randseed (gmp_randstate_ptr rstate, mpz_srcptr seed) { (*((gmp_randfnptr_t *) RNG_FNPTR (rstate))->randseed_fn) (rstate, seed); diff -r 632506b00743 rand/randsdui.c --- a/rand/randsdui.c Sat May 08 19:34:05 2021 +0200 +++ b/rand/randsdui.c Wed May 12 15:07:25 2021 +0200 @@ -32,7 +32,7 @@ #include "gmp-impl.h" void -gmp_randseed_ui (gmp_randstate_t rstate, +gmp_randseed_ui (gmp_randstate_ptr rstate, unsigned long int seed) { mpz_t zseed;
_______________________________________________ gmp-devel mailing list gmp-devel@gmplib.org https://gmplib.org/mailman/listinfo/gmp-devel