summaryrefslogtreecommitdiff
path: root/Build/source/libs/gmp/gmp-src/mpf
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2020-01-19 23:36:31 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2020-01-19 23:36:31 +0000
commit1d4eda0d2362c7404a81bb0e1e308565b8a4b8f9 (patch)
treeda5a6b2829fa072fe1ae806b45f6b5cc70a3e313 /Build/source/libs/gmp/gmp-src/mpf
parentd2777035be2644c9649530be7f9fa31c8abaaf63 (diff)
gmp-6.2.0
git-svn-id: svn://tug.org/texlive/trunk@53461 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/gmp/gmp-src/mpf')
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/abs.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/add.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/add_ui.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/ceilfloor.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/clear.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/clears.c4
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/cmp.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/cmp_d.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/cmp_si.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/cmp_ui.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/cmp_z.c3
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/div.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/div_2exp.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/div_ui.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/dump.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/eq.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/fits_s.h3
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/fits_u.h1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/get_d.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/get_d_2exp.c15
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/get_dfl_prec.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/get_prc.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/get_si.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/get_str.c30
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/get_ui.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/init.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/init2.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/inits.c4
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/inp_str.c7
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/int_p.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/iset.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/iset_d.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/iset_si.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/iset_str.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/iset_ui.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/mul.c135
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/mul_2exp.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/mul_ui.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/neg.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/out_str.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/pow_ui.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/random2.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/reldiff.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/set.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/set_d.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/set_dfl_prec.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/set_prc.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/set_prc_raw.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/set_q.c77
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/set_si.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/set_str.c40
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/set_ui.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/set_z.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/size.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/sqrt.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/sqrt_ui.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/sub.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/sub_ui.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/swap.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/trunc.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/ui_div.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/ui_sub.c1
-rw-r--r--Build/source/libs/gmp/gmp-src/mpf/urandomb.c1
63 files changed, 158 insertions, 213 deletions
diff --git a/Build/source/libs/gmp/gmp-src/mpf/abs.c b/Build/source/libs/gmp/gmp-src/mpf/abs.c
index a2bde2a4f85..1642a467273 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/abs.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/abs.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
void
diff --git a/Build/source/libs/gmp/gmp-src/mpf/add.c b/Build/source/libs/gmp/gmp-src/mpf/add.c
index d2a5c097c57..77a9e476fc2 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/add.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/add.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
void
diff --git a/Build/source/libs/gmp/gmp-src/mpf/add_ui.c b/Build/source/libs/gmp/gmp-src/mpf/add_ui.c
index b1e57d04c1e..1e2a94b1122 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/add_ui.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/add_ui.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
void
diff --git a/Build/source/libs/gmp/gmp-src/mpf/ceilfloor.c b/Build/source/libs/gmp/gmp-src/mpf/ceilfloor.c
index 302e2b8ae5a..9bb663866f8 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/ceilfloor.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/ceilfloor.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
diff --git a/Build/source/libs/gmp/gmp-src/mpf/clear.c b/Build/source/libs/gmp/gmp-src/mpf/clear.c
index 9ff2dd336fe..0939e03a47e 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/clear.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/clear.c
@@ -29,7 +29,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
void
diff --git a/Build/source/libs/gmp/gmp-src/mpf/clears.c b/Build/source/libs/gmp/gmp-src/mpf/clears.c
index 68a4cbebdc1..115fa199fb9 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/clears.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/clears.c
@@ -29,7 +29,6 @@ GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <stdarg.h>
-#include "gmp.h"
#include "gmp-impl.h"
void
@@ -39,11 +38,12 @@ mpf_clears (mpf_ptr x, ...)
va_start (ap, x);
- while (x != NULL)
+ do
{
__GMP_FREE_FUNC_LIMBS (PTR(x), PREC(x) + 1);
x = va_arg (ap, mpf_ptr);
}
+ while (x != NULL);
va_end (ap);
}
diff --git a/Build/source/libs/gmp/gmp-src/mpf/cmp.c b/Build/source/libs/gmp/gmp-src/mpf/cmp.c
index 0c066721827..3518b518171 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/cmp.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/cmp.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
int
diff --git a/Build/source/libs/gmp/gmp-src/mpf/cmp_d.c b/Build/source/libs/gmp/gmp-src/mpf/cmp_d.c
index 52893a781ec..3fa099bf80b 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/cmp_d.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/cmp_d.c
@@ -34,7 +34,6 @@ see https://www.gnu.org/licenses/. */
#include <float.h> /* for DBL_MAX */
#endif
-#include "gmp.h"
#include "gmp-impl.h"
int
diff --git a/Build/source/libs/gmp/gmp-src/mpf/cmp_si.c b/Build/source/libs/gmp/gmp-src/mpf/cmp_si.c
index 3bf98211ddb..d8d98800ba8 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/cmp_si.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/cmp_si.c
@@ -29,7 +29,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
int
diff --git a/Build/source/libs/gmp/gmp-src/mpf/cmp_ui.c b/Build/source/libs/gmp/gmp-src/mpf/cmp_ui.c
index 198eb21e517..a9a60365a83 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/cmp_ui.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/cmp_ui.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
int
diff --git a/Build/source/libs/gmp/gmp-src/mpf/cmp_z.c b/Build/source/libs/gmp/gmp-src/mpf/cmp_z.c
index e9c1559d6a8..279980f5cbd 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/cmp_z.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/cmp_z.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
int
@@ -39,7 +38,7 @@ mpf_cmp_z (mpf_srcptr u, mpz_srcptr v) __GMP_NOTHROW
SIZ (vf) = size = SIZ (v);
EXP (vf) = size = ABS (size);
- /* PREC (vf) = size; */
+ /* PREC (vf) = size; */
PTR (vf) = PTR (v);
return mpf_cmp (u, vf);
diff --git a/Build/source/libs/gmp/gmp-src/mpf/div.c b/Build/source/libs/gmp/gmp-src/mpf/div.c
index af38cb8698f..d13af756611 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/div.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/div.c
@@ -29,7 +29,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
diff --git a/Build/source/libs/gmp/gmp-src/mpf/div_2exp.c b/Build/source/libs/gmp/gmp-src/mpf/div_2exp.c
index fef81520503..ad552c115ca 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/div_2exp.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/div_2exp.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
diff --git a/Build/source/libs/gmp/gmp-src/mpf/div_ui.c b/Build/source/libs/gmp/gmp-src/mpf/div_ui.c
index 9be7e680bef..e1b0112baa6 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/div_ui.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/div_ui.c
@@ -29,7 +29,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
#include "longlong.h"
diff --git a/Build/source/libs/gmp/gmp-src/mpf/dump.c b/Build/source/libs/gmp/gmp-src/mpf/dump.c
index af671059237..cd37dabe62f 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/dump.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/dump.c
@@ -35,7 +35,6 @@ see https://www.gnu.org/licenses/. */
#include <stdio.h>
#include <string.h> /* for strlen */
-#include "gmp.h"
#include "gmp-impl.h"
void
diff --git a/Build/source/libs/gmp/gmp-src/mpf/eq.c b/Build/source/libs/gmp/gmp-src/mpf/eq.c
index 30c6befd061..cddb9d50869 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/eq.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/eq.c
@@ -29,7 +29,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
#include "longlong.h"
diff --git a/Build/source/libs/gmp/gmp-src/mpf/fits_s.h b/Build/source/libs/gmp/gmp-src/mpf/fits_s.h
index 25f323e255c..80e74befdbd 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/fits_s.h
+++ b/Build/source/libs/gmp/gmp-src/mpf/fits_s.h
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
@@ -68,5 +67,5 @@ FUNCTION (mpf_srcptr f) __GMP_NOTHROW
else
return 0;
- return fl <= (fs >= 0 ? (mp_limb_t) MAXIMUM : - (mp_limb_t) MINIMUM);
+ return fl <= (fs >= 0 ? (mp_limb_t) MAXIMUM : NEG_CAST (mp_limb_t, MINIMUM));
}
diff --git a/Build/source/libs/gmp/gmp-src/mpf/fits_u.h b/Build/source/libs/gmp/gmp-src/mpf/fits_u.h
index be7a271b2fa..bd7ca782dd4 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/fits_u.h
+++ b/Build/source/libs/gmp/gmp-src/mpf/fits_u.h
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
diff --git a/Build/source/libs/gmp/gmp-src/mpf/get_d.c b/Build/source/libs/gmp/gmp-src/mpf/get_d.c
index 8f6f9bbea1d..34826fb7d8a 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/get_d.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/get_d.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
double
diff --git a/Build/source/libs/gmp/gmp-src/mpf/get_d_2exp.c b/Build/source/libs/gmp/gmp-src/mpf/get_d_2exp.c
index 17ce229f251..440a753018e 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/get_d_2exp.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/get_d_2exp.c
@@ -1,6 +1,6 @@
/* double mpf_get_d_2exp (signed long int *exp, mpf_t src).
-Copyright 2001-2004 Free Software Foundation, Inc.
+Copyright 2001-2004, 2017 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -28,23 +28,21 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
#include "longlong.h"
double
-mpf_get_d_2exp (signed long int *exp2, mpf_srcptr src)
+mpf_get_d_2exp (signed long int *expptr, mpf_srcptr src)
{
mp_size_t size, abs_size;
mp_srcptr ptr;
int cnt;
- long exp;
size = SIZ(src);
if (UNLIKELY (size == 0))
{
- *exp2 = 0;
+ *expptr = 0;
return 0.0;
}
@@ -53,9 +51,6 @@ mpf_get_d_2exp (signed long int *exp2, mpf_srcptr src)
count_leading_zeros (cnt, ptr[abs_size - 1]);
cnt -= GMP_NAIL_BITS;
- exp = EXP(src) * GMP_NUMB_BITS - cnt;
- *exp2 = exp;
-
- return mpn_get_d (ptr, abs_size, (mp_size_t) 0,
- (long) - (abs_size * GMP_NUMB_BITS - cnt));
+ *expptr = EXP(src) * GMP_NUMB_BITS - cnt;
+ return mpn_get_d (ptr, abs_size, size, -(abs_size * GMP_NUMB_BITS - cnt));
}
diff --git a/Build/source/libs/gmp/gmp-src/mpf/get_dfl_prec.c b/Build/source/libs/gmp/gmp-src/mpf/get_dfl_prec.c
index 9a773d83acb..13fc514290f 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/get_dfl_prec.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/get_dfl_prec.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
diff --git a/Build/source/libs/gmp/gmp-src/mpf/get_prc.c b/Build/source/libs/gmp/gmp-src/mpf/get_prc.c
index 3b3283a48c5..8dee99ec817 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/get_prc.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/get_prc.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
mp_bitcnt_t
diff --git a/Build/source/libs/gmp/gmp-src/mpf/get_si.c b/Build/source/libs/gmp/gmp-src/mpf/get_si.c
index 5b63dbd4256..6ac4d44b49b 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/get_si.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/get_si.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
diff --git a/Build/source/libs/gmp/gmp-src/mpf/get_str.c b/Build/source/libs/gmp/gmp-src/mpf/get_str.c
index 682819daaab..946c4aec23c 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/get_str.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/get_str.c
@@ -4,8 +4,8 @@
example, the number 3.1416 would be returned as "31416" in DIGIT_PTR and
1 in EXP.
-Copyright 1993-1997, 2000-2003, 2005, 2006, 2011, 2015 Free Software
-Foundation, Inc.
+Copyright 1993-1997, 2000-2003, 2005, 2006, 2011, 2015, 2017 Free
+Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -34,7 +34,6 @@ GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <stdlib.h> /* for NULL */
-#include "gmp.h"
#include "gmp-impl.h"
#include "longlong.h" /* for count_leading_zeros */
@@ -139,26 +138,23 @@ mpf_get_str (char *dbuf, mp_exp_t *exp, int base, size_t n_digits, mpf_srcptr u)
un = ABSIZ(u);
ue = EXP(u);
- if (base >= 0)
+ num_to_text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ if (base > 1)
{
- num_to_text = "0123456789abcdefghijklmnopqrstuvwxyz";
- if (base <= 1)
- base = 10;
- else if (base > 36)
- {
- num_to_text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
- if (base > 62)
+ if (base <= 36)
+ num_to_text = "0123456789abcdefghijklmnopqrstuvwxyz";
+ else if (UNLIKELY (base > 62))
return NULL;
- }
+ }
+ else if (base > -2)
+ {
+ base = 10;
}
else
{
base = -base;
- if (base <= 1)
- base = 10;
- else if (base > 36)
+ if (UNLIKELY (base > 36))
return NULL;
- num_to_text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
}
MPF_SIGNIFICANT_DIGITS (max_digits, base, PREC(u));
@@ -170,7 +166,7 @@ mpf_get_str (char *dbuf, mp_exp_t *exp, int base, size_t n_digits, mpf_srcptr u)
/* We didn't get a string from the user. Allocate one (and return
a pointer to it) with space for `-' and terminating null. */
alloc_size = n_digits + 2;
- dbuf = (char *) (*__gmp_allocate_func) (n_digits + 2);
+ dbuf = __GMP_ALLOCATE_FUNC_TYPE (n_digits + 2, char);
}
if (un == 0)
diff --git a/Build/source/libs/gmp/gmp-src/mpf/get_ui.c b/Build/source/libs/gmp/gmp-src/mpf/get_ui.c
index eb9b30e69c0..e7b933365c3 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/get_ui.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/get_ui.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
diff --git a/Build/source/libs/gmp/gmp-src/mpf/init.c b/Build/source/libs/gmp/gmp-src/mpf/init.c
index 0e428d3d44c..26ab262f674 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/init.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/init.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
void
diff --git a/Build/source/libs/gmp/gmp-src/mpf/init2.c b/Build/source/libs/gmp/gmp-src/mpf/init2.c
index 72c87260885..b90a08a185f 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/init2.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/init2.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
void
diff --git a/Build/source/libs/gmp/gmp-src/mpf/inits.c b/Build/source/libs/gmp/gmp-src/mpf/inits.c
index db7cacc4258..b6d054fc120 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/inits.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/inits.c
@@ -29,7 +29,6 @@ GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <stdarg.h>
-#include "gmp.h"
#include "gmp-impl.h"
void
@@ -39,11 +38,12 @@ mpf_inits (mpf_ptr x, ...)
va_start (ap, x);
- while (x != NULL)
+ do
{
mpf_init (x);
x = va_arg (ap, mpf_ptr);
}
+ while (x != NULL);
va_end (ap);
}
diff --git a/Build/source/libs/gmp/gmp-src/mpf/inp_str.c b/Build/source/libs/gmp/gmp-src/mpf/inp_str.c
index 45cc34cebba..c661a792b00 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/inp_str.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/inp_str.c
@@ -31,7 +31,6 @@ see https://www.gnu.org/licenses/. */
#include <stdio.h>
#include <ctype.h>
-#include "gmp.h"
#include "gmp-impl.h"
size_t
@@ -47,7 +46,7 @@ mpf_inp_str (mpf_ptr rop, FILE *stream, int base)
stream = stdin;
alloc_size = 100;
- str = (char *) (*__gmp_allocate_func) (alloc_size);
+ str = __GMP_ALLOCATE_FUNC_TYPE (alloc_size, char);
str_size = 0;
nread = 0;
@@ -65,7 +64,7 @@ mpf_inp_str (mpf_ptr rop, FILE *stream, int base)
{
size_t old_alloc_size = alloc_size;
alloc_size = alloc_size * 3 / 2;
- str = (char *) (*__gmp_reallocate_func) (str, old_alloc_size, alloc_size);
+ str = __GMP_REALLOCATE_FUNC_TYPE (str, old_alloc_size, alloc_size, char);
}
if (c == EOF || isspace (c))
break;
@@ -79,7 +78,7 @@ mpf_inp_str (mpf_ptr rop, FILE *stream, int base)
{
size_t old_alloc_size = alloc_size;
alloc_size = alloc_size * 3 / 2;
- str = (char *) (*__gmp_reallocate_func) (str, old_alloc_size, alloc_size);
+ str = __GMP_REALLOCATE_FUNC_TYPE (str, old_alloc_size, alloc_size, char);
}
str[str_size] = 0;
diff --git a/Build/source/libs/gmp/gmp-src/mpf/int_p.c b/Build/source/libs/gmp/gmp-src/mpf/int_p.c
index e0e337d2f8f..024cfb5ea59 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/int_p.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/int_p.c
@@ -29,7 +29,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
diff --git a/Build/source/libs/gmp/gmp-src/mpf/iset.c b/Build/source/libs/gmp/gmp-src/mpf/iset.c
index 246f367488b..07f9006712c 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/iset.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/iset.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
void
diff --git a/Build/source/libs/gmp/gmp-src/mpf/iset_d.c b/Build/source/libs/gmp/gmp-src/mpf/iset_d.c
index e3492e36179..2f36240f67b 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/iset_d.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/iset_d.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
void
diff --git a/Build/source/libs/gmp/gmp-src/mpf/iset_si.c b/Build/source/libs/gmp/gmp-src/mpf/iset_si.c
index 179f80c9151..65abb9a4583 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/iset_si.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/iset_si.c
@@ -29,7 +29,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
void
diff --git a/Build/source/libs/gmp/gmp-src/mpf/iset_str.c b/Build/source/libs/gmp/gmp-src/mpf/iset_str.c
index 5cb42917685..10acda916b3 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/iset_str.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/iset_str.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
int
diff --git a/Build/source/libs/gmp/gmp-src/mpf/iset_ui.c b/Build/source/libs/gmp/gmp-src/mpf/iset_ui.c
index 3f48cbd685c..2c426bf56a3 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/iset_ui.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/iset_ui.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
void
diff --git a/Build/source/libs/gmp/gmp-src/mpf/mul.c b/Build/source/libs/gmp/gmp-src/mpf/mul.c
index 5bde28c4b2f..30994611003 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/mul.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/mul.c
@@ -1,6 +1,6 @@
/* mpf_mul -- Multiply two floats.
-Copyright 1993, 1994, 1996, 2001, 2005 Free Software Foundation, Inc.
+Copyright 1993, 1994, 1996, 2001, 2005, 2019 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -28,70 +28,107 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
void
mpf_mul (mpf_ptr r, mpf_srcptr u, mpf_srcptr v)
{
- mp_srcptr up, vp;
- mp_size_t usize, vsize;
mp_size_t sign_product;
mp_size_t prec = r->_mp_prec;
+ mp_size_t rsize;
+ mp_limb_t cy_limb;
+ mp_ptr rp, tp;
+ mp_size_t adj;
+ TMP_DECL;
- usize = u->_mp_size;
- vsize = v->_mp_size;
- sign_product = usize ^ vsize;
+ if (u == v)
+ {
+ mp_srcptr up;
+ mp_size_t usize;
- usize = ABS (usize);
- vsize = ABS (vsize);
+ usize = u->_mp_size;
+ sign_product = 0;
- up = u->_mp_d;
- vp = v->_mp_d;
- if (usize > prec)
- {
- up += usize - prec;
- usize = prec;
- }
- if (vsize > prec)
- {
- vp += vsize - prec;
- vsize = prec;
- }
+ usize = ABS (usize);
- if (usize == 0 || vsize == 0)
- {
- r->_mp_size = 0;
- r->_mp_exp = 0; /* ??? */
+ up = u->_mp_d;
+ if (usize > prec)
+ {
+ up += usize - prec;
+ usize = prec;
+ }
+
+ if (usize == 0)
+ {
+ r->_mp_size = 0;
+ r->_mp_exp = 0; /* ??? */
+ return;
+ }
+ else
+ {
+ TMP_MARK;
+ rsize = 2 * usize;
+ tp = TMP_ALLOC_LIMBS (rsize);
+
+ mpn_sqr (tp, up, usize);
+ cy_limb = tp[rsize - 1];
+ }
}
else
{
- mp_size_t rsize;
- mp_limb_t cy_limb;
- mp_ptr rp, tp;
- mp_size_t adj;
- TMP_DECL;
-
- TMP_MARK;
- rsize = usize + vsize;
- tp = TMP_ALLOC_LIMBS (rsize);
- cy_limb = (usize >= vsize
- ? mpn_mul (tp, up, usize, vp, vsize)
- : mpn_mul (tp, vp, vsize, up, usize));
-
- adj = cy_limb == 0;
- rsize -= adj;
- prec++;
- if (rsize > prec)
+ mp_srcptr up, vp;
+ mp_size_t usize, vsize;
+
+ usize = u->_mp_size;
+ vsize = v->_mp_size;
+ sign_product = usize ^ vsize;
+
+ usize = ABS (usize);
+ vsize = ABS (vsize);
+
+ up = u->_mp_d;
+ vp = v->_mp_d;
+ if (usize > prec)
+ {
+ up += usize - prec;
+ usize = prec;
+ }
+ if (vsize > prec)
+ {
+ vp += vsize - prec;
+ vsize = prec;
+ }
+
+ if (usize == 0 || vsize == 0)
{
- tp += rsize - prec;
- rsize = prec;
+ r->_mp_size = 0;
+ r->_mp_exp = 0;
+ return;
}
- rp = r->_mp_d;
- MPN_COPY (rp, tp, rsize);
- r->_mp_exp = u->_mp_exp + v->_mp_exp - adj;
- r->_mp_size = sign_product >= 0 ? rsize : -rsize;
+ else
+ {
+ TMP_MARK;
+ rsize = usize + vsize;
+ tp = TMP_ALLOC_LIMBS (rsize);
+ cy_limb = (usize >= vsize
+ ? mpn_mul (tp, up, usize, vp, vsize)
+ : mpn_mul (tp, vp, vsize, up, usize));
- TMP_FREE;
+ }
}
+
+ adj = cy_limb == 0;
+ rsize -= adj;
+ prec++;
+ if (rsize > prec)
+ {
+ tp += rsize - prec;
+ rsize = prec;
+ }
+ rp = r->_mp_d;
+ MPN_COPY (rp, tp, rsize);
+ r->_mp_exp = u->_mp_exp + v->_mp_exp - adj;
+ r->_mp_size = sign_product >= 0 ? rsize : -rsize;
+
+ TMP_FREE;
}
diff --git a/Build/source/libs/gmp/gmp-src/mpf/mul_2exp.c b/Build/source/libs/gmp/gmp-src/mpf/mul_2exp.c
index 83df2176d3b..5de73633b4c 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/mul_2exp.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/mul_2exp.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
diff --git a/Build/source/libs/gmp/gmp-src/mpf/mul_ui.c b/Build/source/libs/gmp/gmp-src/mpf/mul_ui.c
index 031b2fe06fe..30da6ae5045 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/mul_ui.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/mul_ui.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
#include "longlong.h"
diff --git a/Build/source/libs/gmp/gmp-src/mpf/neg.c b/Build/source/libs/gmp/gmp-src/mpf/neg.c
index 553018f306a..d294815ce04 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/neg.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/neg.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
void
diff --git a/Build/source/libs/gmp/gmp-src/mpf/out_str.c b/Build/source/libs/gmp/gmp-src/mpf/out_str.c
index 200da748063..1802d0fd251 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/out_str.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/out_str.c
@@ -45,7 +45,6 @@ see https://www.gnu.org/licenses/. */
#include <locale.h> /* for localeconv */
#endif
-#include "gmp.h"
#include "gmp-impl.h"
#include "longlong.h"
diff --git a/Build/source/libs/gmp/gmp-src/mpf/pow_ui.c b/Build/source/libs/gmp/gmp-src/mpf/pow_ui.c
index 6d0528bedb2..8d54dc06db1 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/pow_ui.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/pow_ui.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
#include "longlong.h"
diff --git a/Build/source/libs/gmp/gmp-src/mpf/random2.c b/Build/source/libs/gmp/gmp-src/mpf/random2.c
index 4d7f37e976d..2e0163c5700 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/random2.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/random2.c
@@ -30,7 +30,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
diff --git a/Build/source/libs/gmp/gmp-src/mpf/reldiff.c b/Build/source/libs/gmp/gmp-src/mpf/reldiff.c
index f49da081665..81f05dd9eba 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/reldiff.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/reldiff.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
diff --git a/Build/source/libs/gmp/gmp-src/mpf/set.c b/Build/source/libs/gmp/gmp-src/mpf/set.c
index ec8161d779f..382fe86e406 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/set.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/set.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
void
diff --git a/Build/source/libs/gmp/gmp-src/mpf/set_d.c b/Build/source/libs/gmp/gmp-src/mpf/set_d.c
index 100194d1167..0442f2f8820 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/set_d.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/set_d.c
@@ -34,7 +34,6 @@ see https://www.gnu.org/licenses/. */
#include <float.h> /* for DBL_MAX */
#endif
-#include "gmp.h"
#include "gmp-impl.h"
void
diff --git a/Build/source/libs/gmp/gmp-src/mpf/set_dfl_prec.c b/Build/source/libs/gmp/gmp-src/mpf/set_dfl_prec.c
index 04c9a551354..9be71c04429 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/set_dfl_prec.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/set_dfl_prec.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
mp_size_t __gmp_default_fp_limb_precision = __GMPF_BITS_TO_PREC (53);
diff --git a/Build/source/libs/gmp/gmp-src/mpf/set_prc.c b/Build/source/libs/gmp/gmp-src/mpf/set_prc.c
index 30ba06c6e65..40c3f0ebe10 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/set_prc.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/set_prc.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
diff --git a/Build/source/libs/gmp/gmp-src/mpf/set_prc_raw.c b/Build/source/libs/gmp/gmp-src/mpf/set_prc_raw.c
index 77994422994..e5c52cc29a1 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/set_prc_raw.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/set_prc_raw.c
@@ -30,7 +30,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
void
diff --git a/Build/source/libs/gmp/gmp-src/mpf/set_q.c b/Build/source/libs/gmp/gmp-src/mpf/set_q.c
index c5739b2abec..b0b7fe309fb 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/set_q.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/set_q.c
@@ -1,6 +1,6 @@
/* mpf_set_q (mpf_t rop, mpq_t op) -- Convert the rational op to the float rop.
-Copyright 1996, 1999, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
+Copyright 1996, 1999, 2001, 2002, 2004, 2005, 2016 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -28,47 +28,27 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include <stdio.h> /* for NULL */
-#include "gmp.h"
#include "gmp-impl.h"
-#include "longlong.h"
-/* As usual the aim is to produce PREC(r) limbs, with the high non-zero.
- The basic mpn_tdiv_qr produces a quotient of nsize-dsize+1 limbs, with
- either the high or second highest limb non-zero. We arrange for
- nsize-dsize+1 to equal prec+1, hence giving either prec or prec+1 result
- limbs at PTR(r).
+/* As usual the aim is to produce PREC(r) limbs, with the high non-zero. The
+ basic mpn_div_q produces a quotient of nsize-dsize+1 limbs, with either the
+ high or second highest limb non-zero. We arrange for nsize-dsize+1 to equal
+ prec+1, hence giving either prec or prec+1 result limbs at PTR(r).
- nsize-dsize+1 == prec+1 is achieved by adjusting num(q), either dropping
- low limbs if it's too big, or padding with low zeros if it's too small.
- The full given den(q) is always used.
+ nsize-dsize+1 == prec+1 is achieved by adjusting num(q), either dropping low
+ limbs if it's too big, or padding with low zeros if it's too small. The
+ full given den(q) is always used.
- We cannot truncate den(q), because even when it's much bigger than prec
- the last limbs can still influence the final quotient. Often they don't,
- but we leave optimization of that to a prospective quotient-only mpn
- division.
-
- Not done:
-
- If den(q) is a power of 2 then we may end up with low zero limbs on the
- result. But nothing is done about this, since it should be unlikely on
- random data, and can be left to an application to call mpf_div_2exp if it
- might occur with any frequency.
+ We cannot truncate den(q), because even when it's much bigger than prec the
+ last limbs can still influence the final quotient. Often they don't, but we
+ leave optimization of that to mpn_div_q.
Enhancements:
- The high quotient limb is non-zero when high{np,dsize} >= {dp,dsize}. We
+ The high quotient limb is non-zero when high{np,dsize} > {dp,dsize}. We
could make that comparison and use qsize==prec instead of qsize==prec+1,
- to save one limb in the division.
-
- Future:
-
- If/when mpn_tdiv_qr supports its qxn parameter we can use that instead of
- padding n with zeros in temporary space.
-
- If/when a quotient-only division exists it can be used here immediately.
- remp is only to satisfy mpn_tdiv_qr, the remainder is not used. */
+ to save one limb in the division. */
void
mpf_set_q (mpf_t r, mpq_srcptr q)
@@ -76,7 +56,7 @@ mpf_set_q (mpf_t r, mpq_srcptr q)
mp_srcptr np, dp;
mp_size_t prec, nsize, dsize, qsize, prospective_qsize, tsize, zeros;
mp_size_t sign_quotient, high_zero;
- mp_ptr qp, tp, remp;
+ mp_ptr qp, tp;
mp_exp_t exp;
TMP_DECL;
@@ -106,42 +86,25 @@ mpf_set_q (mpf_t r, mpq_srcptr q)
exp = prospective_qsize; /* ie. number of integer limbs */
qsize = prec + 1; /* desired q */
- zeros = qsize - prospective_qsize; /* n zeros to get desired qsize */
- tsize = nsize + zeros; /* possible copy of n */
-
- if (WANT_TMP_DEBUG)
- {
- /* separate alloc blocks, for malloc debugging */
- remp = TMP_ALLOC_LIMBS (dsize);
- tp = NULL;
- if (zeros > 0)
- tp = TMP_ALLOC_LIMBS (tsize);
- }
- else
- {
- /* one alloc with a conditionalized size, for efficiency */
- mp_size_t size = dsize + (zeros > 0 ? tsize : 0);
- remp = TMP_ALLOC_LIMBS (size);
- tp = remp + dsize;
- }
+ zeros = qsize - prospective_qsize; /* n zeros to get desired qsize */
+ tsize = nsize + zeros; /* size of intermediate numerator */
+ tp = TMP_ALLOC_LIMBS (tsize + 1); /* +1 for mpn_div_q's scratch */
if (zeros > 0)
{
/* pad n with zeros into temporary space */
MPN_ZERO (tp, zeros);
MPN_COPY (tp+zeros, np, nsize);
- np = tp;
- nsize = tsize;
+ np = tp; /* mpn_div_q allows this overlap */
}
else
{
/* shorten n to get desired qsize */
- nsize += zeros;
np -= zeros;
}
- ASSERT (nsize-dsize+1 == qsize);
- mpn_tdiv_qr (qp, remp, (mp_size_t) 0, np, nsize, dp, dsize);
+ ASSERT (tsize-dsize+1 == qsize);
+ mpn_div_q (qp, np, tsize, dp, dsize, tp);
/* strip possible zero high limb */
high_zero = (qp[qsize-1] == 0);
diff --git a/Build/source/libs/gmp/gmp-src/mpf/set_si.c b/Build/source/libs/gmp/gmp-src/mpf/set_si.c
index 9c47c7511ff..23f713da796 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/set_si.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/set_si.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
void
diff --git a/Build/source/libs/gmp/gmp-src/mpf/set_str.c b/Build/source/libs/gmp/gmp-src/mpf/set_str.c
index 9053accadeb..c7bfe0b22a8 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/set_str.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/set_str.c
@@ -2,8 +2,8 @@
in base BASE to a float in dest. If BASE is zero, the leading characters
of STRING is used to figure out the base.
-Copyright 1993-1997, 2000-2003, 2005, 2007, 2008, 2011, 2013 Free Software
-Foundation, Inc.
+Copyright 1993-1997, 2000-2003, 2005, 2007, 2008, 2011, 2013, 2019 Free
+Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -54,7 +54,6 @@ see https://www.gnu.org/licenses/. */
#include <locale.h> /* for localeconv */
#endif
-#include "gmp.h"
#include "gmp-impl.h"
#include "longlong.h"
@@ -127,12 +126,15 @@ mpf_set_str (mpf_ptr x, const char *str, int base)
size_t i, j;
int c;
int negative;
- char *dotpos = 0;
+ char *dotpos;
const char *expptr;
int exp_base;
const char *point = GMP_DECIMAL_POINT;
size_t pointlen = strlen (point);
const unsigned char *digit_value;
+ int incr;
+ size_t n_zeros_skipped;
+
TMP_DECL;
c = (unsigned char) *str;
@@ -199,6 +201,10 @@ mpf_set_str (mpf_ptr x, const char *str, int base)
TMP_MARK;
s = begs = (char *) TMP_ALLOC (str_size + 1);
+ incr = 0;
+ n_zeros_skipped = 0;
+ dotpos = NULL;
+
/* Loop through mantissa, converting it from ASCII to raw byte values. */
for (i = 0; i < str_size; i++)
{
@@ -231,7 +237,13 @@ mpf_set_str (mpf_ptr x, const char *str, int base)
TMP_FREE;
return -1;
}
- *s++ = dig;
+ *s = dig;
+ incr |= dig != 0;
+ s += incr; /* Increment after first non-0 digit seen. */
+ if (dotpos != NULL)
+ /* Count skipped zeros between radix point and first non-0
+ digit. */
+ n_zeros_skipped += 1 - incr;
}
}
c = (unsigned char) *++str;
@@ -252,19 +264,14 @@ mpf_set_str (mpf_ptr x, const char *str, int base)
#if 0
size_t n_chars_needed;
- /* This breaks things like 0.000...0001. To safely ignore superfluous
- digits, we need to skip over leading zeros. */
+ /* This needs careful testing. Leave disabled for now. */
/* Just consider the relevant leading digits of the mantissa. */
LIMBS_PER_DIGIT_IN_BASE (n_chars_needed, prec, base);
if (str_size > n_chars_needed)
str_size = n_chars_needed;
#endif
- LIMBS_PER_DIGIT_IN_BASE (ma, str_size, base);
- mp = TMP_ALLOC_LIMBS (ma);
- mn = mpn_set_str (mp, (unsigned char *) begs, str_size, base);
-
- if (mn == 0)
+ if (str_size == 0)
{
SIZ(x) = 0;
EXP(x) = 0;
@@ -272,6 +279,10 @@ mpf_set_str (mpf_ptr x, const char *str, int base)
return 0;
}
+ LIMBS_PER_DIGIT_IN_BASE (ma, str_size, base);
+ mp = TMP_ALLOC_LIMBS (ma);
+ mn = mpn_set_str (mp, (unsigned char *) begs, str_size, base);
+
madj = 0;
/* Ignore excess limbs in MP,MSIZE. */
if (mn > prec)
@@ -311,7 +322,7 @@ mpf_set_str (mpf_ptr x, const char *str, int base)
else
exp_in_base = 0;
if (dotpos != 0)
- exp_in_base -= s - dotpos;
+ exp_in_base -= s - dotpos + n_zeros_skipped;
divflag = exp_in_base < 0;
exp_in_base = ABS (exp_in_base);
@@ -325,8 +336,7 @@ mpf_set_str (mpf_ptr x, const char *str, int base)
}
ra = 2 * (prec + 1);
- rp = TMP_ALLOC_LIMBS (ra);
- tp = TMP_ALLOC_LIMBS (ra);
+ TMP_ALLOC_LIMBS_2 (rp, ra, tp, ra);
rn = mpn_pow_1_highpart (rp, &radj, (mp_limb_t) base, exp_in_base, prec, tp);
if (divflag)
diff --git a/Build/source/libs/gmp/gmp-src/mpf/set_ui.c b/Build/source/libs/gmp/gmp-src/mpf/set_ui.c
index 617bce13c14..bd4ba26b6db 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/set_ui.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/set_ui.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
void
diff --git a/Build/source/libs/gmp/gmp-src/mpf/set_z.c b/Build/source/libs/gmp/gmp-src/mpf/set_z.c
index fe91904563d..f7626334262 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/set_z.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/set_z.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
void
diff --git a/Build/source/libs/gmp/gmp-src/mpf/size.c b/Build/source/libs/gmp/gmp-src/mpf/size.c
index c6b22b64cc3..f7a9dbd7e2c 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/size.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/size.c
@@ -29,7 +29,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
size_t
diff --git a/Build/source/libs/gmp/gmp-src/mpf/sqrt.c b/Build/source/libs/gmp/gmp-src/mpf/sqrt.c
index 44502244e24..ffb7c10b920 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/sqrt.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/sqrt.c
@@ -30,7 +30,6 @@ GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <stdio.h> /* for NULL */
-#include "gmp.h"
#include "gmp-impl.h"
diff --git a/Build/source/libs/gmp/gmp-src/mpf/sqrt_ui.c b/Build/source/libs/gmp/gmp-src/mpf/sqrt_ui.c
index f390e2425b8..9f91f9974f1 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/sqrt_ui.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/sqrt_ui.c
@@ -30,7 +30,6 @@ GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <stdio.h> /* for NULL */
-#include "gmp.h"
#include "gmp-impl.h"
diff --git a/Build/source/libs/gmp/gmp-src/mpf/sub.c b/Build/source/libs/gmp/gmp-src/mpf/sub.c
index 5fb9ab60cb8..56f26f6d39c 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/sub.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/sub.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
void
diff --git a/Build/source/libs/gmp/gmp-src/mpf/sub_ui.c b/Build/source/libs/gmp/gmp-src/mpf/sub_ui.c
index cf9b88eb004..a23d2a884fb 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/sub_ui.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/sub_ui.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
void
diff --git a/Build/source/libs/gmp/gmp-src/mpf/swap.c b/Build/source/libs/gmp/gmp-src/mpf/swap.c
index a3706528763..80b2e9b8b99 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/swap.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/swap.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
void
diff --git a/Build/source/libs/gmp/gmp-src/mpf/trunc.c b/Build/source/libs/gmp/gmp-src/mpf/trunc.c
index 5f94f7aec85..e9af4a70c14 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/trunc.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/trunc.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
diff --git a/Build/source/libs/gmp/gmp-src/mpf/ui_div.c b/Build/source/libs/gmp/gmp-src/mpf/ui_div.c
index ceb881ebcc2..d228bd44a78 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/ui_div.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/ui_div.c
@@ -29,7 +29,6 @@ GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <stdio.h> /* for NULL */
-#include "gmp.h"
#include "gmp-impl.h"
#include "longlong.h"
diff --git a/Build/source/libs/gmp/gmp-src/mpf/ui_sub.c b/Build/source/libs/gmp/gmp-src/mpf/ui_sub.c
index 71050246622..58da56b47a9 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/ui_sub.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/ui_sub.c
@@ -28,7 +28,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
void
diff --git a/Build/source/libs/gmp/gmp-src/mpf/urandomb.c b/Build/source/libs/gmp/gmp-src/mpf/urandomb.c
index 72271e8762a..ebe85ab6957 100644
--- a/Build/source/libs/gmp/gmp-src/mpf/urandomb.c
+++ b/Build/source/libs/gmp/gmp-src/mpf/urandomb.c
@@ -31,7 +31,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
void