Add upstream patches 12-13.

This commit is contained in:
Jerry James 2021-05-22 20:24:48 -06:00
parent 08cf430d59
commit f1eb89ef0d
2 changed files with 300 additions and 1 deletions

View File

@ -2680,3 +2680,297 @@ diff -Naurd mpfr-4.1.0-a/tests/tset_sj.c mpfr-4.1.0-b/tests/tset_sj.c
flags1 = inex1 != 0 ? MPFR_FLAGS_INEXACT : 0;
}
}
diff -Naurd mpfr-4.1.0-a/PATCHES mpfr-4.1.0-b/PATCHES
--- mpfr-4.1.0-a/PATCHES 2021-04-23 09:49:34.648281897 +0000
+++ mpfr-4.1.0-b/PATCHES 2021-04-23 09:49:34.696281616 +0000
@@ -0,0 +1 @@
+get_str_ndigits
diff -Naurd mpfr-4.1.0-a/VERSION mpfr-4.1.0-b/VERSION
--- mpfr-4.1.0-a/VERSION 2021-03-09 13:58:00.937650249 +0000
+++ mpfr-4.1.0-b/VERSION 2021-04-23 09:49:34.696281616 +0000
@@ -1 +1 @@
-4.1.0-p11
+4.1.0-p12
diff -Naurd mpfr-4.1.0-a/src/get_str.c mpfr-4.1.0-b/src/get_str.c
--- mpfr-4.1.0-a/src/get_str.c 2020-06-18 17:17:18.000000000 +0000
+++ mpfr-4.1.0-b/src/get_str.c 2021-04-23 09:49:34.680281710 +0000
@@ -2484,6 +2484,8 @@
size_t
mpfr_get_str_ndigits (int b, mpfr_prec_t p)
{
+ MPFR_SAVE_EXPO_DECL (expo);
+
MPFR_ASSERTN (2 <= b && b <= 62);
/* deal first with power of two bases, since even for those, mpfr_ceil_mul
@@ -2497,17 +2499,26 @@
return 1 + (p + k - 2) / k;
}
+ MPFR_SAVE_EXPO_MARK (expo);
+
/* the value returned by mpfr_ceil_mul is guaranteed to be
1 + ceil(p*log(2)/log(b)) for p < 186564318007 (it returns one more
for p=186564318007 and b=7 or 49) */
MPFR_STAT_STATIC_ASSERT (MPFR_PREC_BITS >= 64 || MPFR_PREC_BITS <= 32);
+ if
#if MPFR_PREC_BITS >= 64
/* 64-bit numbers are supported by the C implementation, so that we can
use the large constant below. If MPFR_PREC_BITS <= 32, the condition
is always satisfied, so that we do not need any test. */
- if (MPFR_LIKELY (p < 186564318007))
+ (MPFR_LIKELY (p < 186564318007))
+#else
+ (1)
#endif
- return 1 + mpfr_ceil_mul (IS_POW2(b) ? p - 1 : p, b, 1);
+ {
+ size_t ret = 1 + mpfr_ceil_mul (IS_POW2(b) ? p - 1 : p, b, 1);
+ MPFR_SAVE_EXPO_FREE (expo);
+ return ret;
+ }
/* Now p is large and b is not a power of two. The code below works for any
value of p and b, as long as b is not a power of two. Indeed, in such a
@@ -2541,6 +2552,8 @@
mpfr_clear (d);
mpfr_clear (u);
}
+
+ MPFR_SAVE_EXPO_FREE (expo);
return 1 + ret;
}
}
diff -Naurd mpfr-4.1.0-a/src/mpfr.h mpfr-4.1.0-b/src/mpfr.h
--- mpfr-4.1.0-a/src/mpfr.h 2021-03-09 13:58:00.933650293 +0000
+++ mpfr-4.1.0-b/src/mpfr.h 2021-04-23 09:49:34.692281639 +0000
@@ -27,7 +27,7 @@
#define MPFR_VERSION_MAJOR 4
#define MPFR_VERSION_MINOR 1
#define MPFR_VERSION_PATCHLEVEL 0
-#define MPFR_VERSION_STRING "4.1.0-p11"
+#define MPFR_VERSION_STRING "4.1.0-p12"
/* User macros:
MPFR_USE_FILE: Define it to make MPFR define functions dealing
diff -Naurd mpfr-4.1.0-a/src/version.c mpfr-4.1.0-b/src/version.c
--- mpfr-4.1.0-a/src/version.c 2021-03-09 13:58:00.933650293 +0000
+++ mpfr-4.1.0-b/src/version.c 2021-04-23 09:49:34.696281616 +0000
@@ -25,5 +25,5 @@
const char *
mpfr_get_version (void)
{
- return "4.1.0-p11";
+ return "4.1.0-p12";
}
diff -Naurd mpfr-4.1.0-a/tests/tget_str.c mpfr-4.1.0-b/tests/tget_str.c
--- mpfr-4.1.0-a/tests/tget_str.c 2020-01-08 18:11:13.000000000 +0000
+++ mpfr-4.1.0-b/tests/tget_str.c 2021-04-23 09:49:34.680281710 +0000
@@ -1311,6 +1311,33 @@
mpfr_clear (x);
}
+static void
+test_ndigits_aux (int b, mpfr_prec_t p, size_t expected_m)
+{
+ size_t m;
+ mpfr_exp_t old_emin, old_emax, e[] = { MPFR_EMIN_MIN, 0, MPFR_EMAX_MAX };
+ mpfr_flags_t flags;
+ int i;
+
+ old_emin = mpfr_get_emin ();
+ old_emax = mpfr_get_emax ();
+
+ i = randlimb () % (numberof (e) + 1);
+ if (i < numberof (e))
+ {
+ set_emin (e[i]);
+ set_emax (e[i]);
+ }
+
+ __gmpfr_flags = flags = randlimb () & MPFR_FLAGS_ALL;
+ m = mpfr_get_str_ndigits (b, p);
+ MPFR_ASSERTN (m == expected_m);
+ MPFR_ASSERTN (__gmpfr_flags == flags);
+
+ set_emin (old_emin);
+ set_emax (old_emax);
+}
+
/* test of mpfr_get_str_ndigits */
static void
test_ndigits (void)
@@ -1319,61 +1346,61 @@
/* for b=2, we have 1 + ceil((p-1)*log(2)/log(b)) = p */
for (p = MPFR_PREC_MIN; p <= 1024; p++)
- MPFR_ASSERTN(mpfr_get_str_ndigits (2, p) == p);
+ test_ndigits_aux (2, p, p);
/* for b=4, we have 1 + ceil((p-1)*log(2)/log(b)) = 1 + ceil((p-1)/2)
= 1 + floor(p/2) */
for (p = MPFR_PREC_MIN; p <= 1024; p++)
- MPFR_ASSERTN(mpfr_get_str_ndigits (4, p) == 1 + (p / 2));
+ test_ndigits_aux (4, p, 1 + (p / 2));
/* for b=8, we have 1 + ceil((p-1)*log(2)/log(b)) = 1 + ceil((p-1)/3)
= 1 + floor((p+1)/3) */
for (p = MPFR_PREC_MIN; p <= 1024; p++)
- MPFR_ASSERTN(mpfr_get_str_ndigits (8, p) == 1 + ((p + 1) / 3));
+ test_ndigits_aux (8, p, 1 + ((p + 1) / 3));
/* for b=16, we have 1 + ceil((p-1)*log(2)/log(b)) = 1 + ceil((p-1)/4)
= 1 + floor((p+2)/4) */
for (p = MPFR_PREC_MIN; p <= 1024; p++)
- MPFR_ASSERTN(mpfr_get_str_ndigits (16, p) == 1 + ((p + 2) / 4));
+ test_ndigits_aux (16, p, 1 + ((p + 2) / 4));
/* for b=32, we have 1 + ceil((p-1)*log(2)/log(b)) = 1 + ceil((p-1)/5)
= 1 + floor((p+3)/5) */
for (p = MPFR_PREC_MIN; p <= 1024; p++)
- MPFR_ASSERTN(mpfr_get_str_ndigits (32, p) == 1 + ((p + 3) / 5));
+ test_ndigits_aux (32, p, 1 + ((p + 3) / 5));
/* error < 1e-3 */
- MPFR_ASSERTN(mpfr_get_str_ndigits (57, 35) == 8);
+ test_ndigits_aux (57, 35, 8);
/* error < 1e-4 */
- MPFR_ASSERTN(mpfr_get_str_ndigits (31, 649) == 133);
+ test_ndigits_aux (31, 649, 133);
/* error < 1e-5 */
- MPFR_ASSERTN(mpfr_get_str_ndigits (43, 5041) == 931);
+ test_ndigits_aux (43, 5041, 931);
/* error < 1e-6 */
- MPFR_ASSERTN(mpfr_get_str_ndigits (41, 17771) == 3319);
+ test_ndigits_aux (41, 17771, 3319);
/* 20th convergent of log(2)/log(3) */
- MPFR_ASSERTN(mpfr_get_str_ndigits (3, 630138897) == 397573381);
+ test_ndigits_aux (3, 630138897, 397573381);
#if MPFR_PREC_BITS >= 64
/* 21st convergent of log(2)/log(3) */
- MPFR_ASSERTN(mpfr_get_str_ndigits (3, 9809721694) == 6189245292);
+ test_ndigits_aux (3, 9809721694, 6189245292);
/* 22nd convergent of log(2)/log(3) */
- MPFR_ASSERTN(mpfr_get_str_ndigits (3, 10439860591) == 6586818672);
+ test_ndigits_aux (3, 10439860591, 6586818672);
/* 23rd convergent of log(2)/log(3) */
- MPFR_ASSERTN(mpfr_get_str_ndigits (3, 103768467013) == 65470613322);
+ test_ndigits_aux (3, 103768467013, 65470613322);
/* 24th convergent of log(2)/log(3) */
- MPFR_ASSERTN(mpfr_get_str_ndigits (3, 217976794617) == 137528045314);
+ test_ndigits_aux (3, 217976794617, 137528045314);
- MPFR_ASSERTN(mpfr_get_str_ndigits (3, 1193652440098) == 753110839882);
+ test_ndigits_aux (3, 1193652440098, 753110839882);
- MPFR_ASSERTN(mpfr_get_str_ndigits (3, 683381996816440) == 431166034846569);
+ test_ndigits_aux (3, 683381996816440, 431166034846569);
- MPFR_ASSERTN(mpfr_get_str_ndigits (7, 186564318007) == 66455550933);
+ test_ndigits_aux (7, 186564318007, 66455550933);
#endif
}
diff -Naurd mpfr-4.1.0-a/PATCHES mpfr-4.1.0-b/PATCHES
--- mpfr-4.1.0-a/PATCHES 2021-05-17 16:09:00.574477185 +0000
+++ mpfr-4.1.0-b/PATCHES 2021-05-17 16:09:00.754476587 +0000
@@ -0,0 +1 @@
+vasprintf-prec-zero
diff -Naurd mpfr-4.1.0-a/VERSION mpfr-4.1.0-b/VERSION
--- mpfr-4.1.0-a/VERSION 2021-04-23 09:49:34.696281616 +0000
+++ mpfr-4.1.0-b/VERSION 2021-05-17 16:09:00.754476587 +0000
@@ -1 +1 @@
-4.1.0-p12
+4.1.0-p13
diff -Naurd mpfr-4.1.0-a/src/mpfr.h mpfr-4.1.0-b/src/mpfr.h
--- mpfr-4.1.0-a/src/mpfr.h 2021-04-23 09:49:34.692281639 +0000
+++ mpfr-4.1.0-b/src/mpfr.h 2021-05-17 16:09:00.754476587 +0000
@@ -27,7 +27,7 @@
#define MPFR_VERSION_MAJOR 4
#define MPFR_VERSION_MINOR 1
#define MPFR_VERSION_PATCHLEVEL 0
-#define MPFR_VERSION_STRING "4.1.0-p12"
+#define MPFR_VERSION_STRING "4.1.0-p13"
/* User macros:
MPFR_USE_FILE: Define it to make MPFR define functions dealing
diff -Naurd mpfr-4.1.0-a/src/vasprintf.c mpfr-4.1.0-b/src/vasprintf.c
--- mpfr-4.1.0-a/src/vasprintf.c 2021-02-11 12:48:27.354242922 +0000
+++ mpfr-4.1.0-b/src/vasprintf.c 2021-05-17 16:09:00.598477107 +0000
@@ -635,7 +635,13 @@
static int
buffer_cat (struct string_buffer *b, const char *s, size_t len)
{
- MPFR_ASSERTD (len > 0);
+ /* If len == 0, which is possible when outputting an integer 0
+ (either a native one or mpfr_prec_t) with precision field = 0,
+ do nothing. This test is not necessary since the code below is
+ valid for len == 0, but this is safer, just in case. */
+ if (len == 0)
+ return 0;
+
MPFR_ASSERTD (len <= strlen (s));
if (buffer_incr_len (b, len))
diff -Naurd mpfr-4.1.0-a/src/version.c mpfr-4.1.0-b/src/version.c
--- mpfr-4.1.0-a/src/version.c 2021-04-23 09:49:34.696281616 +0000
+++ mpfr-4.1.0-b/src/version.c 2021-05-17 16:09:00.754476587 +0000
@@ -25,5 +25,5 @@
const char *
mpfr_get_version (void)
{
- return "4.1.0-p12";
+ return "4.1.0-p13";
}
diff -Naurd mpfr-4.1.0-a/tests/tsprintf.c mpfr-4.1.0-b/tests/tsprintf.c
--- mpfr-4.1.0-a/tests/tsprintf.c 2020-04-08 22:39:35.000000000 +0000
+++ mpfr-4.1.0-b/tests/tsprintf.c 2021-05-17 16:09:00.598477107 +0000
@@ -193,6 +193,10 @@
sprintf (buf, "%d", i);
check_vsprintf (buf, "%d", i);
+ check_vsprintf ("0", "%d", 0);
+ check_vsprintf ("", "%.d", 0);
+ check_vsprintf ("", "%.0d", 0);
+
sprintf (buf, "%e", d);
check_vsprintf (buf, "%e", d);
@@ -227,9 +231,6 @@
mpfr_prec_t p = 128;
mpfr_t x, y, z;
- mpfr_init (z);
- mpfr_init2 (x, p);
-
/* specifier 'P' for precision */
check_vsprintf ("128", "%Pu", p);
check_vsprintf ("00128", "%.5Pu", p);
@@ -247,9 +248,19 @@
check_vsprintf ("0200:", "%0#+ -Po:", p);
check_vsprintf ("+0000128 :", "%0+ *.*Pd:", -9, 7, p);
check_vsprintf ("+12345 :", "%0+ -*.*Pd:", -9, -3, (mpfr_prec_t) 12345);
+ check_vsprintf ("0", "%Pu", (mpfr_prec_t) 0);
/* Do not add a test like "%05.1Pd" as MS Windows is buggy: when
a precision is given, the '0' flag must be ignored. */
+ /* specifier 'P' with precision field 0 */
+ check_vsprintf ("128", "%.Pu", p);
+ check_vsprintf ("128", "%.0Pd", p);
+ /* check_vsprintf ("", "%.Pu", (mpfr_prec_t) 0); */
+ check_vsprintf ("", "%.0Pd", (mpfr_prec_t) 0);
+
+ mpfr_init (z);
+ mpfr_init2 (x, 128);
+
/* special numbers */
mpfr_set_inf (x, 1);
check_sprintf (pinf_str, "%Re", x);

View File

@ -1,7 +1,7 @@
Summary: C library for multiple-precision floating-point computations
Name: mpfr
Version: 4.1.0
Release: 6%{?dist}
Release: 7%{?dist}
URL: https://www.mpfr.org/
License: LGPLv3+
@ -24,6 +24,8 @@ Source0: https://www.mpfr.org/%{name}-%{version}/%{name}-%{version}.tar.xz
# - jyn-asympt-interm-zero.patch
# - macros.patch
# - tset_sij.patch
# - get_str_ndigits.patch
# - vasprintf-prec-zero.patch
Patch0: https://www.mpfr.org/%{name}-%{version}/allpatches
# This can be removed when F32 reaches EOL
@ -112,6 +114,9 @@ export LD_LIBRARY_PATH=%{buildroot}%{_libdir}
%{_infodir}/mpfr.info*
%changelog
* Sat May 22 2021 Jerry James <loganjerry@gmail.com> - 4.1.0-7
- Add upstream patches 12-13
* Tue Apr 13 2021 Jerry James <loganjerry@gmail.com> - 4.1.0-6
- Add upstream patches 10-11