[Gmp-commit] /var/hg/gmp: Consistently use pointers instead of arrays in decl...

mercurial at gmplib.org mercurial at gmplib.org
Sun Jun 6 20:53:47 UTC 2021


details:   /var/hg/gmp/rev/4174a7fea068
changeset: 18222:4174a7fea068
user:      Marc Glisse <marc.glisse at inria.fr>
date:      Sun Jun 06 22:53:16 2021 +0200
description:
Consistently use pointers instead of arrays in declarations.
gmp_randstate_t -> gmp_randstate_ptr, etc

diffstat:

 ChangeLog          |  35 +++++++++++++++++++++++++++++++++++
 gmp-h.in           |  32 +++++++++++++++++---------------
 gmp-impl.h         |  11 ++++-------
 mpf/reldiff.c      |   2 +-
 mpf/set_q.c        |   2 +-
 mpf/urandomb.c     |   2 +-
 mpq/canonicalize.c |   2 +-
 mpq/clear.c        |   2 +-
 mpq/init.c         |   2 +-
 mpq/set_si.c       |   2 +-
 mpq/set_ui.c       |   2 +-
 mpz/rrandomb.c     |   6 +++---
 mpz/urandomb.c     |   2 +-
 mpz/urandomm.c     |   2 +-
 rand/rand.c        |   2 +-
 rand/randclr.c     |   2 +-
 rand/randdef.c     |   2 +-
 rand/randlc2s.c    |   2 +-
 rand/randlc2x.c    |  10 +++++-----
 rand/randmt.c      |   4 ++--
 rand/randmt.h      |   4 ++--
 rand/randmts.c     |   4 ++--
 rand/randsd.c      |   2 +-
 rand/randsdui.c    |   2 +-
 24 files changed, 86 insertions(+), 52 deletions(-)

diffs (truncated from 483 to 300 lines):

diff -r a9f0db9f7199 -r 4174a7fea068 ChangeLog
--- a/ChangeLog	Thu Jun 03 23:50:08 2021 +0200
+++ b/ChangeLog	Sun Jun 06 22:53:16 2021 +0200
@@ -1,3 +1,38 @@
+2021-06-06  Marc Glisse  <marc.glisse at inria.fr>
+
+	* gmp-h.in (gmp_randstate_ptr, gmp_randstate_srcptr): Move declaration
+	from gmp-impl.h.
+	(gmp_randinit, gmp_randinit_default, gmp_randinit_lc_2exp,
+	gmp_randinit_lc_2exp_size, gmp_randinit_mt, gmp_randinit_set,
+	gmp_randseed, gmp_randseed_ui, gmp_randclear, gmp_urandomb_ui,
+	gmp_urandomm_ui, mpz_rrandomb, mpz_urandomb, mpz_urandomm,
+	mpf_urandomb): Replace gmp_randstate_t with gmp_randstate_ptr.
+	* gmp-impl.h (gmp_randstate_ptr, gmp_randstate_srcptr): Move
+	declaration to gmp-h.in.
+	(gmp_randfnptr_t, __gmp_randinit_mt_noseed): Replace gmp_randstate_t
+	with gmp_randstate_ptr.
+	* mpf/reldiff.c: Replace mpf_t with mpf_ptr.
+	* mpf/set_q.c: Likewise.
+	* mpf/urandomb.c: Likewise.
+	* mpq/canonicalize.c: Replace mpq_t with mpq_ptr.
+	* mpq/clear.c: Likewise.
+	* mpq/init.c: Likewise.
+	* mpq/set_si.c: Likewise.
+	* mpq/set_ui.c: Likewise.
+	* mpz/rrandomb.c: Replace gmp_randstate_t with gmp_randstate_ptr.
+	* mpz/urandomb.c: Likewise.
+	* mpz/urandomm.c: Likewise.
+	* rand/rand.c: Likewise.
+	* rand/randclr.c: Likewise.
+	* rand/randdef.c: Likewise.
+	* rand/randlc2s.c: Likewise.
+	* rand/randlc2x.c: Likewise.
+	* rand/randmt.c: Likewise.
+	* rand/randmt.h: Likewise.
+	* rand/randmts.c: Likewise.
+	* rand/randsd.c: Likewise.
+	* rand/randsdui.c: Likewise.
+
 2021-06-03  Niels Möller  <nisse at lysator.liu.se>
 
 	* mpn/generic/div_qr_1n_pi1.c (mpn_div_qr_1n_pi1): Micro-optimize
diff -r a9f0db9f7199 -r 4174a7fea068 gmp-h.in
--- a/gmp-h.in	Thu Jun 03 23:50:08 2021 +0200
+++ b/gmp-h.in	Sun Jun 06 22:53:16 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 a9f0db9f7199 -r 4174a7fea068 gmp-impl.h
--- a/gmp-impl.h	Thu Jun 03 23:50:08 2021 +0200
+++ b/gmp-impl.h	Sun Jun 06 22:53:16 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 a9f0db9f7199 -r 4174a7fea068 mpf/reldiff.c
--- a/mpf/reldiff.c	Thu Jun 03 23:50:08 2021 +0200
+++ b/mpf/reldiff.c	Sun Jun 06 22:53:16 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 a9f0db9f7199 -r 4174a7fea068 mpf/set_q.c
--- a/mpf/set_q.c	Thu Jun 03 23:50:08 2021 +0200
+++ b/mpf/set_q.c	Sun Jun 06 22:53:16 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 a9f0db9f7199 -r 4174a7fea068 mpf/urandomb.c
--- a/mpf/urandomb.c	Thu Jun 03 23:50:08 2021 +0200
+++ b/mpf/urandomb.c	Sun Jun 06 22:53:16 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 a9f0db9f7199 -r 4174a7fea068 mpq/canonicalize.c
--- a/mpq/canonicalize.c	Thu Jun 03 23:50:08 2021 +0200
+++ b/mpq/canonicalize.c	Sun Jun 06 22:53:16 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 a9f0db9f7199 -r 4174a7fea068 mpq/clear.c
--- a/mpq/clear.c	Thu Jun 03 23:50:08 2021 +0200
+++ b/mpq/clear.c	Sun Jun 06 22:53:16 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 a9f0db9f7199 -r 4174a7fea068 mpq/init.c
--- a/mpq/init.c	Thu Jun 03 23:50:08 2021 +0200
+++ b/mpq/init.c	Sun Jun 06 22:53:16 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 a9f0db9f7199 -r 4174a7fea068 mpq/set_si.c
--- a/mpq/set_si.c	Thu Jun 03 23:50:08 2021 +0200
+++ b/mpq/set_si.c	Sun Jun 06 22:53:16 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 a9f0db9f7199 -r 4174a7fea068 mpq/set_ui.c
--- a/mpq/set_ui.c	Thu Jun 03 23:50:08 2021 +0200
+++ b/mpq/set_ui.c	Sun Jun 06 22:53:16 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 a9f0db9f7199 -r 4174a7fea068 mpz/rrandomb.c
--- a/mpz/rrandomb.c	Thu Jun 03 23:50:08 2021 +0200
+++ b/mpz/rrandomb.c	Sun Jun 06 22:53:16 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 a9f0db9f7199 -r 4174a7fea068 mpz/urandomb.c
--- a/mpz/urandomb.c	Thu Jun 03 23:50:08 2021 +0200
+++ b/mpz/urandomb.c	Sun Jun 06 22:53:16 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 a9f0db9f7199 -r 4174a7fea068 mpz/urandomm.c
--- a/mpz/urandomm.c	Thu Jun 03 23:50:08 2021 +0200
+++ b/mpz/urandomm.c	Sun Jun 06 22:53:16 2021 +0200


More information about the gmp-commit mailing list