1 diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
2 --- mpfr-3.0.0-a/PATCHES 2010-06-23 11:02:49.000000000 +0000
3 +++ mpfr-3.0.0-b/PATCHES 2010-06-23 11:03:36.000000000 +0000
6 diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
7 --- mpfr-3.0.0-a/VERSION 2010-06-10 11:00:14.000000000 +0000
8 +++ mpfr-3.0.0-b/VERSION 2010-06-23 11:03:20.000000000 +0000
12 diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
13 --- mpfr-3.0.0-a/mpfr.h 2010-06-10 11:00:14.000000000 +0000
14 +++ mpfr-3.0.0-b/mpfr.h 2010-06-23 11:03:20.000000000 +0000
16 #define MPFR_VERSION_MAJOR 3
17 #define MPFR_VERSION_MINOR 0
18 #define MPFR_VERSION_PATCHLEVEL 0
19 -#define MPFR_VERSION_STRING "3.0.0"
20 +#define MPFR_VERSION_STRING "3.0.0-p1"
22 /* Macros dealing with MPFR VERSION */
23 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
24 diff -Naurd mpfr-3.0.0-a/mpfr.texi mpfr-3.0.0-b/mpfr.texi
25 --- mpfr-3.0.0-a/mpfr.texi 2010-06-10 11:00:14.000000000 +0000
26 +++ mpfr-3.0.0-b/mpfr.texi 2010-06-23 11:03:12.000000000 +0000
28 are printed. If @var{base} is greater than 10, @samp{@@} will be used
29 instead of @samp{e} as exponent delimiter.
31 -Return the number of bytes written, or if an error occurred, return 0.
32 +Return the number of characters written, or if an error occurred, return 0.
35 @deftypefun size_t mpfr_inp_str (mpfr_t @var{rop}, FILE *@var{stream}, int @var{base}, mpfr_rnd_t @var{rnd})
36 diff -Naurd mpfr-3.0.0-a/out_str.c mpfr-3.0.0-b/out_str.c
37 --- mpfr-3.0.0-a/out_str.c 2010-06-10 11:00:14.000000000 +0000
38 +++ mpfr-3.0.0-b/out_str.c 2010-06-23 11:03:12.000000000 +0000
41 #include "mpfr-impl.h"
43 +/* Warning! S should not contain "%". */
44 +#define OUT_STR_RET(S) \
48 + r = fprintf (stream, (S)); \
49 + return r < 0 ? 0 : r; \
54 mpfr_out_str (FILE *stream, int base, size_t n_digits, mpfr_srcptr op,
62 MPFR_ASSERTN (base >= 2 && base <= 62);
68 - if (MPFR_IS_NAN(op))
70 - fprintf (stream, "@NaN@");
74 - if (MPFR_IS_INF(op))
76 - if (MPFR_SIGN(op) > 0)
78 - fprintf (stream, "@Inf@");
83 - fprintf (stream, "-@Inf@");
88 - if (MPFR_IS_ZERO(op))
89 + if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (op)))
91 - if (MPFR_SIGN(op) > 0)
93 - fprintf(stream, "0");
96 + if (MPFR_IS_NAN (op))
97 + OUT_STR_RET ("@NaN@");
98 + else if (MPFR_IS_INF (op))
99 + OUT_STR_RET (MPFR_IS_POS (op) ? "@Inf@" : "-@Inf@");
102 - fprintf(stream, "-0");
104 + MPFR_ASSERTD (MPFR_IS_ZERO (op));
105 + OUT_STR_RET (MPFR_IS_POS (op) ? "0" : "-0");
111 l = strlen (s) + 1; /* size of allocated block returned by mpfr_get_str
112 - may be incorrect, as only an upper bound? */
114 - fputc (*s++, stream);
116 - /* outputs mantissa */
117 - fputc (*s++, stream); e--; /* leading digit */
118 - fputc ((unsigned char) MPFR_DECIMAL_POINT, stream);
119 - fputs (s, stream); /* rest of mantissa */
120 + /* outputs possible sign and significand */
121 + err = (*s == '-' && fputc (*s++, stream) == EOF)
122 + || fputc (*s++, stream) == EOF /* leading digit */
123 + || fputc ((unsigned char) MPFR_DECIMAL_POINT, stream) == EOF
124 + || fputs (s, stream) == EOF; /* trailing significand */
125 (*__gmp_free_func) (s0, l);
126 + if (MPFR_UNLIKELY (err))
129 + e--; /* due to the leading digit */
131 /* outputs exponent */
136 MPFR_ASSERTN(e >= LONG_MIN);
137 MPFR_ASSERTN(e <= LONG_MAX);
138 - l += fprintf (stream, (base <= 10 ? "e%ld" : "@%ld"), (long) e);
140 + r = fprintf (stream, (base <= 10 ? "e%ld" : "@%ld"), (long) e);
141 + if (MPFR_UNLIKELY (r < 0))
148 diff -Naurd mpfr-3.0.0-a/tests/tout_str.c mpfr-3.0.0-b/tests/tout_str.c
149 --- mpfr-3.0.0-a/tests/tout_str.c 2010-06-10 11:00:13.000000000 +0000
150 +++ mpfr-3.0.0-b/tests/tout_str.c 2010-06-23 11:03:12.000000000 +0000
160 - mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
161 + n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
164 + printf ("Error: mpfr_out_str (file, 10, 0, NaN, MPFR_RNDN) wrote %u "
165 + "characters instead of 5.\n", n);
170 - mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
171 + n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
174 + printf ("Error: mpfr_out_str (file, 10, 0, +Inf, MPFR_RNDN) wrote %u "
175 + "characters instead of 5.\n", n);
179 mpfr_set_inf (x, -1);
180 - mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
181 + n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
184 + printf ("Error: mpfr_out_str (file, 10, 0, -Inf, MPFR_RNDN) wrote %u "
185 + "characters instead of 6.\n", n);
189 mpfr_set_ui (x, 0, MPFR_RNDN);
190 - mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
191 + n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
194 + printf ("Error: mpfr_out_str (file, 10, 0, +0, MPFR_RNDN) wrote %u "
195 + "characters instead of 1.\n", n);
199 mpfr_neg (x, x, MPFR_RNDN);
200 - mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
201 + n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
204 + printf ("Error: mpfr_out_str (file, 10, 0, -0, MPFR_RNDN) wrote %u "
205 + "characters instead of 2.\n", n);
211 diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
212 --- mpfr-3.0.0-a/version.c 2010-06-10 11:00:14.000000000 +0000
213 +++ mpfr-3.0.0-b/version.c 2010-06-23 11:03:20.000000000 +0000
216 mpfr_get_version (void)
221 diff -Naurd mpfr-3.0.0-a/Makefile.in mpfr-3.0.0-b/Makefile.in
222 --- mpfr-3.0.0-a/Makefile.in 2010-06-10 11:00:52.000000000 +0000
223 +++ mpfr-3.0.0-b/Makefile.in 2010-06-10 11:00:52.000000000 +0000
225 distuninstallcheck_listfiles = find . -type f -print
226 distcleancheck_listfiles = find . -type f -print
232 diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
233 --- mpfr-3.0.0-a/PATCHES 2010-06-23 11:03:36.000000000 +0000
234 +++ mpfr-3.0.0-b/PATCHES 2010-06-25 13:23:13.000000000 +0000
237 diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
238 --- mpfr-3.0.0-a/VERSION 2010-06-23 11:03:20.000000000 +0000
239 +++ mpfr-3.0.0-b/VERSION 2010-06-25 13:23:13.000000000 +0000
243 diff -Naurd mpfr-3.0.0-a/acinclude.m4 mpfr-3.0.0-b/acinclude.m4
244 --- mpfr-3.0.0-a/acinclude.m4 2010-06-10 11:00:14.000000000 +0000
245 +++ mpfr-3.0.0-b/acinclude.m4 2010-06-10 11:00:14.000000000 +0000
247 dnl sys/fpu.h - MIPS specific
248 AC_CHECK_HEADERS([sys/time.h sys/fpu.h])
250 +dnl Check how to get `alloca'
256 diff -Naurd mpfr-3.0.0-a/configure mpfr-3.0.0-b/configure
257 --- mpfr-3.0.0-a/configure 2010-06-10 11:00:51.000000000 +0000
258 +++ mpfr-3.0.0-b/configure 2010-06-25 13:23:05.000000000 +0000
267 @@ -5622,6 +5623,197 @@
271 +# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
272 +# for constant arguments. Useless!
273 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5
274 +$as_echo_n "checking for working alloca.h... " >&6; }
275 +if test "${ac_cv_working_alloca_h+set}" = set; then :
276 + $as_echo_n "(cached) " >&6
278 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext
279 +/* end confdefs.h. */
284 +char *p = (char *) alloca (2 * sizeof (int));
290 +if ac_fn_c_try_link "$LINENO"; then :
291 + ac_cv_working_alloca_h=yes
293 + ac_cv_working_alloca_h=no
295 +rm -f core conftest.err conftest.$ac_objext \
296 + conftest$ac_exeext conftest.$ac_ext
298 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5
299 +$as_echo "$ac_cv_working_alloca_h" >&6; }
300 +if test $ac_cv_working_alloca_h = yes; then
302 +$as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h
306 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5
307 +$as_echo_n "checking for alloca... " >&6; }
308 +if test "${ac_cv_func_alloca_works+set}" = set; then :
309 + $as_echo_n "(cached) " >&6
311 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext
312 +/* end confdefs.h. */
314 +# define alloca __builtin_alloca
317 +# include <malloc.h>
318 +# define alloca _alloca
320 +# ifdef HAVE_ALLOCA_H
321 +# include <alloca.h>
326 +# ifndef alloca /* predefined by HP cc +Olibcalls */
337 +char *p = (char *) alloca (1);
343 +if ac_fn_c_try_link "$LINENO"; then :
344 + ac_cv_func_alloca_works=yes
346 + ac_cv_func_alloca_works=no
348 +rm -f core conftest.err conftest.$ac_objext \
349 + conftest$ac_exeext conftest.$ac_ext
351 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5
352 +$as_echo "$ac_cv_func_alloca_works" >&6; }
354 +if test $ac_cv_func_alloca_works = yes; then
356 +$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h
359 + # The SVR3 libPW and SVR4 libucb both contain incompatible functions
360 +# that cause trouble. Some versions do not even contain alloca or
361 +# contain a buggy version. If you still want to use their alloca,
362 +# use ar to extract alloca.o from them instead of compiling alloca.c.
364 +ALLOCA=\${LIBOBJDIR}alloca.$ac_objext
366 +$as_echo "#define C_ALLOCA 1" >>confdefs.h
369 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5
370 +$as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; }
371 +if test "${ac_cv_os_cray+set}" = set; then :
372 + $as_echo_n "(cached) " >&6
374 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext
375 +/* end confdefs.h. */
376 +#if defined CRAY && ! defined CRAY2
383 +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
384 + $EGREP "webecray" >/dev/null 2>&1; then :
392 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5
393 +$as_echo "$ac_cv_os_cray" >&6; }
394 +if test $ac_cv_os_cray = yes; then
395 + for ac_func in _getb67 GETB67 getb67; do
396 + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
397 +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
398 +eval as_val=\$$as_ac_var
399 + if test "x$as_val" = x""yes; then :
401 +cat >>confdefs.h <<_ACEOF
402 +#define CRAY_STACKSEG_END $ac_func
411 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5
412 +$as_echo_n "checking stack direction for C alloca... " >&6; }
413 +if test "${ac_cv_c_stack_direction+set}" = set; then :
414 + $as_echo_n "(cached) " >&6
416 + if test "$cross_compiling" = yes; then :
417 + ac_cv_c_stack_direction=0
419 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext
420 +/* end confdefs.h. */
421 +$ac_includes_default
423 +find_stack_direction ()
425 + static char *addr = 0;
430 + return find_stack_direction ();
433 + return (&dummy > addr) ? 1 : -1;
439 + return find_stack_direction () < 0;
442 +if ac_fn_c_try_run "$LINENO"; then :
443 + ac_cv_c_stack_direction=1
445 + ac_cv_c_stack_direction=-1
447 +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
448 + conftest.$ac_objext conftest.beam conftest.$ac_ext
452 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5
453 +$as_echo "$ac_cv_c_stack_direction" >&6; }
454 +cat >>confdefs.h <<_ACEOF
455 +#define STACK_DIRECTION $ac_cv_c_stack_direction
463 for ac_header in stdint.h
465 @@ -7564,13 +7756,13 @@
467 lt_cv_nm_interface="BSD nm"
468 echo "int some_variable = 0;" > conftest.$ac_ext
469 - (eval echo "\"\$as_me:7567: $ac_compile\"" >&5)
470 + (eval echo "\"\$as_me:7759: $ac_compile\"" >&5)
471 (eval "$ac_compile" 2>conftest.err)
473 - (eval echo "\"\$as_me:7570: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
474 + (eval echo "\"\$as_me:7762: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
475 (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
477 - (eval echo "\"\$as_me:7573: output\"" >&5)
478 + (eval echo "\"\$as_me:7765: output\"" >&5)
480 if $GREP 'External.*some_variable' conftest.out > /dev/null; then
481 lt_cv_nm_interface="MS dumpbin"
482 @@ -8772,7 +8964,7 @@
485 # Find out which ABI we are using.
486 - echo '#line 8775 "configure"' > conftest.$ac_ext
487 + echo '#line 8967 "configure"' > conftest.$ac_ext
488 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
489 (eval $ac_compile) 2>&5
491 @@ -10032,11 +10224,11 @@
492 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
493 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
494 -e 's:$: $lt_compiler_flag:'`
495 - (eval echo "\"\$as_me:10035: $lt_compile\"" >&5)
496 + (eval echo "\"\$as_me:10227: $lt_compile\"" >&5)
497 (eval "$lt_compile" 2>conftest.err)
500 - echo "$as_me:10039: \$? = $ac_status" >&5
501 + echo "$as_me:10231: \$? = $ac_status" >&5
502 if (exit $ac_status) && test -s "$ac_outfile"; then
503 # The compiler can only warn and ignore the option if not recognized
504 # So say no if there are warnings other than the usual output.
505 @@ -10371,11 +10563,11 @@
506 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
507 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
508 -e 's:$: $lt_compiler_flag:'`
509 - (eval echo "\"\$as_me:10374: $lt_compile\"" >&5)
510 + (eval echo "\"\$as_me:10566: $lt_compile\"" >&5)
511 (eval "$lt_compile" 2>conftest.err)
514 - echo "$as_me:10378: \$? = $ac_status" >&5
515 + echo "$as_me:10570: \$? = $ac_status" >&5
516 if (exit $ac_status) && test -s "$ac_outfile"; then
517 # The compiler can only warn and ignore the option if not recognized
518 # So say no if there are warnings other than the usual output.
519 @@ -10476,11 +10668,11 @@
520 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
521 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
522 -e 's:$: $lt_compiler_flag:'`
523 - (eval echo "\"\$as_me:10479: $lt_compile\"" >&5)
524 + (eval echo "\"\$as_me:10671: $lt_compile\"" >&5)
525 (eval "$lt_compile" 2>out/conftest.err)
527 cat out/conftest.err >&5
528 - echo "$as_me:10483: \$? = $ac_status" >&5
529 + echo "$as_me:10675: \$? = $ac_status" >&5
530 if (exit $ac_status) && test -s out/conftest2.$ac_objext
532 # The compiler can only warn and ignore the option if not recognized
533 @@ -10531,11 +10723,11 @@
534 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
535 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
536 -e 's:$: $lt_compiler_flag:'`
537 - (eval echo "\"\$as_me:10534: $lt_compile\"" >&5)
538 + (eval echo "\"\$as_me:10726: $lt_compile\"" >&5)
539 (eval "$lt_compile" 2>out/conftest.err)
541 cat out/conftest.err >&5
542 - echo "$as_me:10538: \$? = $ac_status" >&5
543 + echo "$as_me:10730: \$? = $ac_status" >&5
544 if (exit $ac_status) && test -s out/conftest2.$ac_objext
546 # The compiler can only warn and ignore the option if not recognized
547 @@ -12915,7 +13107,7 @@
548 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
549 lt_status=$lt_dlunknown
550 cat > conftest.$ac_ext <<_LT_EOF
551 -#line 12918 "configure"
552 +#line 13110 "configure"
553 #include "confdefs.h"
556 @@ -13011,7 +13203,7 @@
557 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
558 lt_status=$lt_dlunknown
559 cat > conftest.$ac_ext <<_LT_EOF
560 -#line 13014 "configure"
561 +#line 13206 "configure"
562 #include "confdefs.h"
565 diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
566 --- mpfr-3.0.0-a/mpfr.h 2010-06-23 11:03:20.000000000 +0000
567 +++ mpfr-3.0.0-b/mpfr.h 2010-06-25 13:23:13.000000000 +0000
569 #define MPFR_VERSION_MAJOR 3
570 #define MPFR_VERSION_MINOR 0
571 #define MPFR_VERSION_PATCHLEVEL 0
572 -#define MPFR_VERSION_STRING "3.0.0-p1"
573 +#define MPFR_VERSION_STRING "3.0.0-p2"
575 /* Macros dealing with MPFR VERSION */
576 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
577 diff -Naurd mpfr-3.0.0-a/tests/Makefile.in mpfr-3.0.0-b/tests/Makefile.in
578 --- mpfr-3.0.0-a/tests/Makefile.in 2010-06-10 11:00:52.000000000 +0000
579 +++ mpfr-3.0.0-b/tests/Makefile.in 2010-06-10 11:00:52.000000000 +0000
581 red=; grn=; lgn=; blu=; std=
582 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
588 diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
589 --- mpfr-3.0.0-a/version.c 2010-06-23 11:03:20.000000000 +0000
590 +++ mpfr-3.0.0-b/version.c 2010-06-25 13:23:13.000000000 +0000
593 mpfr_get_version (void)
598 diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
599 --- mpfr-3.0.0-a/PATCHES 2010-07-10 00:11:19.000000000 +0000
600 +++ mpfr-3.0.0-b/PATCHES 2010-07-10 00:12:50.000000000 +0000
603 diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
604 --- mpfr-3.0.0-a/VERSION 2010-06-25 13:23:13.000000000 +0000
605 +++ mpfr-3.0.0-b/VERSION 2010-07-10 00:11:53.000000000 +0000
609 diff -Naurd mpfr-3.0.0-a/gamma.c mpfr-3.0.0-b/gamma.c
610 --- mpfr-3.0.0-a/gamma.c 2010-06-10 11:00:14.000000000 +0000
611 +++ mpfr-3.0.0-b/gamma.c 2010-07-10 00:11:46.000000000 +0000
613 /* we want an upper bound for x * [log(2-x)-1].
614 since x < 0, we need a lower bound on log(2-x) */
615 mpfr_ui_sub (xp, 2, x, MPFR_RNDD);
616 - mpfr_log (xp, xp, MPFR_RNDD);
617 + mpfr_log2 (xp, xp, MPFR_RNDD);
618 mpfr_sub_ui (xp, xp, 1, MPFR_RNDD);
619 mpfr_mul (xp, xp, x, MPFR_RNDU);
623 mpfr_sub (tmp, tmp, tmp2, MPFR_RNDZ); /* low bnd on |sin(Pi*(2-x))| */
624 mpfr_ui_div (tmp, 12, tmp, MPFR_RNDU); /* upper bound */
625 - mpfr_log (tmp, tmp, MPFR_RNDU);
626 - mpfr_add (tmp, tmp, xp, MPFR_RNDU);
627 + mpfr_log2 (tmp, tmp, MPFR_RNDU);
628 + mpfr_add (xp, tmp, xp, MPFR_RNDU);
629 underflow = mpfr_cmp_si (xp, expo.saved_emin - 2) <= 0;
632 diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
633 --- mpfr-3.0.0-a/mpfr.h 2010-06-25 13:23:13.000000000 +0000
634 +++ mpfr-3.0.0-b/mpfr.h 2010-07-10 00:11:53.000000000 +0000
636 #define MPFR_VERSION_MAJOR 3
637 #define MPFR_VERSION_MINOR 0
638 #define MPFR_VERSION_PATCHLEVEL 0
639 -#define MPFR_VERSION_STRING "3.0.0-p2"
640 +#define MPFR_VERSION_STRING "3.0.0-p3"
642 /* Macros dealing with MPFR VERSION */
643 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
644 diff -Naurd mpfr-3.0.0-a/tests/tgamma.c mpfr-3.0.0-b/tests/tgamma.c
645 --- mpfr-3.0.0-a/tests/tgamma.c 2010-06-10 11:00:13.000000000 +0000
646 +++ mpfr-3.0.0-b/tests/tgamma.c 2010-07-10 00:11:46.000000000 +0000
651 +/* bug found by Stathis, only occurs on 32-bit machines */
658 + mpfr_init2 (x, 100);
659 + mpfr_set_str (x, "-4.6308260837372266e+07", 10, MPFR_RNDN);
660 + inex = mpfr_gamma (x, x, MPFR_RNDN);
661 + MPFR_ASSERTN(MPFR_IS_ZERO(x) && MPFR_IS_NEG(x) && inex > 0);
666 main (int argc, char *argv[])
669 test_generic (2, 100, 2);
674 data_check ("data/gamma", mpfr_gamma, "mpfr_gamma");
676 diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
677 --- mpfr-3.0.0-a/version.c 2010-06-25 13:23:13.000000000 +0000
678 +++ mpfr-3.0.0-b/version.c 2010-07-10 00:11:53.000000000 +0000
681 mpfr_get_version (void)
686 diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
687 --- mpfr-3.0.0-a/PATCHES 2010-09-07 08:44:01.000000000 +0000
688 +++ mpfr-3.0.0-b/PATCHES 2010-09-07 08:48:46.000000000 +0000
691 diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
692 --- mpfr-3.0.0-a/VERSION 2010-07-10 00:11:53.000000000 +0000
693 +++ mpfr-3.0.0-b/VERSION 2010-09-07 08:46:06.000000000 +0000
697 diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
698 --- mpfr-3.0.0-a/mpfr.h 2010-07-10 00:11:53.000000000 +0000
699 +++ mpfr-3.0.0-b/mpfr.h 2010-09-07 08:46:06.000000000 +0000
701 #define MPFR_VERSION_MAJOR 3
702 #define MPFR_VERSION_MINOR 0
703 #define MPFR_VERSION_PATCHLEVEL 0
704 -#define MPFR_VERSION_STRING "3.0.0-p3"
705 +#define MPFR_VERSION_STRING "3.0.0-p4"
707 /* Macros dealing with MPFR VERSION */
708 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
709 @@ -798,35 +798,45 @@
710 anyway. Checking with other ICC versions is needed. Possibly detect
711 whether warnings are produced or not with a configure test.
712 + Remove C++ too, since it complains too much. */
713 +/* Added casts to improve robustness in case of undefined behavior and
714 + compiler extensions based on UB (in particular -fwrapv). MPFR doesn't
715 + use such extensions, but these macros will be used by 3rd-party code,
716 + where such extensions may be required.
717 + Moreover casts to unsigned long have been added to avoid warnings in
718 + programs that use MPFR and are compiled with -Wconversion; such casts
719 + are OK since if X is a constant expression, then (unsigned long) X is
720 + also a constant expression, so that the optimizations still work. */
721 #if defined (__GNUC__) && !defined(__ICC) && !defined(__cplusplus)
724 -/* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0. */
725 -#define mpfr_cmp_ui(_f,_u) \
726 - (__builtin_constant_p (_u) && (_u) == 0 ? \
728 - mpfr_cmp_ui_2exp ((_f),(_u),0))
729 +/* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0.
730 + But warning! mpfr_sgn is specified as a macro in the API, thus the macro
731 + mustn't be used if side effects are possible, like here. */
732 +#define mpfr_cmp_ui(_f,_u) \
733 + (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ? \
734 + (mpfr_sgn) (_f) : \
735 + mpfr_cmp_ui_2exp ((_f), (unsigned long) (_u), 0))
737 -#define mpfr_cmp_si(_f,_s) \
738 - (__builtin_constant_p (_s) && (_s) >= 0 ? \
739 - mpfr_cmp_ui ((_f), (_s)) : \
740 - mpfr_cmp_si_2exp ((_f), (_s), 0))
741 +#define mpfr_cmp_si(_f,_s) \
742 + (__builtin_constant_p (_s) && (long) (_s) >= 0 ? \
743 + mpfr_cmp_ui ((_f), (unsigned long) (long) (_s)) : \
744 + mpfr_cmp_si_2exp ((_f), (long) (_s), 0))
745 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95
747 -#define mpfr_set_ui(_f,_u,_r) \
748 - (__builtin_constant_p (_u) && (_u) == 0 ? \
750 - mpfr_ptr _p = (_f); \
751 - _p->_mpfr_sign = 1; \
752 - _p->_mpfr_exp = __MPFR_EXP_ZERO; \
753 - (void) (_r); 0; }) : \
754 - mpfr_set_ui_2exp ((_f), (_u), 0, (_r)))
755 +#define mpfr_set_ui(_f,_u,_r) \
756 + (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ? \
758 + mpfr_ptr _p = (_f); \
759 + _p->_mpfr_sign = 1; \
760 + _p->_mpfr_exp = __MPFR_EXP_ZERO; \
761 + (void) (_r); 0; }) : \
762 + mpfr_set_ui_2exp ((_f), (unsigned long) (_u), 0, (_r)))
765 -#define mpfr_set_si(_f,_s,_r) \
766 - (__builtin_constant_p (_s) && (_s) >= 0 ? \
767 - mpfr_set_ui ((_f), (_s), (_r)) : \
768 - mpfr_set_si_2exp ((_f), (_s), 0, (_r)))
769 +#define mpfr_set_si(_f,_s,_r) \
770 + (__builtin_constant_p (_s) && (long) (_s) >= 0 ? \
771 + mpfr_set_ui ((_f), (unsigned long) (long) (_s), (_r)) : \
772 + mpfr_set_si_2exp ((_f), (long) (_s), 0, (_r)))
776 diff -Naurd mpfr-3.0.0-a/tests/tcmp_ui.c mpfr-3.0.0-b/tests/tcmp_ui.c
777 --- mpfr-3.0.0-a/tests/tcmp_ui.c 2010-06-10 11:00:13.000000000 +0000
778 +++ mpfr-3.0.0-b/tests/tcmp_ui.c 2010-09-07 08:45:12.000000000 +0000
783 +/* Since mpfr_cmp_ui and mpfr_cmp_si are also implemented by a macro
784 + with __builtin_constant_p for GCC, check that side effects are
785 + handled correctly. */
792 + mpfr_init2 (x, 32);
795 + mpfr_set_ui (x, 17, MPFR_RNDN);
796 + if (mpfr_cmp_ui (x, 17) != 0)
798 + printf ("Error 1 on mpfr_cmp_ui(x,17) in check_macros\n");
801 + if (mpfr_cmp_ui (x, (c++, 17)) != 0)
803 + printf ("Error 2 on mpfr_cmp_ui(x,17) in check_macros\n");
808 + printf ("Error 3 on mpfr_cmp_ui(x,17) in check_macros\n"
809 + "(c = %d instead of 1)\n", c);
812 + if (mpfr_cmp_si (x, 17) != 0)
814 + printf ("Error 1 on mpfr_cmp_si(x,17) in check_macros\n");
817 + if (mpfr_cmp_si (x, (c++, 17)) != 0)
819 + printf ("Error 2 on mpfr_cmp_si(x,17) in check_macros\n");
824 + printf ("Error 3 on mpfr_cmp_si(x,17) in check_macros\n"
825 + "(c = %d instead of 2)\n", c);
830 + mpfr_set_ui (x, 0, MPFR_RNDN);
831 + if (mpfr_cmp_ui (x, 0) != 0)
833 + printf ("Error 1 on mpfr_cmp_ui(x,0) in check_macros\n");
836 + if (mpfr_cmp_ui (x, (c++, 0)) != 0)
838 + printf ("Error 2 on mpfr_cmp_ui(x,0) in check_macros\n");
843 + printf ("Error 3 on mpfr_cmp_ui(x,0) in check_macros\n"
844 + "(c = %d instead of 1)\n", c);
847 + if (mpfr_cmp_si (x, 0) != 0)
849 + printf ("Error 1 on mpfr_cmp_si(x,0) in check_macros\n");
852 + if (mpfr_cmp_si (x, (c++, 0)) != 0)
854 + printf ("Error 2 on mpfr_cmp_si(x,0) in check_macros\n");
859 + printf ("Error 3 on mpfr_cmp_si(x,0) in check_macros\n"
860 + "(c = %d instead of 2)\n", c);
874 + mpfr_inits (x[0], x[1], x[2], (mpfr_ptr) 0);
875 + mpfr_set_ui (x[0], 0, MPFR_RNDN);
877 + if (mpfr_cmp_ui (p++, 0) != 0)
879 + printf ("Error in mpfr_cmp_ui macro: result should be 0.\n");
884 + printf ("Error in mpfr_cmp_ui macro: p - x[0] = %d (expecting 1)\n",
889 + if (mpfr_cmp_si (p++, 0) != 0)
891 + printf ("Error in mpfr_cmp_si macro: result should be 0.\n");
896 + printf ("Error in mpfr_cmp_si macro: p - x[0] = %d (expecting 1)\n",
900 + mpfr_clears (x[0], x[1], x[2], (mpfr_ptr) 0);
915 diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
916 --- mpfr-3.0.0-a/version.c 2010-07-10 00:11:53.000000000 +0000
917 +++ mpfr-3.0.0-b/version.c 2010-09-07 08:46:06.000000000 +0000
920 mpfr_get_version (void)
925 diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
926 --- mpfr-3.0.0-a/PATCHES 2010-10-21 20:28:38.000000000 +0000
927 +++ mpfr-3.0.0-b/PATCHES 2010-10-21 20:28:38.000000000 +0000
930 diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
931 --- mpfr-3.0.0-a/VERSION 2010-09-07 08:46:06.000000000 +0000
932 +++ mpfr-3.0.0-b/VERSION 2010-10-21 20:28:38.000000000 +0000
936 diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
937 --- mpfr-3.0.0-a/mpfr.h 2010-09-07 08:46:06.000000000 +0000
938 +++ mpfr-3.0.0-b/mpfr.h 2010-10-21 20:28:38.000000000 +0000
940 #define MPFR_VERSION_MAJOR 3
941 #define MPFR_VERSION_MINOR 0
942 #define MPFR_VERSION_PATCHLEVEL 0
943 -#define MPFR_VERSION_STRING "3.0.0-p4"
944 +#define MPFR_VERSION_STRING "3.0.0-p5"
946 /* Macros dealing with MPFR VERSION */
947 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
948 diff -Naurd mpfr-3.0.0-a/tests/tcan_round.c mpfr-3.0.0-b/tests/tcan_round.c
949 --- mpfr-3.0.0-a/tests/tcan_round.c 2010-06-10 11:00:13.000000000 +0000
950 +++ mpfr-3.0.0-b/tests/tcan_round.c 2010-10-21 20:28:38.000000000 +0000
952 /* avoid mpn_random which leaks memory */
953 for (i = 0; i < n; i++)
954 buf[i] = randlimb ();
955 - p = (mpfr_prec_t) randlimb() % ((n-1) * GMP_NUMB_BITS) + MPFR_PREC_MIN;
956 + p = randlimb() % ((n-1) * GMP_NUMB_BITS) + MPFR_PREC_MIN;
957 err = p + randlimb () % GMP_NUMB_BITS;
958 r1 = mpfr_round_p (buf, n, err, p);
959 r2 = mpfr_can_round_raw (buf, n, MPFR_SIGN_POS, err,
960 diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
961 --- mpfr-3.0.0-a/version.c 2010-09-07 08:46:06.000000000 +0000
962 +++ mpfr-3.0.0-b/version.c 2010-10-21 20:28:38.000000000 +0000
965 mpfr_get_version (void)
970 diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
971 --- mpfr-3.0.0-a/PATCHES 2010-10-21 20:59:32.000000000 +0000
972 +++ mpfr-3.0.0-b/PATCHES 2010-10-21 20:59:32.000000000 +0000
975 diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
976 --- mpfr-3.0.0-a/VERSION 2010-10-21 20:28:38.000000000 +0000
977 +++ mpfr-3.0.0-b/VERSION 2010-10-21 20:59:32.000000000 +0000
981 diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
982 --- mpfr-3.0.0-a/mpfr.h 2010-10-21 20:28:38.000000000 +0000
983 +++ mpfr-3.0.0-b/mpfr.h 2010-10-21 20:59:32.000000000 +0000
985 #define MPFR_VERSION_MAJOR 3
986 #define MPFR_VERSION_MINOR 0
987 #define MPFR_VERSION_PATCHLEVEL 0
988 -#define MPFR_VERSION_STRING "3.0.0-p5"
989 +#define MPFR_VERSION_STRING "3.0.0-p6"
991 /* Macros dealing with MPFR VERSION */
992 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
993 diff -Naurd mpfr-3.0.0-a/sub1.c mpfr-3.0.0-b/sub1.c
994 --- mpfr-3.0.0-a/sub1.c 2010-06-10 11:00:14.000000000 +0000
995 +++ mpfr-3.0.0-b/sub1.c 2010-10-21 20:59:32.000000000 +0000
997 mp_size_t cancel2, an, bn, cn, cn0;
998 mp_limb_t *ap, *bp, *cp;
999 mp_limb_t carry, bb, cc, borrow = 0;
1000 - int inexact, shift_b, shift_c, is_exact = 1, down = 0, add_exp = 0;
1001 + int inexact, shift_b, shift_c, add_exp = 0;
1002 + int cmp_low = 0; /* used for rounding to nearest: 0 if low(b) = low(c),
1003 + negative if low(b) < low(c), positive if low(b)>low(c) */
1005 MPFR_TMP_DECL(marker);
1011 - printf ("shift_b=%d shift_c=%d diffexp=%lu\n", shift_b, shift_c,
1012 + printf ("rnd=%s shift_b=%d shift_c=%d diffexp=%lu\n",
1013 + mpfr_print_rnd_mode (rnd_mode), shift_b, shift_c,
1014 (unsigned long) diff_exp);
1017 @@ -307,17 +310,18 @@
1019 if (MPFR_LIKELY(sh))
1021 - is_exact = (carry == 0);
1022 /* can decide except when carry = 2^(sh-1) [middle]
1023 or carry = 0 [truncate, but cannot decide inexact flag] */
1024 - down = (carry < (MPFR_LIMB_ONE << (sh - 1)));
1025 if (carry > (MPFR_LIMB_ONE << (sh - 1)))
1027 - else if ((0 < carry) && down)
1028 + else if ((0 < carry) && (carry < (MPFR_LIMB_ONE << (sh - 1))))
1030 inexact = -1; /* result if smaller than exact value */
1033 + /* now carry = 2^(sh-1), in which case cmp_low=2,
1034 + or carry = 0, in which case cmp_low=0 */
1035 + cmp_low = (carry == 0) ? 0 : 2;
1038 else /* directed rounding: set rnd_mode to RNDZ iff toward zero */
1039 @@ -344,12 +348,32 @@
1040 cn -= (long int) an + cancel2;
1043 - printf ("last %d bits from a are %lu, bn=%ld, cn=%ld\n",
1044 + printf ("last sh=%d bits from a are %lu, bn=%ld, cn=%ld\n",
1045 sh, (unsigned long) carry, (long) bn, (long) cn);
1048 + /* for rounding to nearest, we couldn't conclude up to here in the following
1050 + 1. sh = 0, then cmp_low=0: we can either truncate, subtract one ulp
1051 + or add one ulp: -1 ulp < low(b)-low(c) < 1 ulp
1052 + 2. sh > 0 but the low sh bits from high(b)-high(c) equal 2^(sh-1):
1053 + -0.5 ulp <= -1/2^sh < low(b)-low(c)-0.5 < 1/2^sh <= 0.5 ulp
1054 + we can't decide the rounding, in that case cmp_low=2:
1055 + either we truncate and flag=-1, or we add one ulp and flag=1
1056 + 3. the low sh>0 bits from high(b)-high(c) equal 0: we know we have to
1057 + truncate but we can't decide the ternary value, here cmp_low=0:
1058 + -0.5 ulp <= -1/2^sh < low(b)-low(c) < 1/2^sh <= 0.5 ulp
1059 + we always truncate and inexact can be any of -1,0,1
1062 + /* note: here cn might exceed cn0, in which case we consider a zero limb */
1063 for (k = 0; (bn > 0) || (cn > 0); k = 1)
1065 + /* if cmp_low < 0, we know low(b) - low(c) < 0
1066 + if cmp_low > 0, we know low(b) - low(c) > 0
1067 + (more precisely if cmp_low = 2, low(b) - low(c) = 0.5 ulp so far)
1068 + if cmp_low = 0, so far low(b) - low(c) = 0 */
1070 /* get next limbs */
1071 bb = (bn > 0) ? bp[--bn] : 0;
1072 if ((cn > 0) && (cn-- <= cn0))
1073 @@ -357,76 +381,115 @@
1077 - /* down is set when low(b) < low(c) */
1080 + /* cmp_low compares low(b) and low(c) */
1081 + if (cmp_low == 0) /* case 1 or 3 */
1082 + cmp_low = (bb < cc) ? -2+k : (bb > cc) ? 1 : 0;
1084 + /* Case 1 for k=0 splits into 7 subcases:
1085 + 1a: bb > cc + half
1086 + 1b: bb = cc + half
1087 + 1c: 0 < bb - cc < half
1089 + 1e: -half < bb - cc < 0
1090 + 1f: bb - cc = -half
1091 + 1g: bb - cc < -half
1093 + Case 2 splits into 3 subcases:
1098 + Case 3 splits into 3 subcases:
1104 /* the case rounding to nearest with sh=0 is special since one couldn't
1105 subtract above 1/2 ulp in the trailing limb of the result */
1106 - if ((rnd_mode == MPFR_RNDN) && sh == 0 && k == 0)
1107 + if (rnd_mode == MPFR_RNDN && sh == 0 && k == 0) /* case 1 for k=0 */
1109 mp_limb_t half = MPFR_LIMB_HIGHBIT;
1111 - is_exact = (bb == cc);
1113 /* add one ulp if bb > cc + half
1114 truncate if cc - half < bb < cc + half
1115 sub one ulp if bb < cc - half
1119 + if (cmp_low < 0) /* bb < cc: -1 ulp < low(b) - low(c) < 0,
1120 + cases 1e, 1f and 1g */
1125 + else /* since bb < cc < half, bb+half < 2*half */
1127 + /* now we have bb < cc + half:
1128 + we have to subtract one ulp if bb < cc,
1129 + and truncate if bb > cc */
1131 - else /* bb >= cc */
1132 + else if (cmp_low >= 0) /* bb >= cc, cases 1a to 1d */
1137 + else /* since bb >= cc >= half, bb - half >= 0 */
1139 + /* now we have bb > cc - half: we have to add one ulp if bb > cc,
1140 + and truncate if bb < cc */
1147 - printf (" bb=%lu cc=%lu down=%d is_exact=%d\n",
1148 - (unsigned long) bb, (unsigned long) cc, down, is_exact);
1149 + printf ("k=%u bb=%lu cc=%lu cmp_low=%d\n", k,
1150 + (unsigned long) bb, (unsigned long) cc, cmp_low);
1153 + if (cmp_low < 0) /* low(b) - low(c) < 0: either truncate or subtract
1156 if (rnd_mode == MPFR_RNDZ)
1158 + goto sub_one_ulp; /* set inexact=-1 */
1159 else if (rnd_mode != MPFR_RNDN) /* round away */
1164 - else /* round to nearest: special case here since for sh=k=0
1165 - bb = bb0 - MPFR_LIMB_HIGHBIT */
1166 + else /* round to nearest */
1168 - if (is_exact && sh == 0)
1170 - /* For k=0 we can't decide exactness since it may depend
1171 - from low order bits.
1172 - For k=1, the first low limbs matched: low(b)-low(c)<0. */
1179 - else if (down && sh == 0)
1183 - inexact = (is_exact) ? 1 : -1;
1184 + /* If cmp_low < 0 and bb > cc, then -0.5 ulp < low(b)-low(c) < 0,
1185 + whatever the value of sh.
1186 + If sh>0, then cmp_low < 0 implies that the initial neglected
1187 + sh bits were 0 (otherwise cmp_low=2 initially), thus the
1188 + weight of the new bits is less than 0.5 ulp too.
1189 + If k > 0 (and sh=0) this means that either the first neglected
1190 + limbs bb and cc were equal (thus cmp_low was 0 for k=0),
1191 + or we had bb - cc = -0.5 ulp or 0.5 ulp.
1192 + The last case is not possible here since we would have
1193 + cmp_low > 0 which is sticky.
1194 + In the first case (where we have cmp_low = -1), we truncate,
1195 + whereas in the 2nd case we have cmp_low = -2 and we subtract
1198 + if (bb > cc || sh > 0 || cmp_low == -1)
1199 + { /* -0.5 ulp < low(b)-low(c) < 0,
1200 + bb > cc corresponds to cases 1e and 1f1
1201 + sh > 0 corresponds to cases 3c and 3b3
1202 + cmp_low = -1 corresponds to case 1d3 (also 3b3) */
1206 + else if (bb < cc) /* here sh = 0 and low(b)-low(c) < -0.5 ulp,
1207 + this corresponds to cases 1g and 1f3 */
1209 + /* the only case where we can't conclude is sh=0 and bb=cc,
1210 + i.e., we have low(b) - low(c) = -0.5 ulp (up to now), thus
1211 + we don't know if we must truncate or subtract one ulp.
1212 + Note: for sh=0 we can't have low(b) - low(c) = -0.5 ulp up to
1213 + now, since low(b) - low(c) > 1/2^sh */
1217 + else if (cmp_low > 0) /* 0 < low(b) - low(c): either truncate or
1220 if (rnd_mode == MPFR_RNDZ)
1222 @@ -437,34 +500,70 @@
1224 else /* round to nearest */
1231 + /* if sh=0, then bb>cc means that low(b)-low(c) > 0.5 ulp,
1232 + and similarly when cmp_low=2 */
1233 + if (cmp_low == 2) /* cases 1a, 1b1, 2a and 2b1 */
1235 + /* sh > 0 and cmp_low > 0: this implies that the sh initial
1236 + neglected bits were 0, and the remaining low(b)-low(c)>0,
1237 + but its weight is less than 0.5 ulp */
1238 + else /* 0 < low(b) - low(c) < 0.5 ulp, this corresponds to
1239 + cases 3a, 1d1 and 3b1 */
1246 + else if (bb < cc) /* 0 < low(b) - low(c) < 0.5 ulp, cases 1c,
1247 + 1b3, 2b3 and 2c */
1255 + /* the only case where we can't conclude is bb=cc, i.e.,
1256 + low(b) - low(c) = 0.5 ulp (up to now), thus we don't know
1257 + if we must truncate or add one ulp. */
1260 + /* after k=0, we cannot conclude in the following cases, we split them
1261 + according to the values of bb and cc for k=1:
1262 + 1b. sh=0 and cmp_low = 1 and bb-cc = half [around 0.5 ulp]
1263 + 1b1. bb > cc: add one ulp, inex = 1
1264 + 1b2: bb = cc: cannot conclude
1265 + 1b3: bb < cc: truncate, inex = -1
1266 + 1d. sh=0 and cmp_low = 0 and bb-cc = 0 [around 0]
1267 + 1d1: bb > cc: truncate, inex = -1
1268 + 1d2: bb = cc: cannot conclude
1269 + 1d3: bb < cc: truncate, inex = +1
1270 + 1f. sh=0 and cmp_low = -1 and bb-cc = -half [around -0.5 ulp]
1271 + 1f1: bb > cc: truncate, inex = +1
1272 + 1f2: bb = cc: cannot conclude
1273 + 1f3: bb < cc: sub one ulp, inex = -1
1274 + 2b. sh > 0 and cmp_low = 2 and bb=cc [around 0.5 ulp]
1275 + 2b1. bb > cc: add one ulp, inex = 1
1276 + 2b2: bb = cc: cannot conclude
1277 + 2b3: bb < cc: truncate, inex = -1
1278 + 3b. sh > 0 and cmp_low = 0 [around 0]
1279 + 3b1. bb > cc: truncate, inex = -1
1280 + 3b2: bb = cc: cannot conclude
1281 + 3b3: bb < cc: truncate, inex = +1
1285 - if ((rnd_mode == MPFR_RNDN) && !is_exact)
1286 + if ((rnd_mode == MPFR_RNDN) && cmp_low != 0)
1288 /* even rounding rule */
1289 if ((ap[0] >> sh) & 1)
1298 - inexact = (down) ? 1 : -1;
1299 + inexact = (cmp_low > 0) ? -1 : 1;
1303 diff -Naurd mpfr-3.0.0-a/tests/tfma.c mpfr-3.0.0-b/tests/tfma.c
1304 --- mpfr-3.0.0-a/tests/tfma.c 2010-06-10 11:00:13.000000000 +0000
1305 +++ mpfr-3.0.0-b/tests/tfma.c 2010-10-21 20:59:32.000000000 +0000
1306 @@ -337,6 +337,94 @@
1307 mpfr_clears (x, y, z, r, (mpfr_ptr) 0);
1313 + mpfr_t x, y, z, t, u;
1316 + mpfr_init2 (x, 64);
1317 + mpfr_init2 (y, 64);
1318 + mpfr_init2 (z, 64);
1319 + mpfr_init2 (t, 64);
1320 + mpfr_init2 (u, 64);
1322 + mpfr_set_str (x, "0xf.fffffffffffffffp-14766", 16, MPFR_RNDN);
1323 + mpfr_set_str (y, "-0xf.fffffffffffffffp+317", 16, MPFR_RNDN);
1324 + mpfr_set_str (z, "0x8.3ffffffffffe3ffp-14443", 16, MPFR_RNDN);
1325 + mpfr_set_str (t, "0x8.7ffffffffffc7ffp-14444", 16, MPFR_RNDN);
1326 + i = mpfr_fma (u, x, y, z, MPFR_RNDN);
1327 + if (mpfr_cmp (u, t) != 0)
1329 + printf ("Wrong result in bug20101018 (a)\n");
1330 + printf ("Expected ");
1331 + mpfr_out_str (stdout, 16, 0, t, MPFR_RNDN);
1332 + printf ("\nGot ");
1333 + mpfr_out_str (stdout, 16, 0, u, MPFR_RNDN);
1339 + printf ("Wrong ternary value in bug20101018 (a)\n");
1340 + printf ("Expected > 0\n");
1341 + printf ("Got %d\n", i);
1345 + mpfr_set_str (x, "-0xf.fffffffffffffffp-11420", 16, MPFR_RNDN);
1346 + mpfr_set_str (y, "0xf.fffffffffffffffp+9863", 16, MPFR_RNDN);
1347 + mpfr_set_str (z, "0x8.fffff80ffffffffp-1551", 16, MPFR_RNDN);
1348 + mpfr_set_str (t, "0x9.fffff01ffffffffp-1552", 16, MPFR_RNDN);
1349 + i = mpfr_fma (u, x, y, z, MPFR_RNDN);
1350 + if (mpfr_cmp (u, t) != 0)
1352 + printf ("Wrong result in bug20101018 (b)\n");
1353 + printf ("Expected ");
1354 + mpfr_out_str (stdout, 16, 0, t, MPFR_RNDN);
1355 + printf ("\nGot ");
1356 + mpfr_out_str (stdout, 16, 0, u, MPFR_RNDN);
1362 + printf ("Wrong ternary value in bug20101018 (b)\n");
1363 + printf ("Expected > 0\n");
1364 + printf ("Got %d\n", i);
1368 + mpfr_set_str (x, "0xf.fffffffffffffffp-2125", 16, MPFR_RNDN);
1369 + mpfr_set_str (y, "-0xf.fffffffffffffffp-6000", 16, MPFR_RNDN);
1370 + mpfr_set_str (z, "0x8p-8119", 16, MPFR_RNDN);
1371 + mpfr_set_str (t, "0x8.000000000000001p-8120", 16, MPFR_RNDN);
1372 + i = mpfr_fma (u, x, y, z, MPFR_RNDN);
1373 + if (mpfr_cmp (u, t) != 0)
1375 + printf ("Wrong result in bug20101018 (c)\n");
1376 + printf ("Expected ");
1377 + mpfr_out_str (stdout, 16, 0, t, MPFR_RNDN);
1378 + printf ("\nGot ");
1379 + mpfr_out_str (stdout, 16, 0, u, MPFR_RNDN);
1385 + printf ("Wrong ternary value in bug20101018 (c)\n");
1386 + printf ("Expected > 0\n");
1387 + printf ("Got %d\n", i);
1399 main (int argc, char *argv[])
1403 tests_start_mpfr ();
1410 diff -Naurd mpfr-3.0.0-a/tests/tsub.c mpfr-3.0.0-b/tests/tsub.c
1411 --- mpfr-3.0.0-a/tests/tsub.c 2010-06-10 11:00:13.000000000 +0000
1412 +++ mpfr-3.0.0-b/tests/tsub.c 2010-10-21 20:59:32.000000000 +0000
1414 if (mpfr_cmp (z, x))
1416 printf ("Error in mpfr_sub (2)\n");
1417 + printf ("Expected "); mpfr_print_binary (x); puts ("");
1418 + printf ("Got "); mpfr_print_binary (z); puts ("");
1421 mpfr_set_str_binary (x, "1.1110111011110001110111011111111111101000011001011100101100101101");
1422 @@ -478,6 +480,156 @@
1426 +/* Bug found by Jakub Jelinek
1427 + * http://bugzilla.redhat.com/643657
1428 + * https://gforge.inria.fr/tracker/index.php?func=detail&aid=11301
1429 + * The consequence can be either an assertion failure (i = 2 in the
1430 + * testcase below, in debug mode) or an incorrectly rounded value.
1439 + mpfr_init2 (a, GMP_NUMB_BITS * 2);
1440 + mpfr_init2 (b, GMP_NUMB_BITS);
1441 + mpfr_init2 (c, GMP_NUMB_BITS);
1443 + /* a = 2^(2N) + k.2^(2N-1) + 2^N and b = 1
1444 + with N = GMP_NUMB_BITS and k = 0 or 1.
1445 + c = a - b should round to the same value as a. */
1447 + for (i = 2; i <= 3; i++)
1449 + mpfr_set_ui_2exp (a, i, GMP_NUMB_BITS - 1, MPFR_RNDN);
1450 + mpfr_add_ui (a, a, 1, MPFR_RNDN);
1451 + mpfr_mul_2ui (a, a, GMP_NUMB_BITS, MPFR_RNDN);
1452 + mpfr_set_ui (b, 1, MPFR_RNDN);
1453 + inex = mpfr_sub (c, a, b, MPFR_RNDN);
1454 + mpfr_set (b, a, MPFR_RNDN);
1455 + if (! mpfr_equal_p (c, b))
1457 + printf ("Error in bug20101017 for i = %d.\n", i);
1458 + printf ("Expected ");
1459 + mpfr_out_str (stdout, 16, 0, b, MPFR_RNDN);
1462 + mpfr_out_str (stdout, 16, 0, c, MPFR_RNDN);
1468 + printf ("Error in bug20101017 for i = %d: bad inex value.\n", i);
1469 + printf ("Expected negative, got %d.\n", inex);
1474 + mpfr_set_prec (a, 64);
1475 + mpfr_set_prec (b, 129);
1476 + mpfr_set_prec (c, 2);
1477 + mpfr_set_str_binary (b, "0.100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001E65");
1478 + mpfr_set_str_binary (c, "0.10E1");
1479 + inex = mpfr_sub (a, b, c, MPFR_RNDN);
1480 + if (mpfr_cmp_ui_2exp (a, 1, 64) != 0 || inex >= 0)
1482 + printf ("Error in mpfr_sub for b-c for b=2^64+1+2^(-64), c=1\n");
1483 + printf ("Expected result 2^64 with inex < 0\n");
1484 + printf ("Got "); mpfr_print_binary (a);
1485 + printf (" with inex=%d\n", inex);
1489 + mpfr_clears (a, b, c, (mpfr_ptr) 0);
1492 +/* hard test of rounding */
1494 +check_rounding (void)
1496 + mpfr_t a, b, c, res;
1501 +#define MAXKL (2 * GMP_NUMB_BITS)
1502 + for (p = MPFR_PREC_MIN; p <= GMP_NUMB_BITS; p++)
1504 + mpfr_init2 (a, p);
1505 + mpfr_init2 (res, p);
1506 + mpfr_init2 (b, p + 1 + MAXKL);
1507 + mpfr_init2 (c, MPFR_PREC_MIN);
1509 + /* b = 2^p + 1 + 2^(-k), c = 2^(-l) */
1510 + for (k = 0; k <= MAXKL; k++)
1511 + for (l = 0; l <= MAXKL; l++)
1513 + mpfr_set_ui_2exp (b, 1, p, MPFR_RNDN);
1514 + mpfr_add_ui (b, b, 1, MPFR_RNDN);
1515 + mpfr_mul_2ui (b, b, k, MPFR_RNDN);
1516 + mpfr_add_ui (b, b, 1, MPFR_RNDN);
1517 + mpfr_div_2ui (b, b, k, MPFR_RNDN);
1518 + mpfr_set_ui_2exp (c, 1, -l, MPFR_RNDN);
1519 + i = mpfr_sub (a, b, c, MPFR_RNDN);
1520 + /* b - c = 2^p + 1 + 2^(-k) - 2^(-l), should be rounded to
1521 + 2^p for l <= k, and 2^p+2 for l < k */
1524 + if (mpfr_cmp_ui_2exp (a, 1, p) != 0)
1526 + printf ("Wrong result in check_rounding\n");
1527 + printf ("p=%lu k=%ld l=%ld\n", p, k, l);
1528 + printf ("b="); mpfr_print_binary (b); puts ("");
1529 + printf ("c="); mpfr_print_binary (c); puts ("");
1530 + printf ("Expected 2^%lu\n", p);
1531 + printf ("Got "); mpfr_print_binary (a); puts ("");
1536 + printf ("Wrong ternary value in check_rounding\n");
1537 + printf ("p=%lu k=%ld l=%ld\n", p, k, l);
1538 + printf ("b="); mpfr_print_binary (b); puts ("");
1539 + printf ("c="); mpfr_print_binary (c); puts ("");
1540 + printf ("a="); mpfr_print_binary (a); puts ("");
1541 + printf ("Expected < 0, got %d\n", i);
1547 + mpfr_set_ui_2exp (res, 1, p, MPFR_RNDN);
1548 + mpfr_add_ui (res, res, 2, MPFR_RNDN);
1549 + if (mpfr_cmp (a, res) != 0)
1551 + printf ("Wrong result in check_rounding\n");
1552 + printf ("b="); mpfr_print_binary (b); puts ("");
1553 + printf ("c="); mpfr_print_binary (c); puts ("");
1554 + printf ("Expected "); mpfr_print_binary (res); puts ("");
1555 + printf ("Got "); mpfr_print_binary (a); puts ("");
1560 + printf ("Wrong ternary value in check_rounding\n");
1561 + printf ("b="); mpfr_print_binary (b); puts ("");
1562 + printf ("c="); mpfr_print_binary (c); puts ("");
1563 + printf ("Expected > 0, got %d\n", i);
1576 #define TEST_FUNCTION test_sub
1578 #define RAND_FUNCTION(x) mpfr_random2(x, MPFR_LIMB_SIZE (x), randlimb () % 100, RANDS)
1581 tests_start_mpfr ();
1584 + check_rounding ();
1588 diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
1589 --- mpfr-3.0.0-a/version.c 2010-10-21 20:28:38.000000000 +0000
1590 +++ mpfr-3.0.0-b/version.c 2010-10-21 20:59:32.000000000 +0000
1593 mpfr_get_version (void)
1595 - return "3.0.0-p5";
1596 + return "3.0.0-p6";
1598 diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
1599 --- mpfr-3.0.0-a/PATCHES 2010-10-21 21:18:26.000000000 +0000
1600 +++ mpfr-3.0.0-b/PATCHES 2010-10-21 21:18:26.000000000 +0000
1603 diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
1604 --- mpfr-3.0.0-a/VERSION 2010-10-21 20:59:32.000000000 +0000
1605 +++ mpfr-3.0.0-b/VERSION 2010-10-21 21:18:26.000000000 +0000
1609 diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
1610 --- mpfr-3.0.0-a/mpfr.h 2010-10-21 20:59:32.000000000 +0000
1611 +++ mpfr-3.0.0-b/mpfr.h 2010-10-21 21:18:26.000000000 +0000
1613 #define MPFR_VERSION_MAJOR 3
1614 #define MPFR_VERSION_MINOR 0
1615 #define MPFR_VERSION_PATCHLEVEL 0
1616 -#define MPFR_VERSION_STRING "3.0.0-p6"
1617 +#define MPFR_VERSION_STRING "3.0.0-p7"
1619 /* Macros dealing with MPFR VERSION */
1620 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
1621 diff -Naurd mpfr-3.0.0-a/set_ld.c mpfr-3.0.0-b/set_ld.c
1622 --- mpfr-3.0.0-a/set_ld.c 2010-06-10 11:00:14.000000000 +0000
1623 +++ mpfr-3.0.0-b/set_ld.c 2010-10-21 21:18:26.000000000 +0000
1624 @@ -102,21 +102,25 @@
1626 x /= div13; /* exact */
1628 + mpfr_div_2si (t, t, 8192, MPFR_RNDZ);
1630 if (ABS (x) >= div12)
1632 x /= div12; /* exact */
1634 + mpfr_div_2si (t, t, 4096, MPFR_RNDZ);
1636 if (ABS (x) >= div11)
1638 x /= div11; /* exact */
1640 + mpfr_div_2si (t, t, 2048, MPFR_RNDZ);
1642 if (ABS (x) >= div10)
1644 x /= div10; /* exact */
1646 + mpfr_div_2si (t, t, 1024, MPFR_RNDZ);
1648 /* warning: we may have DBL_MAX=2^1024*(1-2^(-53)) < x < 2^1024,
1649 therefore we have one extra exponent reduction step */
1650 @@ -124,9 +128,10 @@
1652 x /= div9; /* exact */
1654 + mpfr_div_2si (t, t, 512, MPFR_RNDZ);
1656 } /* Check overflow of double */
1658 + else /* no overflow on double */
1660 long double div9, div10, div11;
1662 @@ -149,29 +154,34 @@
1664 x /= div13; /* exact */
1666 + mpfr_mul_2si (t, t, 8192, MPFR_RNDZ);
1668 if (ABS (x) <= div12)
1670 x /= div12; /* exact */
1672 + mpfr_mul_2si (t, t, 4096, MPFR_RNDZ);
1674 if (ABS (x) <= div11)
1676 x /= div11; /* exact */
1678 + mpfr_mul_2si (t, t, 2048, MPFR_RNDZ);
1680 if (ABS (x) <= div10)
1682 x /= div10; /* exact */
1684 + mpfr_mul_2si (t, t, 1024, MPFR_RNDZ);
1688 x /= div9; /* exact */
1690 + mpfr_mul_2si (t, t, 512, MPFR_RNDZ);
1694 + else /* no underflow */
1696 inexact = mpfr_set_d (u, (double) x, MPFR_RNDZ);
1697 MPFR_ASSERTD (inexact == 0);
1698 diff -Naurd mpfr-3.0.0-a/tests/tset_ld.c mpfr-3.0.0-b/tests/tset_ld.c
1699 --- mpfr-3.0.0-a/tests/tset_ld.c 2010-06-10 11:00:13.000000000 +0000
1700 +++ mpfr-3.0.0-b/tests/tset_ld.c 2010-10-21 21:18:26.000000000 +0000
1701 @@ -147,12 +147,39 @@
1702 test_fixed_bugs (void)
1708 /* bug found by Steve Kargl (2009-03-14) */
1710 mpfr_set_ui_2exp (x, 1, -16447, MPFR_RNDN);
1711 - d = mpfr_get_ld (x, MPFR_RNDN); /* an assertion failed in init2.c:50 */
1712 + mpfr_get_ld (x, MPFR_RNDN); /* an assertion failed in init2.c:50 */
1714 + /* bug reported by Jakub Jelinek (2010-10-17)
1715 + https://gforge.inria.fr/tracker/?func=detail&aid=11300 */
1716 + mpfr_set_prec (x, MPFR_LDBL_MANT_DIG);
1717 + /* l = 0x1.23456789abcdef0123456789abcdp-914L; */
1718 + l = 8.215640181713713164092636634579e-276;
1719 + mpfr_set_ld (x, l, MPFR_RNDN);
1720 + m = mpfr_get_ld (x, MPFR_RNDN);
1723 + printf ("Error in get_ld o set_ld for l=%Le\n", l);
1724 + printf ("Got m=%Le instead of l\n", m);
1728 + /* another similar test which failed with extended double precision and the
1729 + generic code for mpfr_set_ld */
1730 + /* l = 0x1.23456789abcdef0123456789abcdp-968L; */
1731 + l = 4.560596445887084662336528403703e-292;
1732 + mpfr_set_ld (x, l, MPFR_RNDN);
1733 + m = mpfr_get_ld (x, MPFR_RNDN);
1736 + printf ("Error in get_ld o set_ld for l=%Le\n", l);
1737 + printf ("Got m=%Le instead of l\n", m);
1743 diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
1744 --- mpfr-3.0.0-a/version.c 2010-10-21 20:59:32.000000000 +0000
1745 +++ mpfr-3.0.0-b/version.c 2010-10-21 21:18:26.000000000 +0000
1748 mpfr_get_version (void)
1750 - return "3.0.0-p6";
1751 + return "3.0.0-p7";
1753 diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
1754 --- mpfr-3.0.0-a/PATCHES 2010-11-09 15:15:07.000000000 +0000
1755 +++ mpfr-3.0.0-b/PATCHES 2010-11-09 15:15:07.000000000 +0000
1758 diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
1759 --- mpfr-3.0.0-a/VERSION 2010-10-21 21:18:26.000000000 +0000
1760 +++ mpfr-3.0.0-b/VERSION 2010-11-09 15:15:07.000000000 +0000
1764 diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
1765 --- mpfr-3.0.0-a/mpfr.h 2010-10-21 21:18:26.000000000 +0000
1766 +++ mpfr-3.0.0-b/mpfr.h 2010-11-09 15:15:07.000000000 +0000
1768 #define MPFR_VERSION_MAJOR 3
1769 #define MPFR_VERSION_MINOR 0
1770 #define MPFR_VERSION_PATCHLEVEL 0
1771 -#define MPFR_VERSION_STRING "3.0.0-p7"
1772 +#define MPFR_VERSION_STRING "3.0.0-p8"
1774 /* Macros dealing with MPFR VERSION */
1775 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
1777 # define _MPFR_H_HAVE_INTMAX_T 1
1780 +/* Avoid some problems with macro expansion if the user defines macros
1781 + with the same name as keywords. By convention, identifiers and macro
1782 + names starting with mpfr_ are reserved by MPFR. */
1783 +typedef void mpfr_void;
1784 +typedef int mpfr_int;
1785 +typedef unsigned int mpfr_uint;
1786 +typedef long mpfr_long;
1787 +typedef unsigned long mpfr_ulong;
1788 +typedef size_t mpfr_size_t;
1790 /* Definition of rounding modes (DON'T USE MPFR_RNDNA!).
1791 Warning! Changing the contents of this enum should be seen as an
1792 interface change since the old and the new types are not compatible
1794 typedef mp_exp_t mpfr_exp_t;
1796 /* Definition of the standard exponent limits */
1797 -#define MPFR_EMAX_DEFAULT ((mpfr_exp_t) (((unsigned long) 1 << 30) - 1))
1798 +#define MPFR_EMAX_DEFAULT ((mpfr_exp_t) (((mpfr_ulong) 1 << 30) - 1))
1799 #define MPFR_EMIN_DEFAULT (-(MPFR_EMAX_DEFAULT))
1801 /* Definition of the main structure */
1802 @@ -725,13 +735,13 @@
1803 unexpected results with future compilers and aggressive optimisations.
1804 Why not working only with signed types, using INT_MIN and LONG_MIN? */
1805 #if __GMP_MP_SIZE_T_INT
1806 -#define __MPFR_EXP_NAN ((mpfr_exp_t)((~((~(unsigned int)0)>>1))+2))
1807 -#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(unsigned int)0)>>1))+1))
1808 -#define __MPFR_EXP_INF ((mpfr_exp_t)((~((~(unsigned int)0)>>1))+3))
1809 +#define __MPFR_EXP_NAN ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+2))
1810 +#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+1))
1811 +#define __MPFR_EXP_INF ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+3))
1813 -#define __MPFR_EXP_NAN ((mpfr_exp_t)((~((~(unsigned long)0)>>1))+2))
1814 -#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(unsigned long)0)>>1))+1))
1815 -#define __MPFR_EXP_INF ((mpfr_exp_t)((~((~(unsigned long)0)>>1))+3))
1816 +#define __MPFR_EXP_NAN ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+2))
1817 +#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+1))
1818 +#define __MPFR_EXP_INF ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+3))
1821 /* Define MPFR_USE_EXTENSION to avoid "gcc -pedantic" warnings. */
1823 #define mpfr_inf_p(_x) ((_x)->_mpfr_exp == __MPFR_EXP_INF)
1824 #define mpfr_zero_p(_x) ((_x)->_mpfr_exp == __MPFR_EXP_ZERO)
1825 #define mpfr_regular_p(_x) ((_x)->_mpfr_exp > __MPFR_EXP_INF)
1826 -#define mpfr_sgn(_x) \
1827 - ((_x)->_mpfr_exp < __MPFR_EXP_INF ? \
1828 - (mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (void) 0), 0 : \
1829 +#define mpfr_sgn(_x) \
1830 + ((_x)->_mpfr_exp < __MPFR_EXP_INF ? \
1831 + (mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (mpfr_void) 0), 0 : \
1834 /* Prevent them from using as lvalues */
1835 @@ -805,7 +815,19 @@
1836 Moreover casts to unsigned long have been added to avoid warnings in
1837 programs that use MPFR and are compiled with -Wconversion; such casts
1838 are OK since if X is a constant expression, then (unsigned long) X is
1839 - also a constant expression, so that the optimizations still work. */
1840 + also a constant expression, so that the optimizations still work. The
1841 + warnings are probably related to the following two bugs:
1842 + http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210
1843 + http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38470 (possibly a variant)
1844 + and the casts could be removed once these bugs are fixed.
1845 + Casts shouldn't be used on the generic calls (to the ..._2exp functions),
1846 + where implicit conversions are performed. Indeed, having at least one
1847 + implicit conversion in the macro allows the compiler to emit diagnostics
1848 + when normally expected, for instance in the following call:
1849 + mpfr_set_ui (x, "foo", MPFR_RNDN);
1850 + If this is not possible (for future macros), one of the tricks described
1851 + on http://groups.google.com/group/comp.std.c/msg/e92abd24bf9eaf7b could
1853 #if defined (__GNUC__) && !defined(__ICC) && !defined(__cplusplus)
1856 @@ -813,45 +835,45 @@
1857 But warning! mpfr_sgn is specified as a macro in the API, thus the macro
1858 mustn't be used if side effects are possible, like here. */
1859 #define mpfr_cmp_ui(_f,_u) \
1860 - (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ? \
1861 + (__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ? \
1863 - mpfr_cmp_ui_2exp ((_f), (unsigned long) (_u), 0))
1864 + mpfr_cmp_ui_2exp ((_f), (_u), 0))
1866 -#define mpfr_cmp_si(_f,_s) \
1867 - (__builtin_constant_p (_s) && (long) (_s) >= 0 ? \
1868 - mpfr_cmp_ui ((_f), (unsigned long) (long) (_s)) : \
1869 - mpfr_cmp_si_2exp ((_f), (long) (_s), 0))
1870 +#define mpfr_cmp_si(_f,_s) \
1871 + (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ? \
1872 + mpfr_cmp_ui ((_f), (mpfr_ulong) (mpfr_long) (_s)) : \
1873 + mpfr_cmp_si_2exp ((_f), (_s), 0))
1874 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95
1876 #define mpfr_set_ui(_f,_u,_r) \
1877 - (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ? \
1878 + (__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ? \
1880 mpfr_ptr _p = (_f); \
1881 _p->_mpfr_sign = 1; \
1882 _p->_mpfr_exp = __MPFR_EXP_ZERO; \
1883 - (void) (_r); 0; }) : \
1884 - mpfr_set_ui_2exp ((_f), (unsigned long) (_u), 0, (_r)))
1885 + (mpfr_void) (_r); 0; }) : \
1886 + mpfr_set_ui_2exp ((_f), (_u), 0, (_r)))
1889 #define mpfr_set_si(_f,_s,_r) \
1890 - (__builtin_constant_p (_s) && (long) (_s) >= 0 ? \
1891 - mpfr_set_ui ((_f), (unsigned long) (long) (_s), (_r)) : \
1892 - mpfr_set_si_2exp ((_f), (long) (_s), 0, (_r)))
1893 + (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ? \
1894 + mpfr_set_ui ((_f), (mpfr_ulong) (mpfr_long) (_s), (_r)) : \
1895 + mpfr_set_si_2exp ((_f), (_s), 0, (_r)))
1899 /* Macro version of mpfr_stack interface for fast access */
1900 -#define mpfr_custom_get_size(p) ((size_t) \
1901 +#define mpfr_custom_get_size(p) ((mpfr_size_t) \
1902 (((p)+GMP_NUMB_BITS-1)/GMP_NUMB_BITS*sizeof (mp_limb_t)))
1903 #define mpfr_custom_init(m,p) do {} while (0)
1904 -#define mpfr_custom_get_significand(x) ((void*)((x)->_mpfr_d))
1905 +#define mpfr_custom_get_significand(x) ((mpfr_void*)((x)->_mpfr_d))
1906 #define mpfr_custom_get_exp(x) ((x)->_mpfr_exp)
1907 #define mpfr_custom_move(x,m) do { ((x)->_mpfr_d = (mp_limb_t*)(m)); } while (0)
1908 #define mpfr_custom_init_set(x,k,e,p,m) do { \
1909 mpfr_ptr _x = (x); \
1913 + mpfr_int _s, _k; \
1916 _t = (mpfr_kind_t) _k; \
1917 @@ -868,11 +890,13 @@
1918 _x->_mpfr_exp = _e; \
1919 _x->_mpfr_d = (mp_limb_t*) (m); \
1921 -#define mpfr_custom_get_kind(x) \
1922 - ( (x)->_mpfr_exp > __MPFR_EXP_INF ? (int)MPFR_REGULAR_KIND*MPFR_SIGN (x) \
1923 - : (x)->_mpfr_exp == __MPFR_EXP_INF ? (int)MPFR_INF_KIND*MPFR_SIGN (x) \
1924 - : (x)->_mpfr_exp == __MPFR_EXP_NAN ? (int)MPFR_NAN_KIND \
1925 - : (int) MPFR_ZERO_KIND * MPFR_SIGN (x) )
1926 +#define mpfr_custom_get_kind(x) \
1927 + ( (x)->_mpfr_exp > __MPFR_EXP_INF ? \
1928 + (mpfr_int) MPFR_REGULAR_KIND * MPFR_SIGN (x) \
1929 + : (x)->_mpfr_exp == __MPFR_EXP_INF ? \
1930 + (mpfr_int) MPFR_INF_KIND * MPFR_SIGN (x) \
1931 + : (x)->_mpfr_exp == __MPFR_EXP_NAN ? (mpfr_int) MPFR_NAN_KIND \
1932 + : (mpfr_int) MPFR_ZERO_KIND * MPFR_SIGN (x) )
1935 #endif /* MPFR_USE_NO_MACRO */
1936 diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
1937 --- mpfr-3.0.0-a/version.c 2010-10-21 21:18:26.000000000 +0000
1938 +++ mpfr-3.0.0-b/version.c 2010-11-09 15:15:07.000000000 +0000
1941 mpfr_get_version (void)
1943 - return "3.0.0-p7";
1944 + return "3.0.0-p8";