[Gmp-commit] /var/hg/gmp: 4 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Sun Jan 5 14:47:56 UTC 2014


details:   /var/hg/gmp/rev/9c66f46d4339
changeset: 16171:9c66f46d4339
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sun Jan 05 15:40:01 2014 +0100
description:
Declare all itch functions using __GMP_ATTRIBUTE_PURE.

details:   /var/hg/gmp/rev/9cf721a4d53b
changeset: 16172:9cf721a4d53b
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sun Jan 05 15:40:58 2014 +0100
description:
Declare input arg using 'const'.

details:   /var/hg/gmp/rev/3d5f126b0f3a
changeset: 16173:3d5f126b0f3a
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sun Jan 05 15:46:36 2014 +0100
description:
Improve doc for several functions.

details:   /var/hg/gmp/rev/8d8f8cef5236
changeset: 16174:8d8f8cef5236
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sun Jan 05 15:47:48 2014 +0100
description:
ChangeLog

diffstat:

 ChangeLog                   |  10 ++++++++++
 doc/gmp.texi                |  21 +++++++++++----------
 gmp-h.in                    |  14 +++++++-------
 gmp-impl.h                  |  32 ++++++++++++++++----------------
 mpn/generic/sec_tabselect.c |   7 ++-----
 5 files changed, 46 insertions(+), 38 deletions(-)

diffs (260 lines):

diff -r f27b038dad0e -r 8d8f8cef5236 ChangeLog
--- a/ChangeLog	Sun Jan 05 12:25:43 2014 +0100
+++ b/ChangeLog	Sun Jan 05 15:47:48 2014 +0100
@@ -1,3 +1,13 @@
+2014-01-05  Torbjorn Granlund  <tege at gmplib.org>
+
+	* doc/gmp.texi: Improve doc for several functions.
+
+	* mpn/generic/sec_tabselect.c: Declare input arg using 'const'.
+	* gmp-h.in: Analogous change.
+
+	* gmp-h.in: Declare all itch functions using __GMP_ATTRIBUTE_PURE.
+	* gmp-impl.h: Likewise.
+
 2014-01-05 Marco Bodrato <bodrato at mail.dm.unipi.it>
 
 	* tests/mpn/t-minvert.c: Always compare with mpz_invert results,
diff -r f27b038dad0e -r 8d8f8cef5236 doc/gmp.texi
--- a/doc/gmp.texi	Sun Jan 05 12:25:43 2014 +0100
+++ b/doc/gmp.texi	Sun Jan 05 15:47:48 2014 +0100
@@ -4851,9 +4851,9 @@
 towards zero), and with an exponent returned separately.
 
 The return value is in the range @math{0.5 at le{}@GMPabs{@var{d}}<1} and the
-exponent is stored to @code{*@var{exp}}.  @m{@var{d} * 2^{exp}, @var{d} *
-2^@var{exp}} is the (truncated) @var{op} value.  If @var{op} is zero, the
-return is @math{0.0} and 0 is stored to @code{*@var{exp}}.
+exponent is stored to @code{*@var{exp}}.  @m{@var{d} \times 2^{exp},
+ at var{d} * 2^@var{exp}} is the (truncated) @var{op} value.  If @var{op} is zero,
+the return is @math{0.0} and 0 is stored to @code{*@var{exp}}.
 
 @cindex @code{frexp}
 This is similar to the standard C @code{frexp} function (@pxref{Normalization
@@ -5295,7 +5295,7 @@
 Compute the square of @{@var{s1p}, @var{n}@} and write the 2*@var{n}-limb
 result to @var{rp}.
 
-The destination has to have space for 2*@var{n} limbs, even if the result's
+The destination has to have space for 2 at var{n} limbs, even if the result's
 most significant limb is zero.  No overlap is permitted between the
 destination and the source.
 @end deftypefun
@@ -5715,7 +5715,7 @@
 
 @deftypefun void mpn_sec_mul (mp_limb_t *@var{rp}, const mp_limb_t *@var{ap}, mp_size_t @var{an}, const mp_limb_t *@var{bp}, mp_size_t @var{bn}, mp_limb_t *@var{tp})
 @deftypefunx mp_size_t mpn_sec_mul_itch (mp_size_t @var{an}, mp_size_t @var{bn})
-Set @var{R} to @math{A @times B}, where @var{A} = @{@var{ap}, at var{an}@},
+Set @var{R} to @math{A @times{} B}, where @var{A} = @{@var{ap}, at var{an}@},
 @var{B} = @{@var{bp}, at var{bn}@}, and @var{R} =
 @{@var{rp}, at math{@var{an}+ at var{bn}}@}.
 
@@ -5809,7 +5809,7 @@
 @var{dn})} limbs to be passed in the @var{tp} parameter.
 @end deftypefun
 
- at deftypefun int mpn_sec_minvert (mp_limb_t *@var{rp}, mp_limb_t *@var{ap}, const mp_limb_t *@var{mp}, mp_size_t @var{n}, mp_bitcnt_t @var{bit_size}, mp_limb_t *@var{tp})
+ at deftypefun int mpn_sec_minvert (mp_limb_t *@var{rp}, mp_limb_t *@var{ap}, const mp_limb_t *@var{mp}, mp_size_t @var{n}, mp_bitcnt_t @var{nbcnt}, mp_limb_t *@var{tp})
 @deftypefunx mp_size_t mpn_sec_minvert_itch (mp_size_t @var{n})
 Set @var{R} to @m{@var{A}^{-1} \bmod @var{M}, the inverse of @var{A} modulo
 @var{M}}, where @var{R} = @{@var{rp}, at var{n}@}, @var{A} = @{@var{ap}, at var{n}@},
@@ -5819,10 +5819,11 @@
 If an inverse exists, return 1, otherwise return 0 and leave @var{R}
 undefined. In either case, the input @var{A} is destroyed.
 
-It is required that @var{M} is odd, and that @var{bit_size} is no smaller than
-the sum of the bit sizes of @var{A} and @var{M}. E.g, @var{bit_size} = 2 *
- at var{n} * @code{GMP_NUMB_BITS} is always a safe choice, but smaller values can
-be used if @var{M} or @var{A} are known to have leading zero bits.
+It is required that @var{M} is odd, and that @math{@var{nbcnt} @ge
+ at GMPceil{\log(@var{A}+1)} + @GMPceil{\log(@var{M}+1)}}.  A safe choice is
+ at m{@var{nbcnt} = 2 at var{n} @times{} @code{GMP\_NUMB\_BITS}, @var{nbcnt} = 2
+ at times{} @var{n} @times{} GMP_NUMB_BITS}, but a smaller value might improve
+performance if @var{M} or @var{A} are known to have leading zero bits.
 
 This function requires scratch space of @code{mpn_sec_minvert_itch(@var{n})}
 limbs to be passed in the @var{tp} parameter.
diff -r f27b038dad0e -r 8d8f8cef5236 gmp-h.in
--- a/gmp-h.in	Sun Jan 05 12:25:43 2014 +0100
+++ b/gmp-h.in	Sun Jan 05 15:47:48 2014 +0100
@@ -1632,35 +1632,35 @@
 #define mpn_sec_mul __MPN(sec_mul)
 __GMP_DECLSPEC void mpn_sec_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);
 #define mpn_sec_mul_itch __MPN(sec_mul_itch)
-__GMP_DECLSPEC mp_size_t mpn_sec_mul_itch (mp_size_t, mp_size_t);
+__GMP_DECLSPEC mp_size_t mpn_sec_mul_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE;
 
 #define mpn_sec_sqr __MPN(sec_sqr)
 __GMP_DECLSPEC void mpn_sec_sqr (mp_ptr, mp_srcptr, mp_size_t, mp_ptr);
 #define mpn_sec_sqr_itch __MPN(sec_sqr_itch)
-__GMP_DECLSPEC mp_size_t mpn_sec_sqr_itch (mp_size_t);
+__GMP_DECLSPEC mp_size_t mpn_sec_sqr_itch (mp_size_t) __GMP_ATTRIBUTE_PURE;
 
 #define mpn_sec_powm __MPN(sec_powm)
 __GMP_DECLSPEC void mpn_sec_powm (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);
 #define mpn_sec_powm_itch __MPN(sec_powm_itch)
-__GMP_DECLSPEC mp_size_t mpn_sec_powm_itch (mp_size_t, mp_size_t, mp_size_t);
+__GMP_DECLSPEC mp_size_t mpn_sec_powm_itch (mp_size_t, mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE;
 
 #define mpn_sec_tabselect __MPN(sec_tabselect)
-__GMP_DECLSPEC void mpn_sec_tabselect (volatile mp_limb_t *, volatile mp_limb_t *, mp_size_t, mp_size_t, mp_size_t);
+__GMP_DECLSPEC void mpn_sec_tabselect (volatile mp_limb_t *, volatile const mp_limb_t *, mp_size_t, mp_size_t, mp_size_t);
 
 #define mpn_sec_div_qr __MPN(sec_div_qr)
 __GMP_DECLSPEC mp_limb_t mpn_sec_div_qr (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);
 #define mpn_sec_div_qr_itch __MPN(sec_div_qr_itch)
-__GMP_DECLSPEC mp_size_t mpn_sec_div_qr_itch (mp_size_t, mp_size_t);
+__GMP_DECLSPEC mp_size_t mpn_sec_div_qr_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE;
 #define mpn_sec_div_r __MPN(sec_div_r)
 __GMP_DECLSPEC void mpn_sec_div_r (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);
 #define mpn_sec_div_r_itch __MPN(sec_div_r_itch)
-__GMP_DECLSPEC mp_size_t mpn_sec_div_r_itch (mp_size_t, mp_size_t);
+__GMP_DECLSPEC mp_size_t mpn_sec_div_r_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE;
 
 #define mpn_sec_minvert __MPN(sec_minvert)
 __GMP_DECLSPEC int mpn_sec_minvert (mp_ptr, mp_ptr ap, mp_srcptr mp,
 				    mp_size_t, mp_bitcnt_t, mp_ptr);
 #define mpn_sec_minvert_itch __MPN(sec_minvert_itch)
-__GMP_DECLSPEC mp_size_t mpn_sec_minvert_itch (mp_size_t);
+__GMP_DECLSPEC mp_size_t mpn_sec_minvert_itch (mp_size_t) __GMP_ATTRIBUTE_PURE;
 
 
 /**************** mpz inlines ****************/
diff -r f27b038dad0e -r 8d8f8cef5236 gmp-impl.h
--- a/gmp-impl.h	Sun Jan 05 12:25:43 2014 +0100
+++ b/gmp-impl.h	Sun Jan 05 15:47:48 2014 +0100
@@ -1445,19 +1445,19 @@
 #define   mpn_mu_div_qr __MPN(mu_div_qr)
 __GMP_DECLSPEC mp_limb_t mpn_mu_div_qr (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);
 #define   mpn_mu_div_qr_itch __MPN(mu_div_qr_itch)
-__GMP_DECLSPEC mp_size_t mpn_mu_div_qr_itch (mp_size_t, mp_size_t, int);
+__GMP_DECLSPEC mp_size_t mpn_mu_div_qr_itch (mp_size_t, mp_size_t, int) __GMP_ATTRIBUTE_PURE;
 #define   mpn_mu_div_qr_choose_in __MPN(mu_div_qr_choose_in)
 __GMP_DECLSPEC mp_size_t mpn_mu_div_qr_choose_in (mp_size_t, mp_size_t, int);
 
 #define   mpn_preinv_mu_div_qr __MPN(preinv_mu_div_qr)
 __GMP_DECLSPEC mp_limb_t mpn_preinv_mu_div_qr (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);
 #define   mpn_preinv_mu_div_qr_itch __MPN(preinv_mu_div_qr_itch)
-__GMP_DECLSPEC mp_size_t mpn_preinv_mu_div_qr_itch (mp_size_t, mp_size_t, mp_size_t);
+__GMP_DECLSPEC mp_size_t mpn_preinv_mu_div_qr_itch (mp_size_t, mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE;
 
 #define   mpn_mu_divappr_q __MPN(mu_divappr_q)
 __GMP_DECLSPEC mp_limb_t mpn_mu_divappr_q (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);
 #define   mpn_mu_divappr_q_itch __MPN(mu_divappr_q_itch)
-__GMP_DECLSPEC mp_size_t mpn_mu_divappr_q_itch (mp_size_t, mp_size_t, int);
+__GMP_DECLSPEC mp_size_t mpn_mu_divappr_q_itch (mp_size_t, mp_size_t, int) __GMP_ATTRIBUTE_PURE;
 #define   mpn_mu_divappr_q_choose_in __MPN(mu_divappr_q_choose_in)
 __GMP_DECLSPEC mp_size_t mpn_mu_divappr_q_choose_in (mp_size_t, mp_size_t, int);
 
@@ -1467,7 +1467,7 @@
 #define   mpn_mu_div_q __MPN(mu_div_q)
 __GMP_DECLSPEC mp_limb_t mpn_mu_div_q (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);
 #define   mpn_mu_div_q_itch __MPN(mu_div_q_itch)
-__GMP_DECLSPEC mp_size_t mpn_mu_div_q_itch (mp_size_t, mp_size_t, int);
+__GMP_DECLSPEC mp_size_t mpn_mu_div_q_itch (mp_size_t, mp_size_t, int) __GMP_ATTRIBUTE_PURE;
 
 #define  mpn_div_q __MPN(div_q)
 __GMP_DECLSPEC void mpn_div_q (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);
@@ -1502,42 +1502,42 @@
 #define   mpn_dcpi1_bdiv_qr __MPN(dcpi1_bdiv_qr)
 __GMP_DECLSPEC mp_limb_t mpn_dcpi1_bdiv_qr (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t);
 #define   mpn_dcpi1_bdiv_qr_n_itch __MPN(dcpi1_bdiv_qr_n_itch)
-__GMP_DECLSPEC mp_size_t mpn_dcpi1_bdiv_qr_n_itch (mp_size_t);
+__GMP_DECLSPEC mp_size_t mpn_dcpi1_bdiv_qr_n_itch (mp_size_t) __GMP_ATTRIBUTE_PURE;
 
 #define   mpn_dcpi1_bdiv_qr_n __MPN(dcpi1_bdiv_qr_n)
 __GMP_DECLSPEC mp_limb_t mpn_dcpi1_bdiv_qr_n (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr);
 #define   mpn_dcpi1_bdiv_q __MPN(dcpi1_bdiv_q)
 __GMP_DECLSPEC void      mpn_dcpi1_bdiv_q (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t);
 
-#define   mpn_dcpi1_bdiv_q_n_itch __MPN(dcpi1_bdiv_q_n_itch)
-__GMP_DECLSPEC mp_size_t mpn_dcpi1_bdiv_q_n_itch (mp_size_t);
 #define   mpn_dcpi1_bdiv_q_n __MPN(dcpi1_bdiv_q_n)
 __GMP_DECLSPEC void      mpn_dcpi1_bdiv_q_n (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr);
+#define   mpn_dcpi1_bdiv_q_n_itch __MPN(dcpi1_bdiv_q_n_itch)
+__GMP_DECLSPEC mp_size_t mpn_dcpi1_bdiv_q_n_itch (mp_size_t) __GMP_ATTRIBUTE_PURE;
 
 #define   mpn_mu_bdiv_qr __MPN(mu_bdiv_qr)
 __GMP_DECLSPEC mp_limb_t mpn_mu_bdiv_qr (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);
 #define   mpn_mu_bdiv_qr_itch __MPN(mu_bdiv_qr_itch)
-__GMP_DECLSPEC mp_size_t mpn_mu_bdiv_qr_itch (mp_size_t, mp_size_t);
+__GMP_DECLSPEC mp_size_t mpn_mu_bdiv_qr_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE;
 
 #define   mpn_mu_bdiv_q __MPN(mu_bdiv_q)
 __GMP_DECLSPEC void      mpn_mu_bdiv_q (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);
 #define   mpn_mu_bdiv_q_itch __MPN(mu_bdiv_q_itch)
-__GMP_DECLSPEC mp_size_t mpn_mu_bdiv_q_itch (mp_size_t, mp_size_t);
+__GMP_DECLSPEC mp_size_t mpn_mu_bdiv_q_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE;
 
 #define   mpn_bdiv_qr __MPN(bdiv_qr)
 __GMP_DECLSPEC mp_limb_t mpn_bdiv_qr (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);
 #define   mpn_bdiv_qr_itch __MPN(bdiv_qr_itch)
-__GMP_DECLSPEC mp_size_t mpn_bdiv_qr_itch (mp_size_t, mp_size_t);
+__GMP_DECLSPEC mp_size_t mpn_bdiv_qr_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE;
 
 #define   mpn_bdiv_q __MPN(bdiv_q)
 __GMP_DECLSPEC void      mpn_bdiv_q (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);
 #define   mpn_bdiv_q_itch __MPN(bdiv_q_itch)
-__GMP_DECLSPEC mp_size_t mpn_bdiv_q_itch (mp_size_t, mp_size_t);
+__GMP_DECLSPEC mp_size_t mpn_bdiv_q_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE;
 
 #define   mpn_divexact __MPN(divexact)
 __GMP_DECLSPEC void      mpn_divexact (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t);
 #define   mpn_divexact_itch __MPN(divexact_itch)
-__GMP_DECLSPEC mp_size_t mpn_divexact_itch (mp_size_t, mp_size_t);
+__GMP_DECLSPEC mp_size_t mpn_divexact_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE;
 
 #ifndef mpn_bdiv_dbm1c  /* if not done with cpuvec in a fat binary */
 #define   mpn_bdiv_dbm1c __MPN(bdiv_dbm1c)
@@ -4114,7 +4114,7 @@
 #define   mpn_matrix22_mul_strassen __MPN(matrix22_mul_strassen)
 __GMP_DECLSPEC void      mpn_matrix22_mul_strassen (mp_ptr, mp_ptr, mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_srcptr, mp_srcptr, mp_srcptr, mp_size_t, mp_ptr);
 #define   mpn_matrix22_mul_itch __MPN(matrix22_mul_itch)
-__GMP_DECLSPEC mp_size_t mpn_matrix22_mul_itch (mp_size_t, mp_size_t);
+__GMP_DECLSPEC mp_size_t mpn_matrix22_mul_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE;
 
 #ifndef MATRIX22_STRASSEN_THRESHOLD
 #define MATRIX22_STRASSEN_THRESHOLD 30
@@ -4194,16 +4194,16 @@
 __GMP_DECLSPEC mp_size_t mpn_hgcd_reduce (struct hgcd_matrix *, mp_ptr, mp_ptr, mp_size_t, mp_size_t, mp_ptr);
 
 #define mpn_hgcd_reduce_itch __MPN(hgcd_reduce_itch)
-__GMP_DECLSPEC mp_size_t mpn_hgcd_reduce_itch (mp_size_t, mp_size_t);
+__GMP_DECLSPEC mp_size_t mpn_hgcd_reduce_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE;
 
 #define mpn_hgcd_itch __MPN (hgcd_itch)
-__GMP_DECLSPEC mp_size_t mpn_hgcd_itch (mp_size_t);
+__GMP_DECLSPEC mp_size_t mpn_hgcd_itch (mp_size_t) __GMP_ATTRIBUTE_PURE;
 
 #define mpn_hgcd __MPN (hgcd)
 __GMP_DECLSPEC mp_size_t mpn_hgcd (mp_ptr, mp_ptr, mp_size_t, struct hgcd_matrix *, mp_ptr);
 
 #define mpn_hgcd_appr_itch __MPN (hgcd_appr_itch)
-__GMP_DECLSPEC mp_size_t mpn_hgcd_appr_itch (mp_size_t);
+__GMP_DECLSPEC mp_size_t mpn_hgcd_appr_itch (mp_size_t) __GMP_ATTRIBUTE_PURE;
 
 #define mpn_hgcd_appr __MPN (hgcd_appr)
 __GMP_DECLSPEC int mpn_hgcd_appr (mp_ptr, mp_ptr, mp_size_t, struct hgcd_matrix *, mp_ptr);
diff -r f27b038dad0e -r 8d8f8cef5236 mpn/generic/sec_tabselect.c
--- a/mpn/generic/sec_tabselect.c	Sun Jan 05 12:25:43 2014 +0100
+++ b/mpn/generic/sec_tabselect.c	Sun Jan 05 15:47:48 2014 +0100
@@ -1,9 +1,6 @@
 /* mpn_sec_tabselect.
 
-   THIS IS AN INTERNAL FUNCTION WITH A MUTABLE INTERFACE.  IT IS ONLY
-   SAFE TO REACH THIS FUNCTION THROUGH DOCUMENTED INTERFACES.
-
-Copyright 2007-2009, 2011 Free Software Foundation, Inc.
+Copyright 2007-2009, 2011, 2013 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -28,7 +25,7 @@
    limbs.  Store the selected entry at rp.  Reads entire table to avoid
    side-channel information leaks.  O(n*nents).  */
 void
-mpn_sec_tabselect (volatile mp_limb_t *rp, volatile mp_limb_t *tab,
+mpn_sec_tabselect (volatile mp_limb_t *rp, volatile const mp_limb_t *tab,
 		   mp_size_t n, mp_size_t nents, mp_size_t which)
 {
   mp_size_t k, i;


More information about the gmp-commit mailing list