wok-next diff mpfr/stuff/mpfr-3.0.0.patch @ rev 11168
ftgl: Clean up.
author | Christopher Rogers <slaxemulator@gmail.com> |
---|---|
date | Wed Nov 02 07:12:20 2011 +0000 (2011-11-02) |
parents | 30f061368a04 |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/mpfr/stuff/mpfr-3.0.0.patch Wed Nov 02 07:12:20 2011 +0000 1.3 @@ -0,0 +1,1945 @@ 1.4 +diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES 1.5 +--- mpfr-3.0.0-a/PATCHES 2010-06-23 11:02:49.000000000 +0000 1.6 ++++ mpfr-3.0.0-b/PATCHES 2010-06-23 11:03:36.000000000 +0000 1.7 +@@ -0,0 +1 @@ 1.8 ++mpfr_out_str 1.9 +diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION 1.10 +--- mpfr-3.0.0-a/VERSION 2010-06-10 11:00:14.000000000 +0000 1.11 ++++ mpfr-3.0.0-b/VERSION 2010-06-23 11:03:20.000000000 +0000 1.12 +@@ -1 +1 @@ 1.13 +-3.0.0 1.14 ++3.0.0-p1 1.15 +diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h 1.16 +--- mpfr-3.0.0-a/mpfr.h 2010-06-10 11:00:14.000000000 +0000 1.17 ++++ mpfr-3.0.0-b/mpfr.h 2010-06-23 11:03:20.000000000 +0000 1.18 +@@ -27,7 +27,7 @@ 1.19 + #define MPFR_VERSION_MAJOR 3 1.20 + #define MPFR_VERSION_MINOR 0 1.21 + #define MPFR_VERSION_PATCHLEVEL 0 1.22 +-#define MPFR_VERSION_STRING "3.0.0" 1.23 ++#define MPFR_VERSION_STRING "3.0.0-p1" 1.24 + 1.25 + /* Macros dealing with MPFR VERSION */ 1.26 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) 1.27 +diff -Naurd mpfr-3.0.0-a/mpfr.texi mpfr-3.0.0-b/mpfr.texi 1.28 +--- mpfr-3.0.0-a/mpfr.texi 2010-06-10 11:00:14.000000000 +0000 1.29 ++++ mpfr-3.0.0-b/mpfr.texi 2010-06-23 11:03:12.000000000 +0000 1.30 +@@ -2050,7 +2050,7 @@ 1.31 + are printed. If @var{base} is greater than 10, @samp{@@} will be used 1.32 + instead of @samp{e} as exponent delimiter. 1.33 + 1.34 +-Return the number of bytes written, or if an error occurred, return 0. 1.35 ++Return the number of characters written, or if an error occurred, return 0. 1.36 + @end deftypefun 1.37 + 1.38 + @deftypefun size_t mpfr_inp_str (mpfr_t @var{rop}, FILE *@var{stream}, int @var{base}, mpfr_rnd_t @var{rnd}) 1.39 +diff -Naurd mpfr-3.0.0-a/out_str.c mpfr-3.0.0-b/out_str.c 1.40 +--- mpfr-3.0.0-a/out_str.c 2010-06-10 11:00:14.000000000 +0000 1.41 ++++ mpfr-3.0.0-b/out_str.c 2010-06-23 11:03:12.000000000 +0000 1.42 +@@ -22,6 +22,16 @@ 1.43 + 1.44 + #include "mpfr-impl.h" 1.45 + 1.46 ++/* Warning! S should not contain "%". */ 1.47 ++#define OUT_STR_RET(S) \ 1.48 ++ do \ 1.49 ++ { \ 1.50 ++ int r; \ 1.51 ++ r = fprintf (stream, (S)); \ 1.52 ++ return r < 0 ? 0 : r; \ 1.53 ++ } \ 1.54 ++ while (0) 1.55 ++ 1.56 + size_t 1.57 + mpfr_out_str (FILE *stream, int base, size_t n_digits, mpfr_srcptr op, 1.58 + mpfr_rnd_t rnd_mode) 1.59 +@@ -29,6 +39,7 @@ 1.60 + char *s, *s0; 1.61 + size_t l; 1.62 + mpfr_exp_t e; 1.63 ++ int err; 1.64 + 1.65 + MPFR_ASSERTN (base >= 2 && base <= 62); 1.66 + 1.67 +@@ -36,37 +47,16 @@ 1.68 + if (stream == NULL) 1.69 + stream = stdout; 1.70 + 1.71 +- if (MPFR_IS_NAN(op)) 1.72 +- { 1.73 +- fprintf (stream, "@NaN@"); 1.74 +- return 3; 1.75 +- } 1.76 +- 1.77 +- if (MPFR_IS_INF(op)) 1.78 +- { 1.79 +- if (MPFR_SIGN(op) > 0) 1.80 +- { 1.81 +- fprintf (stream, "@Inf@"); 1.82 +- return 3; 1.83 +- } 1.84 +- else 1.85 +- { 1.86 +- fprintf (stream, "-@Inf@"); 1.87 +- return 4; 1.88 +- } 1.89 +- } 1.90 +- 1.91 +- if (MPFR_IS_ZERO(op)) 1.92 ++ if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (op))) 1.93 + { 1.94 +- if (MPFR_SIGN(op) > 0) 1.95 +- { 1.96 +- fprintf(stream, "0"); 1.97 +- return 1; 1.98 +- } 1.99 ++ if (MPFR_IS_NAN (op)) 1.100 ++ OUT_STR_RET ("@NaN@"); 1.101 ++ else if (MPFR_IS_INF (op)) 1.102 ++ OUT_STR_RET (MPFR_IS_POS (op) ? "@Inf@" : "-@Inf@"); 1.103 + else 1.104 + { 1.105 +- fprintf(stream, "-0"); 1.106 +- return 2; 1.107 ++ MPFR_ASSERTD (MPFR_IS_ZERO (op)); 1.108 ++ OUT_STR_RET (MPFR_IS_POS (op) ? "0" : "-0"); 1.109 + } 1.110 + } 1.111 + 1.112 +@@ -77,21 +67,31 @@ 1.113 + 1.114 + l = strlen (s) + 1; /* size of allocated block returned by mpfr_get_str 1.115 + - may be incorrect, as only an upper bound? */ 1.116 +- if (*s == '-') 1.117 +- fputc (*s++, stream); 1.118 + 1.119 +- /* outputs mantissa */ 1.120 +- fputc (*s++, stream); e--; /* leading digit */ 1.121 +- fputc ((unsigned char) MPFR_DECIMAL_POINT, stream); 1.122 +- fputs (s, stream); /* rest of mantissa */ 1.123 ++ /* outputs possible sign and significand */ 1.124 ++ err = (*s == '-' && fputc (*s++, stream) == EOF) 1.125 ++ || fputc (*s++, stream) == EOF /* leading digit */ 1.126 ++ || fputc ((unsigned char) MPFR_DECIMAL_POINT, stream) == EOF 1.127 ++ || fputs (s, stream) == EOF; /* trailing significand */ 1.128 + (*__gmp_free_func) (s0, l); 1.129 ++ if (MPFR_UNLIKELY (err)) 1.130 ++ return 0; 1.131 ++ 1.132 ++ e--; /* due to the leading digit */ 1.133 + 1.134 + /* outputs exponent */ 1.135 + if (e) 1.136 + { 1.137 ++ int r; 1.138 ++ 1.139 + MPFR_ASSERTN(e >= LONG_MIN); 1.140 + MPFR_ASSERTN(e <= LONG_MAX); 1.141 +- l += fprintf (stream, (base <= 10 ? "e%ld" : "@%ld"), (long) e); 1.142 ++ 1.143 ++ r = fprintf (stream, (base <= 10 ? "e%ld" : "@%ld"), (long) e); 1.144 ++ if (MPFR_UNLIKELY (r < 0)) 1.145 ++ return 0; 1.146 ++ 1.147 ++ l += r; 1.148 + } 1.149 + 1.150 + return l; 1.151 +diff -Naurd mpfr-3.0.0-a/tests/tout_str.c mpfr-3.0.0-b/tests/tout_str.c 1.152 +--- mpfr-3.0.0-a/tests/tout_str.c 2010-06-10 11:00:13.000000000 +0000 1.153 ++++ mpfr-3.0.0-b/tests/tout_str.c 2010-06-23 11:03:12.000000000 +0000 1.154 +@@ -46,22 +46,54 @@ 1.155 + special (void) 1.156 + { 1.157 + mpfr_t x; 1.158 ++ unsigned int n; 1.159 + 1.160 + mpfr_init (x); 1.161 + 1.162 + mpfr_set_nan (x); 1.163 +- mpfr_out_str (fout, 10, 0, x, MPFR_RNDN); 1.164 ++ n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN); 1.165 ++ if (n != 5) 1.166 ++ { 1.167 ++ printf ("Error: mpfr_out_str (file, 10, 0, NaN, MPFR_RNDN) wrote %u " 1.168 ++ "characters instead of 5.\n", n); 1.169 ++ exit (1); 1.170 ++ } 1.171 + 1.172 + mpfr_set_inf (x, 1); 1.173 +- mpfr_out_str (fout, 10, 0, x, MPFR_RNDN); 1.174 ++ n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN); 1.175 ++ if (n != 5) 1.176 ++ { 1.177 ++ printf ("Error: mpfr_out_str (file, 10, 0, +Inf, MPFR_RNDN) wrote %u " 1.178 ++ "characters instead of 5.\n", n); 1.179 ++ exit (1); 1.180 ++ } 1.181 + 1.182 + mpfr_set_inf (x, -1); 1.183 +- mpfr_out_str (fout, 10, 0, x, MPFR_RNDN); 1.184 ++ n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN); 1.185 ++ if (n != 6) 1.186 ++ { 1.187 ++ printf ("Error: mpfr_out_str (file, 10, 0, -Inf, MPFR_RNDN) wrote %u " 1.188 ++ "characters instead of 6.\n", n); 1.189 ++ exit (1); 1.190 ++ } 1.191 + 1.192 + mpfr_set_ui (x, 0, MPFR_RNDN); 1.193 +- mpfr_out_str (fout, 10, 0, x, MPFR_RNDN); 1.194 ++ n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN); 1.195 ++ if (n != 1) 1.196 ++ { 1.197 ++ printf ("Error: mpfr_out_str (file, 10, 0, +0, MPFR_RNDN) wrote %u " 1.198 ++ "characters instead of 1.\n", n); 1.199 ++ exit (1); 1.200 ++ } 1.201 ++ 1.202 + mpfr_neg (x, x, MPFR_RNDN); 1.203 +- mpfr_out_str (fout, 10, 0, x, MPFR_RNDN); 1.204 ++ n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN); 1.205 ++ if (n != 2) 1.206 ++ { 1.207 ++ printf ("Error: mpfr_out_str (file, 10, 0, -0, MPFR_RNDN) wrote %u " 1.208 ++ "characters instead of 2.\n", n); 1.209 ++ exit (1); 1.210 ++ } 1.211 + 1.212 + mpfr_clear (x); 1.213 + } 1.214 +diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c 1.215 +--- mpfr-3.0.0-a/version.c 2010-06-10 11:00:14.000000000 +0000 1.216 ++++ mpfr-3.0.0-b/version.c 2010-06-23 11:03:20.000000000 +0000 1.217 +@@ -25,5 +25,5 @@ 1.218 + const char * 1.219 + mpfr_get_version (void) 1.220 + { 1.221 +- return "3.0.0"; 1.222 ++ return "3.0.0-p1"; 1.223 + } 1.224 +diff -Naurd mpfr-3.0.0-a/Makefile.in mpfr-3.0.0-b/Makefile.in 1.225 +--- mpfr-3.0.0-a/Makefile.in 2010-06-10 11:00:52.000000000 +0000 1.226 ++++ mpfr-3.0.0-b/Makefile.in 2010-06-10 11:00:52.000000000 +0000 1.227 +@@ -239,6 +239,7 @@ 1.228 + distuninstallcheck_listfiles = find . -type f -print 1.229 + distcleancheck_listfiles = find . -type f -print 1.230 + ACLOCAL = @ACLOCAL@ 1.231 ++ALLOCA = @ALLOCA@ 1.232 + AMTAR = @AMTAR@ 1.233 + AR = @AR@ 1.234 + AS = @AS@ 1.235 +diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES 1.236 +--- mpfr-3.0.0-a/PATCHES 2010-06-23 11:03:36.000000000 +0000 1.237 ++++ mpfr-3.0.0-b/PATCHES 2010-06-25 13:23:13.000000000 +0000 1.238 +@@ -0,0 +1 @@ 1.239 ++alloca 1.240 +diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION 1.241 +--- mpfr-3.0.0-a/VERSION 2010-06-23 11:03:20.000000000 +0000 1.242 ++++ mpfr-3.0.0-b/VERSION 2010-06-25 13:23:13.000000000 +0000 1.243 +@@ -1 +1 @@ 1.244 +-3.0.0-p1 1.245 ++3.0.0-p2 1.246 +diff -Naurd mpfr-3.0.0-a/acinclude.m4 mpfr-3.0.0-b/acinclude.m4 1.247 +--- mpfr-3.0.0-a/acinclude.m4 2010-06-10 11:00:14.000000000 +0000 1.248 ++++ mpfr-3.0.0-b/acinclude.m4 2010-06-10 11:00:14.000000000 +0000 1.249 +@@ -59,6 +59,9 @@ 1.250 + dnl sys/fpu.h - MIPS specific 1.251 + AC_CHECK_HEADERS([sys/time.h sys/fpu.h]) 1.252 + 1.253 ++dnl Check how to get `alloca' 1.254 ++AC_FUNC_ALLOCA 1.255 ++ 1.256 + dnl SIZE_MAX macro 1.257 + gl_SIZE_MAX 1.258 + 1.259 +diff -Naurd mpfr-3.0.0-a/configure mpfr-3.0.0-b/configure 1.260 +--- mpfr-3.0.0-a/configure 2010-06-10 11:00:51.000000000 +0000 1.261 ++++ mpfr-3.0.0-b/configure 2010-06-25 13:23:05.000000000 +0000 1.262 +@@ -783,6 +783,7 @@ 1.263 + OBJDUMP 1.264 + DLLTOOL 1.265 + AS 1.266 ++ALLOCA 1.267 + MPFR_LIBM 1.268 + ANSI2KNR 1.269 + U 1.270 +@@ -5622,6 +5623,197 @@ 1.271 + done 1.272 + 1.273 + 1.274 ++# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works 1.275 ++# for constant arguments. Useless! 1.276 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5 1.277 ++$as_echo_n "checking for working alloca.h... " >&6; } 1.278 ++if test "${ac_cv_working_alloca_h+set}" = set; then : 1.279 ++ $as_echo_n "(cached) " >&6 1.280 ++else 1.281 ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext 1.282 ++/* end confdefs.h. */ 1.283 ++#include <alloca.h> 1.284 ++int 1.285 ++main () 1.286 ++{ 1.287 ++char *p = (char *) alloca (2 * sizeof (int)); 1.288 ++ if (p) return 0; 1.289 ++ ; 1.290 ++ return 0; 1.291 ++} 1.292 ++_ACEOF 1.293 ++if ac_fn_c_try_link "$LINENO"; then : 1.294 ++ ac_cv_working_alloca_h=yes 1.295 ++else 1.296 ++ ac_cv_working_alloca_h=no 1.297 ++fi 1.298 ++rm -f core conftest.err conftest.$ac_objext \ 1.299 ++ conftest$ac_exeext conftest.$ac_ext 1.300 ++fi 1.301 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5 1.302 ++$as_echo "$ac_cv_working_alloca_h" >&6; } 1.303 ++if test $ac_cv_working_alloca_h = yes; then 1.304 ++ 1.305 ++$as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h 1.306 ++ 1.307 ++fi 1.308 ++ 1.309 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5 1.310 ++$as_echo_n "checking for alloca... " >&6; } 1.311 ++if test "${ac_cv_func_alloca_works+set}" = set; then : 1.312 ++ $as_echo_n "(cached) " >&6 1.313 ++else 1.314 ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext 1.315 ++/* end confdefs.h. */ 1.316 ++#ifdef __GNUC__ 1.317 ++# define alloca __builtin_alloca 1.318 ++#else 1.319 ++# ifdef _MSC_VER 1.320 ++# include <malloc.h> 1.321 ++# define alloca _alloca 1.322 ++# else 1.323 ++# ifdef HAVE_ALLOCA_H 1.324 ++# include <alloca.h> 1.325 ++# else 1.326 ++# ifdef _AIX 1.327 ++ #pragma alloca 1.328 ++# else 1.329 ++# ifndef alloca /* predefined by HP cc +Olibcalls */ 1.330 ++char *alloca (); 1.331 ++# endif 1.332 ++# endif 1.333 ++# endif 1.334 ++# endif 1.335 ++#endif 1.336 ++ 1.337 ++int 1.338 ++main () 1.339 ++{ 1.340 ++char *p = (char *) alloca (1); 1.341 ++ if (p) return 0; 1.342 ++ ; 1.343 ++ return 0; 1.344 ++} 1.345 ++_ACEOF 1.346 ++if ac_fn_c_try_link "$LINENO"; then : 1.347 ++ ac_cv_func_alloca_works=yes 1.348 ++else 1.349 ++ ac_cv_func_alloca_works=no 1.350 ++fi 1.351 ++rm -f core conftest.err conftest.$ac_objext \ 1.352 ++ conftest$ac_exeext conftest.$ac_ext 1.353 ++fi 1.354 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5 1.355 ++$as_echo "$ac_cv_func_alloca_works" >&6; } 1.356 ++ 1.357 ++if test $ac_cv_func_alloca_works = yes; then 1.358 ++ 1.359 ++$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h 1.360 ++ 1.361 ++else 1.362 ++ # The SVR3 libPW and SVR4 libucb both contain incompatible functions 1.363 ++# that cause trouble. Some versions do not even contain alloca or 1.364 ++# contain a buggy version. If you still want to use their alloca, 1.365 ++# use ar to extract alloca.o from them instead of compiling alloca.c. 1.366 ++ 1.367 ++ALLOCA=\${LIBOBJDIR}alloca.$ac_objext 1.368 ++ 1.369 ++$as_echo "#define C_ALLOCA 1" >>confdefs.h 1.370 ++ 1.371 ++ 1.372 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5 1.373 ++$as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; } 1.374 ++if test "${ac_cv_os_cray+set}" = set; then : 1.375 ++ $as_echo_n "(cached) " >&6 1.376 ++else 1.377 ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext 1.378 ++/* end confdefs.h. */ 1.379 ++#if defined CRAY && ! defined CRAY2 1.380 ++webecray 1.381 ++#else 1.382 ++wenotbecray 1.383 ++#endif 1.384 ++ 1.385 ++_ACEOF 1.386 ++if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | 1.387 ++ $EGREP "webecray" >/dev/null 2>&1; then : 1.388 ++ ac_cv_os_cray=yes 1.389 ++else 1.390 ++ ac_cv_os_cray=no 1.391 ++fi 1.392 ++rm -f conftest* 1.393 ++ 1.394 ++fi 1.395 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5 1.396 ++$as_echo "$ac_cv_os_cray" >&6; } 1.397 ++if test $ac_cv_os_cray = yes; then 1.398 ++ for ac_func in _getb67 GETB67 getb67; do 1.399 ++ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` 1.400 ++ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" 1.401 ++eval as_val=\$$as_ac_var 1.402 ++ if test "x$as_val" = x""yes; then : 1.403 ++ 1.404 ++cat >>confdefs.h <<_ACEOF 1.405 ++#define CRAY_STACKSEG_END $ac_func 1.406 ++_ACEOF 1.407 ++ 1.408 ++ break 1.409 ++fi 1.410 ++ 1.411 ++ done 1.412 ++fi 1.413 ++ 1.414 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5 1.415 ++$as_echo_n "checking stack direction for C alloca... " >&6; } 1.416 ++if test "${ac_cv_c_stack_direction+set}" = set; then : 1.417 ++ $as_echo_n "(cached) " >&6 1.418 ++else 1.419 ++ if test "$cross_compiling" = yes; then : 1.420 ++ ac_cv_c_stack_direction=0 1.421 ++else 1.422 ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext 1.423 ++/* end confdefs.h. */ 1.424 ++$ac_includes_default 1.425 ++int 1.426 ++find_stack_direction () 1.427 ++{ 1.428 ++ static char *addr = 0; 1.429 ++ auto char dummy; 1.430 ++ if (addr == 0) 1.431 ++ { 1.432 ++ addr = &dummy; 1.433 ++ return find_stack_direction (); 1.434 ++ } 1.435 ++ else 1.436 ++ return (&dummy > addr) ? 1 : -1; 1.437 ++} 1.438 ++ 1.439 ++int 1.440 ++main () 1.441 ++{ 1.442 ++ return find_stack_direction () < 0; 1.443 ++} 1.444 ++_ACEOF 1.445 ++if ac_fn_c_try_run "$LINENO"; then : 1.446 ++ ac_cv_c_stack_direction=1 1.447 ++else 1.448 ++ ac_cv_c_stack_direction=-1 1.449 ++fi 1.450 ++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ 1.451 ++ conftest.$ac_objext conftest.beam conftest.$ac_ext 1.452 ++fi 1.453 ++ 1.454 ++fi 1.455 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5 1.456 ++$as_echo "$ac_cv_c_stack_direction" >&6; } 1.457 ++cat >>confdefs.h <<_ACEOF 1.458 ++#define STACK_DIRECTION $ac_cv_c_stack_direction 1.459 ++_ACEOF 1.460 ++ 1.461 ++ 1.462 ++fi 1.463 ++ 1.464 ++ 1.465 + 1.466 + for ac_header in stdint.h 1.467 + do : 1.468 +@@ -7564,13 +7756,13 @@ 1.469 + else 1.470 + lt_cv_nm_interface="BSD nm" 1.471 + echo "int some_variable = 0;" > conftest.$ac_ext 1.472 +- (eval echo "\"\$as_me:7567: $ac_compile\"" >&5) 1.473 ++ (eval echo "\"\$as_me:7759: $ac_compile\"" >&5) 1.474 + (eval "$ac_compile" 2>conftest.err) 1.475 + cat conftest.err >&5 1.476 +- (eval echo "\"\$as_me:7570: $NM \\\"conftest.$ac_objext\\\"\"" >&5) 1.477 ++ (eval echo "\"\$as_me:7762: $NM \\\"conftest.$ac_objext\\\"\"" >&5) 1.478 + (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) 1.479 + cat conftest.err >&5 1.480 +- (eval echo "\"\$as_me:7573: output\"" >&5) 1.481 ++ (eval echo "\"\$as_me:7765: output\"" >&5) 1.482 + cat conftest.out >&5 1.483 + if $GREP 'External.*some_variable' conftest.out > /dev/null; then 1.484 + lt_cv_nm_interface="MS dumpbin" 1.485 +@@ -8772,7 +8964,7 @@ 1.486 + ;; 1.487 + *-*-irix6*) 1.488 + # Find out which ABI we are using. 1.489 +- echo '#line 8775 "configure"' > conftest.$ac_ext 1.490 ++ echo '#line 8967 "configure"' > conftest.$ac_ext 1.491 + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 1.492 + (eval $ac_compile) 2>&5 1.493 + ac_status=$? 1.494 +@@ -10032,11 +10224,11 @@ 1.495 + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ 1.496 + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ 1.497 + -e 's:$: $lt_compiler_flag:'` 1.498 +- (eval echo "\"\$as_me:10035: $lt_compile\"" >&5) 1.499 ++ (eval echo "\"\$as_me:10227: $lt_compile\"" >&5) 1.500 + (eval "$lt_compile" 2>conftest.err) 1.501 + ac_status=$? 1.502 + cat conftest.err >&5 1.503 +- echo "$as_me:10039: \$? = $ac_status" >&5 1.504 ++ echo "$as_me:10231: \$? = $ac_status" >&5 1.505 + if (exit $ac_status) && test -s "$ac_outfile"; then 1.506 + # The compiler can only warn and ignore the option if not recognized 1.507 + # So say no if there are warnings other than the usual output. 1.508 +@@ -10371,11 +10563,11 @@ 1.509 + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ 1.510 + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ 1.511 + -e 's:$: $lt_compiler_flag:'` 1.512 +- (eval echo "\"\$as_me:10374: $lt_compile\"" >&5) 1.513 ++ (eval echo "\"\$as_me:10566: $lt_compile\"" >&5) 1.514 + (eval "$lt_compile" 2>conftest.err) 1.515 + ac_status=$? 1.516 + cat conftest.err >&5 1.517 +- echo "$as_me:10378: \$? = $ac_status" >&5 1.518 ++ echo "$as_me:10570: \$? = $ac_status" >&5 1.519 + if (exit $ac_status) && test -s "$ac_outfile"; then 1.520 + # The compiler can only warn and ignore the option if not recognized 1.521 + # So say no if there are warnings other than the usual output. 1.522 +@@ -10476,11 +10668,11 @@ 1.523 + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ 1.524 + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ 1.525 + -e 's:$: $lt_compiler_flag:'` 1.526 +- (eval echo "\"\$as_me:10479: $lt_compile\"" >&5) 1.527 ++ (eval echo "\"\$as_me:10671: $lt_compile\"" >&5) 1.528 + (eval "$lt_compile" 2>out/conftest.err) 1.529 + ac_status=$? 1.530 + cat out/conftest.err >&5 1.531 +- echo "$as_me:10483: \$? = $ac_status" >&5 1.532 ++ echo "$as_me:10675: \$? = $ac_status" >&5 1.533 + if (exit $ac_status) && test -s out/conftest2.$ac_objext 1.534 + then 1.535 + # The compiler can only warn and ignore the option if not recognized 1.536 +@@ -10531,11 +10723,11 @@ 1.537 + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ 1.538 + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ 1.539 + -e 's:$: $lt_compiler_flag:'` 1.540 +- (eval echo "\"\$as_me:10534: $lt_compile\"" >&5) 1.541 ++ (eval echo "\"\$as_me:10726: $lt_compile\"" >&5) 1.542 + (eval "$lt_compile" 2>out/conftest.err) 1.543 + ac_status=$? 1.544 + cat out/conftest.err >&5 1.545 +- echo "$as_me:10538: \$? = $ac_status" >&5 1.546 ++ echo "$as_me:10730: \$? = $ac_status" >&5 1.547 + if (exit $ac_status) && test -s out/conftest2.$ac_objext 1.548 + then 1.549 + # The compiler can only warn and ignore the option if not recognized 1.550 +@@ -12915,7 +13107,7 @@ 1.551 + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 1.552 + lt_status=$lt_dlunknown 1.553 + cat > conftest.$ac_ext <<_LT_EOF 1.554 +-#line 12918 "configure" 1.555 ++#line 13110 "configure" 1.556 + #include "confdefs.h" 1.557 + 1.558 + #if HAVE_DLFCN_H 1.559 +@@ -13011,7 +13203,7 @@ 1.560 + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 1.561 + lt_status=$lt_dlunknown 1.562 + cat > conftest.$ac_ext <<_LT_EOF 1.563 +-#line 13014 "configure" 1.564 ++#line 13206 "configure" 1.565 + #include "confdefs.h" 1.566 + 1.567 + #if HAVE_DLFCN_H 1.568 +diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h 1.569 +--- mpfr-3.0.0-a/mpfr.h 2010-06-23 11:03:20.000000000 +0000 1.570 ++++ mpfr-3.0.0-b/mpfr.h 2010-06-25 13:23:13.000000000 +0000 1.571 +@@ -27,7 +27,7 @@ 1.572 + #define MPFR_VERSION_MAJOR 3 1.573 + #define MPFR_VERSION_MINOR 0 1.574 + #define MPFR_VERSION_PATCHLEVEL 0 1.575 +-#define MPFR_VERSION_STRING "3.0.0-p1" 1.576 ++#define MPFR_VERSION_STRING "3.0.0-p2" 1.577 + 1.578 + /* Macros dealing with MPFR VERSION */ 1.579 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) 1.580 +diff -Naurd mpfr-3.0.0-a/tests/Makefile.in mpfr-3.0.0-b/tests/Makefile.in 1.581 +--- mpfr-3.0.0-a/tests/Makefile.in 2010-06-10 11:00:52.000000000 +0000 1.582 ++++ mpfr-3.0.0-b/tests/Makefile.in 2010-06-10 11:00:52.000000000 +0000 1.583 +@@ -960,6 +960,7 @@ 1.584 + red=; grn=; lgn=; blu=; std= 1.585 + DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 1.586 + ACLOCAL = @ACLOCAL@ 1.587 ++ALLOCA = @ALLOCA@ 1.588 + AMTAR = @AMTAR@ 1.589 + AR = @AR@ 1.590 + AS = @AS@ 1.591 +diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c 1.592 +--- mpfr-3.0.0-a/version.c 2010-06-23 11:03:20.000000000 +0000 1.593 ++++ mpfr-3.0.0-b/version.c 2010-06-25 13:23:13.000000000 +0000 1.594 +@@ -25,5 +25,5 @@ 1.595 + const char * 1.596 + mpfr_get_version (void) 1.597 + { 1.598 +- return "3.0.0-p1"; 1.599 ++ return "3.0.0-p2"; 1.600 + } 1.601 +diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES 1.602 +--- mpfr-3.0.0-a/PATCHES 2010-07-10 00:11:19.000000000 +0000 1.603 ++++ mpfr-3.0.0-b/PATCHES 2010-07-10 00:12:50.000000000 +0000 1.604 +@@ -0,0 +1 @@ 1.605 ++gamma_underflow 1.606 +diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION 1.607 +--- mpfr-3.0.0-a/VERSION 2010-06-25 13:23:13.000000000 +0000 1.608 ++++ mpfr-3.0.0-b/VERSION 2010-07-10 00:11:53.000000000 +0000 1.609 +@@ -1 +1 @@ 1.610 +-3.0.0-p2 1.611 ++3.0.0-p3 1.612 +diff -Naurd mpfr-3.0.0-a/gamma.c mpfr-3.0.0-b/gamma.c 1.613 +--- mpfr-3.0.0-a/gamma.c 2010-06-10 11:00:14.000000000 +0000 1.614 ++++ mpfr-3.0.0-b/gamma.c 2010-07-10 00:11:46.000000000 +0000 1.615 +@@ -274,7 +274,7 @@ 1.616 + /* we want an upper bound for x * [log(2-x)-1]. 1.617 + since x < 0, we need a lower bound on log(2-x) */ 1.618 + mpfr_ui_sub (xp, 2, x, MPFR_RNDD); 1.619 +- mpfr_log (xp, xp, MPFR_RNDD); 1.620 ++ mpfr_log2 (xp, xp, MPFR_RNDD); 1.621 + mpfr_sub_ui (xp, xp, 1, MPFR_RNDD); 1.622 + mpfr_mul (xp, xp, x, MPFR_RNDU); 1.623 + 1.624 +@@ -303,8 +303,8 @@ 1.625 + { 1.626 + mpfr_sub (tmp, tmp, tmp2, MPFR_RNDZ); /* low bnd on |sin(Pi*(2-x))| */ 1.627 + mpfr_ui_div (tmp, 12, tmp, MPFR_RNDU); /* upper bound */ 1.628 +- mpfr_log (tmp, tmp, MPFR_RNDU); 1.629 +- mpfr_add (tmp, tmp, xp, MPFR_RNDU); 1.630 ++ mpfr_log2 (tmp, tmp, MPFR_RNDU); 1.631 ++ mpfr_add (xp, tmp, xp, MPFR_RNDU); 1.632 + underflow = mpfr_cmp_si (xp, expo.saved_emin - 2) <= 0; 1.633 + } 1.634 + 1.635 +diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h 1.636 +--- mpfr-3.0.0-a/mpfr.h 2010-06-25 13:23:13.000000000 +0000 1.637 ++++ mpfr-3.0.0-b/mpfr.h 2010-07-10 00:11:53.000000000 +0000 1.638 +@@ -27,7 +27,7 @@ 1.639 + #define MPFR_VERSION_MAJOR 3 1.640 + #define MPFR_VERSION_MINOR 0 1.641 + #define MPFR_VERSION_PATCHLEVEL 0 1.642 +-#define MPFR_VERSION_STRING "3.0.0-p2" 1.643 ++#define MPFR_VERSION_STRING "3.0.0-p3" 1.644 + 1.645 + /* Macros dealing with MPFR VERSION */ 1.646 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) 1.647 +diff -Naurd mpfr-3.0.0-a/tests/tgamma.c mpfr-3.0.0-b/tests/tgamma.c 1.648 +--- mpfr-3.0.0-a/tests/tgamma.c 2010-06-10 11:00:13.000000000 +0000 1.649 ++++ mpfr-3.0.0-b/tests/tgamma.c 2010-07-10 00:11:46.000000000 +0000 1.650 +@@ -461,6 +461,20 @@ 1.651 + mpfr_clear (x); 1.652 + } 1.653 + 1.654 ++/* bug found by Stathis, only occurs on 32-bit machines */ 1.655 ++static void 1.656 ++test20100709 (void) 1.657 ++{ 1.658 ++ mpfr_t x; 1.659 ++ int inex; 1.660 ++ 1.661 ++ mpfr_init2 (x, 100); 1.662 ++ mpfr_set_str (x, "-4.6308260837372266e+07", 10, MPFR_RNDN); 1.663 ++ inex = mpfr_gamma (x, x, MPFR_RNDN); 1.664 ++ MPFR_ASSERTN(MPFR_IS_ZERO(x) && MPFR_IS_NEG(x) && inex > 0); 1.665 ++ mpfr_clear (x); 1.666 ++} 1.667 ++ 1.668 + int 1.669 + main (int argc, char *argv[]) 1.670 + { 1.671 +@@ -471,6 +485,7 @@ 1.672 + test_generic (2, 100, 2); 1.673 + gamma_integer (); 1.674 + test20071231 (); 1.675 ++ test20100709 (); 1.676 + 1.677 + data_check ("data/gamma", mpfr_gamma, "mpfr_gamma"); 1.678 + 1.679 +diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c 1.680 +--- mpfr-3.0.0-a/version.c 2010-06-25 13:23:13.000000000 +0000 1.681 ++++ mpfr-3.0.0-b/version.c 2010-07-10 00:11:53.000000000 +0000 1.682 +@@ -25,5 +25,5 @@ 1.683 + const char * 1.684 + mpfr_get_version (void) 1.685 + { 1.686 +- return "3.0.0-p2"; 1.687 ++ return "3.0.0-p3"; 1.688 + } 1.689 +diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES 1.690 +--- mpfr-3.0.0-a/PATCHES 2010-09-07 08:44:01.000000000 +0000 1.691 ++++ mpfr-3.0.0-b/PATCHES 2010-09-07 08:48:46.000000000 +0000 1.692 +@@ -0,0 +1 @@ 1.693 ++mpfr_cmp/set_ui/si 1.694 +diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION 1.695 +--- mpfr-3.0.0-a/VERSION 2010-07-10 00:11:53.000000000 +0000 1.696 ++++ mpfr-3.0.0-b/VERSION 2010-09-07 08:46:06.000000000 +0000 1.697 +@@ -1 +1 @@ 1.698 +-3.0.0-p3 1.699 ++3.0.0-p4 1.700 +diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h 1.701 +--- mpfr-3.0.0-a/mpfr.h 2010-07-10 00:11:53.000000000 +0000 1.702 ++++ mpfr-3.0.0-b/mpfr.h 2010-09-07 08:46:06.000000000 +0000 1.703 +@@ -27,7 +27,7 @@ 1.704 + #define MPFR_VERSION_MAJOR 3 1.705 + #define MPFR_VERSION_MINOR 0 1.706 + #define MPFR_VERSION_PATCHLEVEL 0 1.707 +-#define MPFR_VERSION_STRING "3.0.0-p3" 1.708 ++#define MPFR_VERSION_STRING "3.0.0-p4" 1.709 + 1.710 + /* Macros dealing with MPFR VERSION */ 1.711 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) 1.712 +@@ -798,35 +798,45 @@ 1.713 + anyway. Checking with other ICC versions is needed. Possibly detect 1.714 + whether warnings are produced or not with a configure test. 1.715 + + Remove C++ too, since it complains too much. */ 1.716 ++/* Added casts to improve robustness in case of undefined behavior and 1.717 ++ compiler extensions based on UB (in particular -fwrapv). MPFR doesn't 1.718 ++ use such extensions, but these macros will be used by 3rd-party code, 1.719 ++ where such extensions may be required. 1.720 ++ Moreover casts to unsigned long have been added to avoid warnings in 1.721 ++ programs that use MPFR and are compiled with -Wconversion; such casts 1.722 ++ are OK since if X is a constant expression, then (unsigned long) X is 1.723 ++ also a constant expression, so that the optimizations still work. */ 1.724 + #if defined (__GNUC__) && !defined(__ICC) && !defined(__cplusplus) 1.725 + #if (__GNUC__ >= 2) 1.726 + #undef mpfr_cmp_ui 1.727 +-/* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0. */ 1.728 +-#define mpfr_cmp_ui(_f,_u) \ 1.729 +- (__builtin_constant_p (_u) && (_u) == 0 ? \ 1.730 +- mpfr_sgn (_f) : \ 1.731 +- mpfr_cmp_ui_2exp ((_f),(_u),0)) 1.732 ++/* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0. 1.733 ++ But warning! mpfr_sgn is specified as a macro in the API, thus the macro 1.734 ++ mustn't be used if side effects are possible, like here. */ 1.735 ++#define mpfr_cmp_ui(_f,_u) \ 1.736 ++ (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ? \ 1.737 ++ (mpfr_sgn) (_f) : \ 1.738 ++ mpfr_cmp_ui_2exp ((_f), (unsigned long) (_u), 0)) 1.739 + #undef mpfr_cmp_si 1.740 +-#define mpfr_cmp_si(_f,_s) \ 1.741 +- (__builtin_constant_p (_s) && (_s) >= 0 ? \ 1.742 +- mpfr_cmp_ui ((_f), (_s)) : \ 1.743 +- mpfr_cmp_si_2exp ((_f), (_s), 0)) 1.744 ++#define mpfr_cmp_si(_f,_s) \ 1.745 ++ (__builtin_constant_p (_s) && (long) (_s) >= 0 ? \ 1.746 ++ mpfr_cmp_ui ((_f), (unsigned long) (long) (_s)) : \ 1.747 ++ mpfr_cmp_si_2exp ((_f), (long) (_s), 0)) 1.748 + #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95 1.749 + #undef mpfr_set_ui 1.750 +-#define mpfr_set_ui(_f,_u,_r) \ 1.751 +- (__builtin_constant_p (_u) && (_u) == 0 ? \ 1.752 +- __extension__ ({ \ 1.753 +- mpfr_ptr _p = (_f); \ 1.754 +- _p->_mpfr_sign = 1; \ 1.755 +- _p->_mpfr_exp = __MPFR_EXP_ZERO; \ 1.756 +- (void) (_r); 0; }) : \ 1.757 +- mpfr_set_ui_2exp ((_f), (_u), 0, (_r))) 1.758 ++#define mpfr_set_ui(_f,_u,_r) \ 1.759 ++ (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ? \ 1.760 ++ __extension__ ({ \ 1.761 ++ mpfr_ptr _p = (_f); \ 1.762 ++ _p->_mpfr_sign = 1; \ 1.763 ++ _p->_mpfr_exp = __MPFR_EXP_ZERO; \ 1.764 ++ (void) (_r); 0; }) : \ 1.765 ++ mpfr_set_ui_2exp ((_f), (unsigned long) (_u), 0, (_r))) 1.766 + #endif 1.767 + #undef mpfr_set_si 1.768 +-#define mpfr_set_si(_f,_s,_r) \ 1.769 +- (__builtin_constant_p (_s) && (_s) >= 0 ? \ 1.770 +- mpfr_set_ui ((_f), (_s), (_r)) : \ 1.771 +- mpfr_set_si_2exp ((_f), (_s), 0, (_r))) 1.772 ++#define mpfr_set_si(_f,_s,_r) \ 1.773 ++ (__builtin_constant_p (_s) && (long) (_s) >= 0 ? \ 1.774 ++ mpfr_set_ui ((_f), (unsigned long) (long) (_s), (_r)) : \ 1.775 ++ mpfr_set_si_2exp ((_f), (long) (_s), 0, (_r))) 1.776 + #endif 1.777 + #endif 1.778 + 1.779 +diff -Naurd mpfr-3.0.0-a/tests/tcmp_ui.c mpfr-3.0.0-b/tests/tcmp_ui.c 1.780 +--- mpfr-3.0.0-a/tests/tcmp_ui.c 2010-06-10 11:00:13.000000000 +0000 1.781 ++++ mpfr-3.0.0-b/tests/tcmp_ui.c 2010-09-07 08:45:12.000000000 +0000 1.782 +@@ -88,6 +88,126 @@ 1.783 + mpfr_clear (x); 1.784 + } 1.785 + 1.786 ++/* Since mpfr_cmp_ui and mpfr_cmp_si are also implemented by a macro 1.787 ++ with __builtin_constant_p for GCC, check that side effects are 1.788 ++ handled correctly. */ 1.789 ++static void 1.790 ++check_macros (void) 1.791 ++{ 1.792 ++ mpfr_t x; 1.793 ++ int c; 1.794 ++ 1.795 ++ mpfr_init2 (x, 32); 1.796 ++ 1.797 ++ c = 0; 1.798 ++ mpfr_set_ui (x, 17, MPFR_RNDN); 1.799 ++ if (mpfr_cmp_ui (x, 17) != 0) 1.800 ++ { 1.801 ++ printf ("Error 1 on mpfr_cmp_ui(x,17) in check_macros\n"); 1.802 ++ exit (1); 1.803 ++ } 1.804 ++ if (mpfr_cmp_ui (x, (c++, 17)) != 0) 1.805 ++ { 1.806 ++ printf ("Error 2 on mpfr_cmp_ui(x,17) in check_macros\n"); 1.807 ++ exit (1); 1.808 ++ } 1.809 ++ if (c != 1) 1.810 ++ { 1.811 ++ printf ("Error 3 on mpfr_cmp_ui(x,17) in check_macros\n" 1.812 ++ "(c = %d instead of 1)\n", c); 1.813 ++ exit (1); 1.814 ++ } 1.815 ++ if (mpfr_cmp_si (x, 17) != 0) 1.816 ++ { 1.817 ++ printf ("Error 1 on mpfr_cmp_si(x,17) in check_macros\n"); 1.818 ++ exit (1); 1.819 ++ } 1.820 ++ if (mpfr_cmp_si (x, (c++, 17)) != 0) 1.821 ++ { 1.822 ++ printf ("Error 2 on mpfr_cmp_si(x,17) in check_macros\n"); 1.823 ++ exit (1); 1.824 ++ } 1.825 ++ if (c != 2) 1.826 ++ { 1.827 ++ printf ("Error 3 on mpfr_cmp_si(x,17) in check_macros\n" 1.828 ++ "(c = %d instead of 2)\n", c); 1.829 ++ exit (1); 1.830 ++ } 1.831 ++ 1.832 ++ c = 0; 1.833 ++ mpfr_set_ui (x, 0, MPFR_RNDN); 1.834 ++ if (mpfr_cmp_ui (x, 0) != 0) 1.835 ++ { 1.836 ++ printf ("Error 1 on mpfr_cmp_ui(x,0) in check_macros\n"); 1.837 ++ exit (1); 1.838 ++ } 1.839 ++ if (mpfr_cmp_ui (x, (c++, 0)) != 0) 1.840 ++ { 1.841 ++ printf ("Error 2 on mpfr_cmp_ui(x,0) in check_macros\n"); 1.842 ++ exit (1); 1.843 ++ } 1.844 ++ if (c != 1) 1.845 ++ { 1.846 ++ printf ("Error 3 on mpfr_cmp_ui(x,0) in check_macros\n" 1.847 ++ "(c = %d instead of 1)\n", c); 1.848 ++ exit (1); 1.849 ++ } 1.850 ++ if (mpfr_cmp_si (x, 0) != 0) 1.851 ++ { 1.852 ++ printf ("Error 1 on mpfr_cmp_si(x,0) in check_macros\n"); 1.853 ++ exit (1); 1.854 ++ } 1.855 ++ if (mpfr_cmp_si (x, (c++, 0)) != 0) 1.856 ++ { 1.857 ++ printf ("Error 2 on mpfr_cmp_si(x,0) in check_macros\n"); 1.858 ++ exit (1); 1.859 ++ } 1.860 ++ if (c != 2) 1.861 ++ { 1.862 ++ printf ("Error 3 on mpfr_cmp_si(x,0) in check_macros\n" 1.863 ++ "(c = %d instead of 2)\n", c); 1.864 ++ exit (1); 1.865 ++ } 1.866 ++ 1.867 ++ mpfr_clear (x); 1.868 ++} 1.869 ++ 1.870 ++/* Bug in r7114 */ 1.871 ++static void 1.872 ++test_macros (void) 1.873 ++{ 1.874 ++ mpfr_t x[3]; 1.875 ++ mpfr_ptr p; 1.876 ++ 1.877 ++ mpfr_inits (x[0], x[1], x[2], (mpfr_ptr) 0); 1.878 ++ mpfr_set_ui (x[0], 0, MPFR_RNDN); 1.879 ++ p = x[0]; 1.880 ++ if (mpfr_cmp_ui (p++, 0) != 0) 1.881 ++ { 1.882 ++ printf ("Error in mpfr_cmp_ui macro: result should be 0.\n"); 1.883 ++ exit (1); 1.884 ++ } 1.885 ++ if (p != x[1]) 1.886 ++ { 1.887 ++ printf ("Error in mpfr_cmp_ui macro: p - x[0] = %d (expecting 1)\n", 1.888 ++ (int) (p - x[0])); 1.889 ++ exit (1); 1.890 ++ } 1.891 ++ p = x[0]; 1.892 ++ if (mpfr_cmp_si (p++, 0) != 0) 1.893 ++ { 1.894 ++ printf ("Error in mpfr_cmp_si macro: result should be 0.\n"); 1.895 ++ exit (1); 1.896 ++ } 1.897 ++ if (p != x[1]) 1.898 ++ { 1.899 ++ printf ("Error in mpfr_cmp_si macro: p - x[0] = %d (expecting 1)\n", 1.900 ++ (int) (p - x[0])); 1.901 ++ exit (1); 1.902 ++ } 1.903 ++ mpfr_clears (x[0], x[1], x[2], (mpfr_ptr) 0); 1.904 ++} 1.905 ++ 1.906 + int 1.907 + main (void) 1.908 + { 1.909 +@@ -216,6 +336,8 @@ 1.910 + mpfr_clear (x); 1.911 + 1.912 + check_nan (); 1.913 ++ check_macros (); 1.914 ++ test_macros (); 1.915 + 1.916 + tests_end_mpfr (); 1.917 + return 0; 1.918 +diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c 1.919 +--- mpfr-3.0.0-a/version.c 2010-07-10 00:11:53.000000000 +0000 1.920 ++++ mpfr-3.0.0-b/version.c 2010-09-07 08:46:06.000000000 +0000 1.921 +@@ -25,5 +25,5 @@ 1.922 + const char * 1.923 + mpfr_get_version (void) 1.924 + { 1.925 +- return "3.0.0-p3"; 1.926 ++ return "3.0.0-p4"; 1.927 + } 1.928 +diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES 1.929 +--- mpfr-3.0.0-a/PATCHES 2010-10-21 20:28:38.000000000 +0000 1.930 ++++ mpfr-3.0.0-b/PATCHES 2010-10-21 20:28:38.000000000 +0000 1.931 +@@ -0,0 +1 @@ 1.932 ++tcan_round 1.933 +diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION 1.934 +--- mpfr-3.0.0-a/VERSION 2010-09-07 08:46:06.000000000 +0000 1.935 ++++ mpfr-3.0.0-b/VERSION 2010-10-21 20:28:38.000000000 +0000 1.936 +@@ -1 +1 @@ 1.937 +-3.0.0-p4 1.938 ++3.0.0-p5 1.939 +diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h 1.940 +--- mpfr-3.0.0-a/mpfr.h 2010-09-07 08:46:06.000000000 +0000 1.941 ++++ mpfr-3.0.0-b/mpfr.h 2010-10-21 20:28:38.000000000 +0000 1.942 +@@ -27,7 +27,7 @@ 1.943 + #define MPFR_VERSION_MAJOR 3 1.944 + #define MPFR_VERSION_MINOR 0 1.945 + #define MPFR_VERSION_PATCHLEVEL 0 1.946 +-#define MPFR_VERSION_STRING "3.0.0-p4" 1.947 ++#define MPFR_VERSION_STRING "3.0.0-p5" 1.948 + 1.949 + /* Macros dealing with MPFR VERSION */ 1.950 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) 1.951 +diff -Naurd mpfr-3.0.0-a/tests/tcan_round.c mpfr-3.0.0-b/tests/tcan_round.c 1.952 +--- mpfr-3.0.0-a/tests/tcan_round.c 2010-06-10 11:00:13.000000000 +0000 1.953 ++++ mpfr-3.0.0-b/tests/tcan_round.c 2010-10-21 20:28:38.000000000 +0000 1.954 +@@ -41,7 +41,7 @@ 1.955 + /* avoid mpn_random which leaks memory */ 1.956 + for (i = 0; i < n; i++) 1.957 + buf[i] = randlimb (); 1.958 +- p = (mpfr_prec_t) randlimb() % ((n-1) * GMP_NUMB_BITS) + MPFR_PREC_MIN; 1.959 ++ p = randlimb() % ((n-1) * GMP_NUMB_BITS) + MPFR_PREC_MIN; 1.960 + err = p + randlimb () % GMP_NUMB_BITS; 1.961 + r1 = mpfr_round_p (buf, n, err, p); 1.962 + r2 = mpfr_can_round_raw (buf, n, MPFR_SIGN_POS, err, 1.963 +diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c 1.964 +--- mpfr-3.0.0-a/version.c 2010-09-07 08:46:06.000000000 +0000 1.965 ++++ mpfr-3.0.0-b/version.c 2010-10-21 20:28:38.000000000 +0000 1.966 +@@ -25,5 +25,5 @@ 1.967 + const char * 1.968 + mpfr_get_version (void) 1.969 + { 1.970 +- return "3.0.0-p4"; 1.971 ++ return "3.0.0-p5"; 1.972 + } 1.973 +diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES 1.974 +--- mpfr-3.0.0-a/PATCHES 2010-10-21 20:59:32.000000000 +0000 1.975 ++++ mpfr-3.0.0-b/PATCHES 2010-10-21 20:59:32.000000000 +0000 1.976 +@@ -0,0 +1 @@ 1.977 ++mpfr_sub1 1.978 +diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION 1.979 +--- mpfr-3.0.0-a/VERSION 2010-10-21 20:28:38.000000000 +0000 1.980 ++++ mpfr-3.0.0-b/VERSION 2010-10-21 20:59:32.000000000 +0000 1.981 +@@ -1 +1 @@ 1.982 +-3.0.0-p5 1.983 ++3.0.0-p6 1.984 +diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h 1.985 +--- mpfr-3.0.0-a/mpfr.h 2010-10-21 20:28:38.000000000 +0000 1.986 ++++ mpfr-3.0.0-b/mpfr.h 2010-10-21 20:59:32.000000000 +0000 1.987 +@@ -27,7 +27,7 @@ 1.988 + #define MPFR_VERSION_MAJOR 3 1.989 + #define MPFR_VERSION_MINOR 0 1.990 + #define MPFR_VERSION_PATCHLEVEL 0 1.991 +-#define MPFR_VERSION_STRING "3.0.0-p5" 1.992 ++#define MPFR_VERSION_STRING "3.0.0-p6" 1.993 + 1.994 + /* Macros dealing with MPFR VERSION */ 1.995 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) 1.996 +diff -Naurd mpfr-3.0.0-a/sub1.c mpfr-3.0.0-b/sub1.c 1.997 +--- mpfr-3.0.0-a/sub1.c 2010-06-10 11:00:14.000000000 +0000 1.998 ++++ mpfr-3.0.0-b/sub1.c 2010-10-21 20:59:32.000000000 +0000 1.999 +@@ -37,7 +37,9 @@ 1.1000 + mp_size_t cancel2, an, bn, cn, cn0; 1.1001 + mp_limb_t *ap, *bp, *cp; 1.1002 + mp_limb_t carry, bb, cc, borrow = 0; 1.1003 +- int inexact, shift_b, shift_c, is_exact = 1, down = 0, add_exp = 0; 1.1004 ++ int inexact, shift_b, shift_c, add_exp = 0; 1.1005 ++ int cmp_low = 0; /* used for rounding to nearest: 0 if low(b) = low(c), 1.1006 ++ negative if low(b) < low(c), positive if low(b)>low(c) */ 1.1007 + int sh, k; 1.1008 + MPFR_TMP_DECL(marker); 1.1009 + 1.1010 +@@ -196,7 +198,8 @@ 1.1011 + } 1.1012 + 1.1013 + #ifdef DEBUG 1.1014 +- printf ("shift_b=%d shift_c=%d diffexp=%lu\n", shift_b, shift_c, 1.1015 ++ printf ("rnd=%s shift_b=%d shift_c=%d diffexp=%lu\n", 1.1016 ++ mpfr_print_rnd_mode (rnd_mode), shift_b, shift_c, 1.1017 + (unsigned long) diff_exp); 1.1018 + #endif 1.1019 + 1.1020 +@@ -307,17 +310,18 @@ 1.1021 + { 1.1022 + if (MPFR_LIKELY(sh)) 1.1023 + { 1.1024 +- is_exact = (carry == 0); 1.1025 + /* can decide except when carry = 2^(sh-1) [middle] 1.1026 + or carry = 0 [truncate, but cannot decide inexact flag] */ 1.1027 +- down = (carry < (MPFR_LIMB_ONE << (sh - 1))); 1.1028 + if (carry > (MPFR_LIMB_ONE << (sh - 1))) 1.1029 + goto add_one_ulp; 1.1030 +- else if ((0 < carry) && down) 1.1031 ++ else if ((0 < carry) && (carry < (MPFR_LIMB_ONE << (sh - 1)))) 1.1032 + { 1.1033 + inexact = -1; /* result if smaller than exact value */ 1.1034 + goto truncate; 1.1035 + } 1.1036 ++ /* now carry = 2^(sh-1), in which case cmp_low=2, 1.1037 ++ or carry = 0, in which case cmp_low=0 */ 1.1038 ++ cmp_low = (carry == 0) ? 0 : 2; 1.1039 + } 1.1040 + } 1.1041 + else /* directed rounding: set rnd_mode to RNDZ iff toward zero */ 1.1042 +@@ -344,12 +348,32 @@ 1.1043 + cn -= (long int) an + cancel2; 1.1044 + 1.1045 + #ifdef DEBUG 1.1046 +- printf ("last %d bits from a are %lu, bn=%ld, cn=%ld\n", 1.1047 ++ printf ("last sh=%d bits from a are %lu, bn=%ld, cn=%ld\n", 1.1048 + sh, (unsigned long) carry, (long) bn, (long) cn); 1.1049 + #endif 1.1050 + 1.1051 ++ /* for rounding to nearest, we couldn't conclude up to here in the following 1.1052 ++ cases: 1.1053 ++ 1. sh = 0, then cmp_low=0: we can either truncate, subtract one ulp 1.1054 ++ or add one ulp: -1 ulp < low(b)-low(c) < 1 ulp 1.1055 ++ 2. sh > 0 but the low sh bits from high(b)-high(c) equal 2^(sh-1): 1.1056 ++ -0.5 ulp <= -1/2^sh < low(b)-low(c)-0.5 < 1/2^sh <= 0.5 ulp 1.1057 ++ we can't decide the rounding, in that case cmp_low=2: 1.1058 ++ either we truncate and flag=-1, or we add one ulp and flag=1 1.1059 ++ 3. the low sh>0 bits from high(b)-high(c) equal 0: we know we have to 1.1060 ++ truncate but we can't decide the ternary value, here cmp_low=0: 1.1061 ++ -0.5 ulp <= -1/2^sh < low(b)-low(c) < 1/2^sh <= 0.5 ulp 1.1062 ++ we always truncate and inexact can be any of -1,0,1 1.1063 ++ */ 1.1064 ++ 1.1065 ++ /* note: here cn might exceed cn0, in which case we consider a zero limb */ 1.1066 + for (k = 0; (bn > 0) || (cn > 0); k = 1) 1.1067 + { 1.1068 ++ /* if cmp_low < 0, we know low(b) - low(c) < 0 1.1069 ++ if cmp_low > 0, we know low(b) - low(c) > 0 1.1070 ++ (more precisely if cmp_low = 2, low(b) - low(c) = 0.5 ulp so far) 1.1071 ++ if cmp_low = 0, so far low(b) - low(c) = 0 */ 1.1072 ++ 1.1073 + /* get next limbs */ 1.1074 + bb = (bn > 0) ? bp[--bn] : 0; 1.1075 + if ((cn > 0) && (cn-- <= cn0)) 1.1076 +@@ -357,76 +381,115 @@ 1.1077 + else 1.1078 + cc = 0; 1.1079 + 1.1080 +- /* down is set when low(b) < low(c) */ 1.1081 +- if (down == 0) 1.1082 +- down = (bb < cc); 1.1083 ++ /* cmp_low compares low(b) and low(c) */ 1.1084 ++ if (cmp_low == 0) /* case 1 or 3 */ 1.1085 ++ cmp_low = (bb < cc) ? -2+k : (bb > cc) ? 1 : 0; 1.1086 ++ 1.1087 ++ /* Case 1 for k=0 splits into 7 subcases: 1.1088 ++ 1a: bb > cc + half 1.1089 ++ 1b: bb = cc + half 1.1090 ++ 1c: 0 < bb - cc < half 1.1091 ++ 1d: bb = cc 1.1092 ++ 1e: -half < bb - cc < 0 1.1093 ++ 1f: bb - cc = -half 1.1094 ++ 1g: bb - cc < -half 1.1095 ++ 1.1096 ++ Case 2 splits into 3 subcases: 1.1097 ++ 2a: bb > cc 1.1098 ++ 2b: bb = cc 1.1099 ++ 2c: bb < cc 1.1100 ++ 1.1101 ++ Case 3 splits into 3 subcases: 1.1102 ++ 3a: bb > cc 1.1103 ++ 3b: bb = cc 1.1104 ++ 3c: bb < cc 1.1105 ++ */ 1.1106 + 1.1107 + /* the case rounding to nearest with sh=0 is special since one couldn't 1.1108 + subtract above 1/2 ulp in the trailing limb of the result */ 1.1109 +- if ((rnd_mode == MPFR_RNDN) && sh == 0 && k == 0) 1.1110 ++ if (rnd_mode == MPFR_RNDN && sh == 0 && k == 0) /* case 1 for k=0 */ 1.1111 + { 1.1112 + mp_limb_t half = MPFR_LIMB_HIGHBIT; 1.1113 + 1.1114 +- is_exact = (bb == cc); 1.1115 +- 1.1116 + /* add one ulp if bb > cc + half 1.1117 + truncate if cc - half < bb < cc + half 1.1118 + sub one ulp if bb < cc - half 1.1119 + */ 1.1120 + 1.1121 +- if (down) 1.1122 ++ if (cmp_low < 0) /* bb < cc: -1 ulp < low(b) - low(c) < 0, 1.1123 ++ cases 1e, 1f and 1g */ 1.1124 + { 1.1125 + if (cc >= half) 1.1126 + cc -= half; 1.1127 +- else 1.1128 ++ else /* since bb < cc < half, bb+half < 2*half */ 1.1129 + bb += half; 1.1130 ++ /* now we have bb < cc + half: 1.1131 ++ we have to subtract one ulp if bb < cc, 1.1132 ++ and truncate if bb > cc */ 1.1133 + } 1.1134 +- else /* bb >= cc */ 1.1135 ++ else if (cmp_low >= 0) /* bb >= cc, cases 1a to 1d */ 1.1136 + { 1.1137 + if (cc < half) 1.1138 + cc += half; 1.1139 +- else 1.1140 ++ else /* since bb >= cc >= half, bb - half >= 0 */ 1.1141 + bb -= half; 1.1142 ++ /* now we have bb > cc - half: we have to add one ulp if bb > cc, 1.1143 ++ and truncate if bb < cc */ 1.1144 ++ if (cmp_low > 0) 1.1145 ++ cmp_low = 2; 1.1146 + } 1.1147 + } 1.1148 + 1.1149 + #ifdef DEBUG 1.1150 +- printf (" bb=%lu cc=%lu down=%d is_exact=%d\n", 1.1151 +- (unsigned long) bb, (unsigned long) cc, down, is_exact); 1.1152 ++ printf ("k=%u bb=%lu cc=%lu cmp_low=%d\n", k, 1.1153 ++ (unsigned long) bb, (unsigned long) cc, cmp_low); 1.1154 + #endif 1.1155 +- if (bb < cc) 1.1156 ++ if (cmp_low < 0) /* low(b) - low(c) < 0: either truncate or subtract 1.1157 ++ one ulp */ 1.1158 + { 1.1159 + if (rnd_mode == MPFR_RNDZ) 1.1160 +- goto sub_one_ulp; 1.1161 ++ goto sub_one_ulp; /* set inexact=-1 */ 1.1162 + else if (rnd_mode != MPFR_RNDN) /* round away */ 1.1163 + { 1.1164 + inexact = 1; 1.1165 + goto truncate; 1.1166 + } 1.1167 +- else /* round to nearest: special case here since for sh=k=0 1.1168 +- bb = bb0 - MPFR_LIMB_HIGHBIT */ 1.1169 ++ else /* round to nearest */ 1.1170 + { 1.1171 +- if (is_exact && sh == 0) 1.1172 +- { 1.1173 +- /* For k=0 we can't decide exactness since it may depend 1.1174 +- from low order bits. 1.1175 +- For k=1, the first low limbs matched: low(b)-low(c)<0. */ 1.1176 +- if (k) 1.1177 +- { 1.1178 +- inexact = 1; 1.1179 +- goto truncate; 1.1180 +- } 1.1181 +- } 1.1182 +- else if (down && sh == 0) 1.1183 +- goto sub_one_ulp; 1.1184 +- else 1.1185 +- { 1.1186 +- inexact = (is_exact) ? 1 : -1; 1.1187 ++ /* If cmp_low < 0 and bb > cc, then -0.5 ulp < low(b)-low(c) < 0, 1.1188 ++ whatever the value of sh. 1.1189 ++ If sh>0, then cmp_low < 0 implies that the initial neglected 1.1190 ++ sh bits were 0 (otherwise cmp_low=2 initially), thus the 1.1191 ++ weight of the new bits is less than 0.5 ulp too. 1.1192 ++ If k > 0 (and sh=0) this means that either the first neglected 1.1193 ++ limbs bb and cc were equal (thus cmp_low was 0 for k=0), 1.1194 ++ or we had bb - cc = -0.5 ulp or 0.5 ulp. 1.1195 ++ The last case is not possible here since we would have 1.1196 ++ cmp_low > 0 which is sticky. 1.1197 ++ In the first case (where we have cmp_low = -1), we truncate, 1.1198 ++ whereas in the 2nd case we have cmp_low = -2 and we subtract 1.1199 ++ one ulp. 1.1200 ++ */ 1.1201 ++ if (bb > cc || sh > 0 || cmp_low == -1) 1.1202 ++ { /* -0.5 ulp < low(b)-low(c) < 0, 1.1203 ++ bb > cc corresponds to cases 1e and 1f1 1.1204 ++ sh > 0 corresponds to cases 3c and 3b3 1.1205 ++ cmp_low = -1 corresponds to case 1d3 (also 3b3) */ 1.1206 ++ inexact = 1; 1.1207 + goto truncate; 1.1208 + } 1.1209 ++ else if (bb < cc) /* here sh = 0 and low(b)-low(c) < -0.5 ulp, 1.1210 ++ this corresponds to cases 1g and 1f3 */ 1.1211 ++ goto sub_one_ulp; 1.1212 ++ /* the only case where we can't conclude is sh=0 and bb=cc, 1.1213 ++ i.e., we have low(b) - low(c) = -0.5 ulp (up to now), thus 1.1214 ++ we don't know if we must truncate or subtract one ulp. 1.1215 ++ Note: for sh=0 we can't have low(b) - low(c) = -0.5 ulp up to 1.1216 ++ now, since low(b) - low(c) > 1/2^sh */ 1.1217 + } 1.1218 + } 1.1219 +- else if (bb > cc) 1.1220 ++ else if (cmp_low > 0) /* 0 < low(b) - low(c): either truncate or 1.1221 ++ add one ulp */ 1.1222 + { 1.1223 + if (rnd_mode == MPFR_RNDZ) 1.1224 + { 1.1225 +@@ -437,34 +500,70 @@ 1.1226 + goto add_one_ulp; 1.1227 + else /* round to nearest */ 1.1228 + { 1.1229 +- if (is_exact) 1.1230 ++ if (bb > cc) 1.1231 + { 1.1232 +- inexact = -1; 1.1233 +- goto truncate; 1.1234 ++ /* if sh=0, then bb>cc means that low(b)-low(c) > 0.5 ulp, 1.1235 ++ and similarly when cmp_low=2 */ 1.1236 ++ if (cmp_low == 2) /* cases 1a, 1b1, 2a and 2b1 */ 1.1237 ++ goto add_one_ulp; 1.1238 ++ /* sh > 0 and cmp_low > 0: this implies that the sh initial 1.1239 ++ neglected bits were 0, and the remaining low(b)-low(c)>0, 1.1240 ++ but its weight is less than 0.5 ulp */ 1.1241 ++ else /* 0 < low(b) - low(c) < 0.5 ulp, this corresponds to 1.1242 ++ cases 3a, 1d1 and 3b1 */ 1.1243 ++ { 1.1244 ++ inexact = -1; 1.1245 ++ goto truncate; 1.1246 ++ } 1.1247 + } 1.1248 +- else if (down) 1.1249 ++ else if (bb < cc) /* 0 < low(b) - low(c) < 0.5 ulp, cases 1c, 1.1250 ++ 1b3, 2b3 and 2c */ 1.1251 + { 1.1252 +- inexact = 1; 1.1253 ++ inexact = -1; 1.1254 + goto truncate; 1.1255 + } 1.1256 +- else 1.1257 +- goto add_one_ulp; 1.1258 ++ /* the only case where we can't conclude is bb=cc, i.e., 1.1259 ++ low(b) - low(c) = 0.5 ulp (up to now), thus we don't know 1.1260 ++ if we must truncate or add one ulp. */ 1.1261 + } 1.1262 + } 1.1263 ++ /* after k=0, we cannot conclude in the following cases, we split them 1.1264 ++ according to the values of bb and cc for k=1: 1.1265 ++ 1b. sh=0 and cmp_low = 1 and bb-cc = half [around 0.5 ulp] 1.1266 ++ 1b1. bb > cc: add one ulp, inex = 1 1.1267 ++ 1b2: bb = cc: cannot conclude 1.1268 ++ 1b3: bb < cc: truncate, inex = -1 1.1269 ++ 1d. sh=0 and cmp_low = 0 and bb-cc = 0 [around 0] 1.1270 ++ 1d1: bb > cc: truncate, inex = -1 1.1271 ++ 1d2: bb = cc: cannot conclude 1.1272 ++ 1d3: bb < cc: truncate, inex = +1 1.1273 ++ 1f. sh=0 and cmp_low = -1 and bb-cc = -half [around -0.5 ulp] 1.1274 ++ 1f1: bb > cc: truncate, inex = +1 1.1275 ++ 1f2: bb = cc: cannot conclude 1.1276 ++ 1f3: bb < cc: sub one ulp, inex = -1 1.1277 ++ 2b. sh > 0 and cmp_low = 2 and bb=cc [around 0.5 ulp] 1.1278 ++ 2b1. bb > cc: add one ulp, inex = 1 1.1279 ++ 2b2: bb = cc: cannot conclude 1.1280 ++ 2b3: bb < cc: truncate, inex = -1 1.1281 ++ 3b. sh > 0 and cmp_low = 0 [around 0] 1.1282 ++ 3b1. bb > cc: truncate, inex = -1 1.1283 ++ 3b2: bb = cc: cannot conclude 1.1284 ++ 3b3: bb < cc: truncate, inex = +1 1.1285 ++ */ 1.1286 + } 1.1287 + 1.1288 +- if ((rnd_mode == MPFR_RNDN) && !is_exact) 1.1289 ++ if ((rnd_mode == MPFR_RNDN) && cmp_low != 0) 1.1290 + { 1.1291 + /* even rounding rule */ 1.1292 + if ((ap[0] >> sh) & 1) 1.1293 + { 1.1294 +- if (down) 1.1295 ++ if (cmp_low < 0) 1.1296 + goto sub_one_ulp; 1.1297 + else 1.1298 + goto add_one_ulp; 1.1299 + } 1.1300 + else 1.1301 +- inexact = (down) ? 1 : -1; 1.1302 ++ inexact = (cmp_low > 0) ? -1 : 1; 1.1303 + } 1.1304 + else 1.1305 + inexact = 0; 1.1306 +diff -Naurd mpfr-3.0.0-a/tests/tfma.c mpfr-3.0.0-b/tests/tfma.c 1.1307 +--- mpfr-3.0.0-a/tests/tfma.c 2010-06-10 11:00:13.000000000 +0000 1.1308 ++++ mpfr-3.0.0-b/tests/tfma.c 2010-10-21 20:59:32.000000000 +0000 1.1309 +@@ -337,6 +337,94 @@ 1.1310 + mpfr_clears (x, y, z, r, (mpfr_ptr) 0); 1.1311 + } 1.1312 + 1.1313 ++static void 1.1314 ++bug20101018 (void) 1.1315 ++{ 1.1316 ++ mpfr_t x, y, z, t, u; 1.1317 ++ int i; 1.1318 ++ 1.1319 ++ mpfr_init2 (x, 64); 1.1320 ++ mpfr_init2 (y, 64); 1.1321 ++ mpfr_init2 (z, 64); 1.1322 ++ mpfr_init2 (t, 64); 1.1323 ++ mpfr_init2 (u, 64); 1.1324 ++ 1.1325 ++ mpfr_set_str (x, "0xf.fffffffffffffffp-14766", 16, MPFR_RNDN); 1.1326 ++ mpfr_set_str (y, "-0xf.fffffffffffffffp+317", 16, MPFR_RNDN); 1.1327 ++ mpfr_set_str (z, "0x8.3ffffffffffe3ffp-14443", 16, MPFR_RNDN); 1.1328 ++ mpfr_set_str (t, "0x8.7ffffffffffc7ffp-14444", 16, MPFR_RNDN); 1.1329 ++ i = mpfr_fma (u, x, y, z, MPFR_RNDN); 1.1330 ++ if (mpfr_cmp (u, t) != 0) 1.1331 ++ { 1.1332 ++ printf ("Wrong result in bug20101018 (a)\n"); 1.1333 ++ printf ("Expected "); 1.1334 ++ mpfr_out_str (stdout, 16, 0, t, MPFR_RNDN); 1.1335 ++ printf ("\nGot "); 1.1336 ++ mpfr_out_str (stdout, 16, 0, u, MPFR_RNDN); 1.1337 ++ printf ("\n"); 1.1338 ++ exit (1); 1.1339 ++ } 1.1340 ++ if (i <= 0) 1.1341 ++ { 1.1342 ++ printf ("Wrong ternary value in bug20101018 (a)\n"); 1.1343 ++ printf ("Expected > 0\n"); 1.1344 ++ printf ("Got %d\n", i); 1.1345 ++ exit (1); 1.1346 ++ } 1.1347 ++ 1.1348 ++ mpfr_set_str (x, "-0xf.fffffffffffffffp-11420", 16, MPFR_RNDN); 1.1349 ++ mpfr_set_str (y, "0xf.fffffffffffffffp+9863", 16, MPFR_RNDN); 1.1350 ++ mpfr_set_str (z, "0x8.fffff80ffffffffp-1551", 16, MPFR_RNDN); 1.1351 ++ mpfr_set_str (t, "0x9.fffff01ffffffffp-1552", 16, MPFR_RNDN); 1.1352 ++ i = mpfr_fma (u, x, y, z, MPFR_RNDN); 1.1353 ++ if (mpfr_cmp (u, t) != 0) 1.1354 ++ { 1.1355 ++ printf ("Wrong result in bug20101018 (b)\n"); 1.1356 ++ printf ("Expected "); 1.1357 ++ mpfr_out_str (stdout, 16, 0, t, MPFR_RNDN); 1.1358 ++ printf ("\nGot "); 1.1359 ++ mpfr_out_str (stdout, 16, 0, u, MPFR_RNDN); 1.1360 ++ printf ("\n"); 1.1361 ++ exit (1); 1.1362 ++ } 1.1363 ++ if (i <= 0) 1.1364 ++ { 1.1365 ++ printf ("Wrong ternary value in bug20101018 (b)\n"); 1.1366 ++ printf ("Expected > 0\n"); 1.1367 ++ printf ("Got %d\n", i); 1.1368 ++ exit (1); 1.1369 ++ } 1.1370 ++ 1.1371 ++ mpfr_set_str (x, "0xf.fffffffffffffffp-2125", 16, MPFR_RNDN); 1.1372 ++ mpfr_set_str (y, "-0xf.fffffffffffffffp-6000", 16, MPFR_RNDN); 1.1373 ++ mpfr_set_str (z, "0x8p-8119", 16, MPFR_RNDN); 1.1374 ++ mpfr_set_str (t, "0x8.000000000000001p-8120", 16, MPFR_RNDN); 1.1375 ++ i = mpfr_fma (u, x, y, z, MPFR_RNDN); 1.1376 ++ if (mpfr_cmp (u, t) != 0) 1.1377 ++ { 1.1378 ++ printf ("Wrong result in bug20101018 (c)\n"); 1.1379 ++ printf ("Expected "); 1.1380 ++ mpfr_out_str (stdout, 16, 0, t, MPFR_RNDN); 1.1381 ++ printf ("\nGot "); 1.1382 ++ mpfr_out_str (stdout, 16, 0, u, MPFR_RNDN); 1.1383 ++ printf ("\n"); 1.1384 ++ exit (1); 1.1385 ++ } 1.1386 ++ if (i <= 0) 1.1387 ++ { 1.1388 ++ printf ("Wrong ternary value in bug20101018 (c)\n"); 1.1389 ++ printf ("Expected > 0\n"); 1.1390 ++ printf ("Got %d\n", i); 1.1391 ++ exit (1); 1.1392 ++ } 1.1393 ++ 1.1394 ++ mpfr_clear (x); 1.1395 ++ mpfr_clear (y); 1.1396 ++ mpfr_clear (z); 1.1397 ++ mpfr_clear (t); 1.1398 ++ mpfr_clear (u); 1.1399 ++} 1.1400 ++ 1.1401 + int 1.1402 + main (int argc, char *argv[]) 1.1403 + { 1.1404 +@@ -345,6 +433,8 @@ 1.1405 + 1.1406 + tests_start_mpfr (); 1.1407 + 1.1408 ++ bug20101018 (); 1.1409 ++ 1.1410 + mpfr_init (x); 1.1411 + mpfr_init (s); 1.1412 + mpfr_init (y); 1.1413 +diff -Naurd mpfr-3.0.0-a/tests/tsub.c mpfr-3.0.0-b/tests/tsub.c 1.1414 +--- mpfr-3.0.0-a/tests/tsub.c 2010-06-10 11:00:13.000000000 +0000 1.1415 ++++ mpfr-3.0.0-b/tests/tsub.c 2010-10-21 20:59:32.000000000 +0000 1.1416 +@@ -201,6 +201,8 @@ 1.1417 + if (mpfr_cmp (z, x)) 1.1418 + { 1.1419 + printf ("Error in mpfr_sub (2)\n"); 1.1420 ++ printf ("Expected "); mpfr_print_binary (x); puts (""); 1.1421 ++ printf ("Got "); mpfr_print_binary (z); puts (""); 1.1422 + exit (1); 1.1423 + } 1.1424 + mpfr_set_str_binary (x, "1.1110111011110001110111011111111111101000011001011100101100101101"); 1.1425 +@@ -478,6 +480,156 @@ 1.1426 + mpfr_clear (u); 1.1427 + } 1.1428 + 1.1429 ++/* Bug found by Jakub Jelinek 1.1430 ++ * http://bugzilla.redhat.com/643657 1.1431 ++ * https://gforge.inria.fr/tracker/index.php?func=detail&aid=11301 1.1432 ++ * The consequence can be either an assertion failure (i = 2 in the 1.1433 ++ * testcase below, in debug mode) or an incorrectly rounded value. 1.1434 ++ */ 1.1435 ++static void 1.1436 ++bug20101017 (void) 1.1437 ++{ 1.1438 ++ mpfr_t a, b, c; 1.1439 ++ int inex; 1.1440 ++ int i; 1.1441 ++ 1.1442 ++ mpfr_init2 (a, GMP_NUMB_BITS * 2); 1.1443 ++ mpfr_init2 (b, GMP_NUMB_BITS); 1.1444 ++ mpfr_init2 (c, GMP_NUMB_BITS); 1.1445 ++ 1.1446 ++ /* a = 2^(2N) + k.2^(2N-1) + 2^N and b = 1 1.1447 ++ with N = GMP_NUMB_BITS and k = 0 or 1. 1.1448 ++ c = a - b should round to the same value as a. */ 1.1449 ++ 1.1450 ++ for (i = 2; i <= 3; i++) 1.1451 ++ { 1.1452 ++ mpfr_set_ui_2exp (a, i, GMP_NUMB_BITS - 1, MPFR_RNDN); 1.1453 ++ mpfr_add_ui (a, a, 1, MPFR_RNDN); 1.1454 ++ mpfr_mul_2ui (a, a, GMP_NUMB_BITS, MPFR_RNDN); 1.1455 ++ mpfr_set_ui (b, 1, MPFR_RNDN); 1.1456 ++ inex = mpfr_sub (c, a, b, MPFR_RNDN); 1.1457 ++ mpfr_set (b, a, MPFR_RNDN); 1.1458 ++ if (! mpfr_equal_p (c, b)) 1.1459 ++ { 1.1460 ++ printf ("Error in bug20101017 for i = %d.\n", i); 1.1461 ++ printf ("Expected "); 1.1462 ++ mpfr_out_str (stdout, 16, 0, b, MPFR_RNDN); 1.1463 ++ putchar ('\n'); 1.1464 ++ printf ("Got "); 1.1465 ++ mpfr_out_str (stdout, 16, 0, c, MPFR_RNDN); 1.1466 ++ putchar ('\n'); 1.1467 ++ exit (1); 1.1468 ++ } 1.1469 ++ if (inex >= 0) 1.1470 ++ { 1.1471 ++ printf ("Error in bug20101017 for i = %d: bad inex value.\n", i); 1.1472 ++ printf ("Expected negative, got %d.\n", inex); 1.1473 ++ exit (1); 1.1474 ++ } 1.1475 ++ } 1.1476 ++ 1.1477 ++ mpfr_set_prec (a, 64); 1.1478 ++ mpfr_set_prec (b, 129); 1.1479 ++ mpfr_set_prec (c, 2); 1.1480 ++ mpfr_set_str_binary (b, "0.100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001E65"); 1.1481 ++ mpfr_set_str_binary (c, "0.10E1"); 1.1482 ++ inex = mpfr_sub (a, b, c, MPFR_RNDN); 1.1483 ++ if (mpfr_cmp_ui_2exp (a, 1, 64) != 0 || inex >= 0) 1.1484 ++ { 1.1485 ++ printf ("Error in mpfr_sub for b-c for b=2^64+1+2^(-64), c=1\n"); 1.1486 ++ printf ("Expected result 2^64 with inex < 0\n"); 1.1487 ++ printf ("Got "); mpfr_print_binary (a); 1.1488 ++ printf (" with inex=%d\n", inex); 1.1489 ++ exit (1); 1.1490 ++ } 1.1491 ++ 1.1492 ++ mpfr_clears (a, b, c, (mpfr_ptr) 0); 1.1493 ++} 1.1494 ++ 1.1495 ++/* hard test of rounding */ 1.1496 ++static void 1.1497 ++check_rounding (void) 1.1498 ++{ 1.1499 ++ mpfr_t a, b, c, res; 1.1500 ++ mpfr_prec_t p; 1.1501 ++ long k, l; 1.1502 ++ int i; 1.1503 ++ 1.1504 ++#define MAXKL (2 * GMP_NUMB_BITS) 1.1505 ++ for (p = MPFR_PREC_MIN; p <= GMP_NUMB_BITS; p++) 1.1506 ++ { 1.1507 ++ mpfr_init2 (a, p); 1.1508 ++ mpfr_init2 (res, p); 1.1509 ++ mpfr_init2 (b, p + 1 + MAXKL); 1.1510 ++ mpfr_init2 (c, MPFR_PREC_MIN); 1.1511 ++ 1.1512 ++ /* b = 2^p + 1 + 2^(-k), c = 2^(-l) */ 1.1513 ++ for (k = 0; k <= MAXKL; k++) 1.1514 ++ for (l = 0; l <= MAXKL; l++) 1.1515 ++ { 1.1516 ++ mpfr_set_ui_2exp (b, 1, p, MPFR_RNDN); 1.1517 ++ mpfr_add_ui (b, b, 1, MPFR_RNDN); 1.1518 ++ mpfr_mul_2ui (b, b, k, MPFR_RNDN); 1.1519 ++ mpfr_add_ui (b, b, 1, MPFR_RNDN); 1.1520 ++ mpfr_div_2ui (b, b, k, MPFR_RNDN); 1.1521 ++ mpfr_set_ui_2exp (c, 1, -l, MPFR_RNDN); 1.1522 ++ i = mpfr_sub (a, b, c, MPFR_RNDN); 1.1523 ++ /* b - c = 2^p + 1 + 2^(-k) - 2^(-l), should be rounded to 1.1524 ++ 2^p for l <= k, and 2^p+2 for l < k */ 1.1525 ++ if (l <= k) 1.1526 ++ { 1.1527 ++ if (mpfr_cmp_ui_2exp (a, 1, p) != 0) 1.1528 ++ { 1.1529 ++ printf ("Wrong result in check_rounding\n"); 1.1530 ++ printf ("p=%lu k=%ld l=%ld\n", p, k, l); 1.1531 ++ printf ("b="); mpfr_print_binary (b); puts (""); 1.1532 ++ printf ("c="); mpfr_print_binary (c); puts (""); 1.1533 ++ printf ("Expected 2^%lu\n", p); 1.1534 ++ printf ("Got "); mpfr_print_binary (a); puts (""); 1.1535 ++ exit (1); 1.1536 ++ } 1.1537 ++ if (i >= 0) 1.1538 ++ { 1.1539 ++ printf ("Wrong ternary value in check_rounding\n"); 1.1540 ++ printf ("p=%lu k=%ld l=%ld\n", p, k, l); 1.1541 ++ printf ("b="); mpfr_print_binary (b); puts (""); 1.1542 ++ printf ("c="); mpfr_print_binary (c); puts (""); 1.1543 ++ printf ("a="); mpfr_print_binary (a); puts (""); 1.1544 ++ printf ("Expected < 0, got %d\n", i); 1.1545 ++ exit (1); 1.1546 ++ } 1.1547 ++ } 1.1548 ++ else /* l < k */ 1.1549 ++ { 1.1550 ++ mpfr_set_ui_2exp (res, 1, p, MPFR_RNDN); 1.1551 ++ mpfr_add_ui (res, res, 2, MPFR_RNDN); 1.1552 ++ if (mpfr_cmp (a, res) != 0) 1.1553 ++ { 1.1554 ++ printf ("Wrong result in check_rounding\n"); 1.1555 ++ printf ("b="); mpfr_print_binary (b); puts (""); 1.1556 ++ printf ("c="); mpfr_print_binary (c); puts (""); 1.1557 ++ printf ("Expected "); mpfr_print_binary (res); puts (""); 1.1558 ++ printf ("Got "); mpfr_print_binary (a); puts (""); 1.1559 ++ exit (1); 1.1560 ++ } 1.1561 ++ if (i <= 0) 1.1562 ++ { 1.1563 ++ printf ("Wrong ternary value in check_rounding\n"); 1.1564 ++ printf ("b="); mpfr_print_binary (b); puts (""); 1.1565 ++ printf ("c="); mpfr_print_binary (c); puts (""); 1.1566 ++ printf ("Expected > 0, got %d\n", i); 1.1567 ++ exit (1); 1.1568 ++ } 1.1569 ++ } 1.1570 ++ } 1.1571 ++ 1.1572 ++ mpfr_clear (a); 1.1573 ++ mpfr_clear (res); 1.1574 ++ mpfr_clear (b); 1.1575 ++ mpfr_clear (c); 1.1576 ++ } 1.1577 ++} 1.1578 ++ 1.1579 + #define TEST_FUNCTION test_sub 1.1580 + #define TWO_ARGS 1.1581 + #define RAND_FUNCTION(x) mpfr_random2(x, MPFR_LIMB_SIZE (x), randlimb () % 100, RANDS) 1.1582 +@@ -491,6 +643,8 @@ 1.1583 + 1.1584 + tests_start_mpfr (); 1.1585 + 1.1586 ++ bug20101017 (); 1.1587 ++ check_rounding (); 1.1588 + check_diverse (); 1.1589 + check_inexact (); 1.1590 + bug_ddefour (); 1.1591 +diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c 1.1592 +--- mpfr-3.0.0-a/version.c 2010-10-21 20:28:38.000000000 +0000 1.1593 ++++ mpfr-3.0.0-b/version.c 2010-10-21 20:59:32.000000000 +0000 1.1594 +@@ -25,5 +25,5 @@ 1.1595 + const char * 1.1596 + mpfr_get_version (void) 1.1597 + { 1.1598 +- return "3.0.0-p5"; 1.1599 ++ return "3.0.0-p6"; 1.1600 + } 1.1601 +diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES 1.1602 +--- mpfr-3.0.0-a/PATCHES 2010-10-21 21:18:26.000000000 +0000 1.1603 ++++ mpfr-3.0.0-b/PATCHES 2010-10-21 21:18:26.000000000 +0000 1.1604 +@@ -0,0 +1 @@ 1.1605 ++mpfr_set_ld 1.1606 +diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION 1.1607 +--- mpfr-3.0.0-a/VERSION 2010-10-21 20:59:32.000000000 +0000 1.1608 ++++ mpfr-3.0.0-b/VERSION 2010-10-21 21:18:26.000000000 +0000 1.1609 +@@ -1 +1 @@ 1.1610 +-3.0.0-p6 1.1611 ++3.0.0-p7 1.1612 +diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h 1.1613 +--- mpfr-3.0.0-a/mpfr.h 2010-10-21 20:59:32.000000000 +0000 1.1614 ++++ mpfr-3.0.0-b/mpfr.h 2010-10-21 21:18:26.000000000 +0000 1.1615 +@@ -27,7 +27,7 @@ 1.1616 + #define MPFR_VERSION_MAJOR 3 1.1617 + #define MPFR_VERSION_MINOR 0 1.1618 + #define MPFR_VERSION_PATCHLEVEL 0 1.1619 +-#define MPFR_VERSION_STRING "3.0.0-p6" 1.1620 ++#define MPFR_VERSION_STRING "3.0.0-p7" 1.1621 + 1.1622 + /* Macros dealing with MPFR VERSION */ 1.1623 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) 1.1624 +diff -Naurd mpfr-3.0.0-a/set_ld.c mpfr-3.0.0-b/set_ld.c 1.1625 +--- mpfr-3.0.0-a/set_ld.c 2010-06-10 11:00:14.000000000 +0000 1.1626 ++++ mpfr-3.0.0-b/set_ld.c 2010-10-21 21:18:26.000000000 +0000 1.1627 +@@ -102,21 +102,25 @@ 1.1628 + { 1.1629 + x /= div13; /* exact */ 1.1630 + shift_exp += 8192; 1.1631 ++ mpfr_div_2si (t, t, 8192, MPFR_RNDZ); 1.1632 + } 1.1633 + if (ABS (x) >= div12) 1.1634 + { 1.1635 + x /= div12; /* exact */ 1.1636 + shift_exp += 4096; 1.1637 ++ mpfr_div_2si (t, t, 4096, MPFR_RNDZ); 1.1638 + } 1.1639 + if (ABS (x) >= div11) 1.1640 + { 1.1641 + x /= div11; /* exact */ 1.1642 + shift_exp += 2048; 1.1643 ++ mpfr_div_2si (t, t, 2048, MPFR_RNDZ); 1.1644 + } 1.1645 + if (ABS (x) >= div10) 1.1646 + { 1.1647 + x /= div10; /* exact */ 1.1648 + shift_exp += 1024; 1.1649 ++ mpfr_div_2si (t, t, 1024, MPFR_RNDZ); 1.1650 + } 1.1651 + /* warning: we may have DBL_MAX=2^1024*(1-2^(-53)) < x < 2^1024, 1.1652 + therefore we have one extra exponent reduction step */ 1.1653 +@@ -124,9 +128,10 @@ 1.1654 + { 1.1655 + x /= div9; /* exact */ 1.1656 + shift_exp += 512; 1.1657 ++ mpfr_div_2si (t, t, 512, MPFR_RNDZ); 1.1658 + } 1.1659 + } /* Check overflow of double */ 1.1660 +- else 1.1661 ++ else /* no overflow on double */ 1.1662 + { 1.1663 + long double div9, div10, div11; 1.1664 + 1.1665 +@@ -149,29 +154,34 @@ 1.1666 + { 1.1667 + x /= div13; /* exact */ 1.1668 + shift_exp -= 8192; 1.1669 ++ mpfr_mul_2si (t, t, 8192, MPFR_RNDZ); 1.1670 + } 1.1671 + if (ABS (x) <= div12) 1.1672 + { 1.1673 + x /= div12; /* exact */ 1.1674 + shift_exp -= 4096; 1.1675 ++ mpfr_mul_2si (t, t, 4096, MPFR_RNDZ); 1.1676 + } 1.1677 + if (ABS (x) <= div11) 1.1678 + { 1.1679 + x /= div11; /* exact */ 1.1680 + shift_exp -= 2048; 1.1681 ++ mpfr_mul_2si (t, t, 2048, MPFR_RNDZ); 1.1682 + } 1.1683 + if (ABS (x) <= div10) 1.1684 + { 1.1685 + x /= div10; /* exact */ 1.1686 + shift_exp -= 1024; 1.1687 ++ mpfr_mul_2si (t, t, 1024, MPFR_RNDZ); 1.1688 + } 1.1689 + if (ABS(x) <= div9) 1.1690 + { 1.1691 + x /= div9; /* exact */ 1.1692 + shift_exp -= 512; 1.1693 ++ mpfr_mul_2si (t, t, 512, MPFR_RNDZ); 1.1694 + } 1.1695 + } 1.1696 +- else 1.1697 ++ else /* no underflow */ 1.1698 + { 1.1699 + inexact = mpfr_set_d (u, (double) x, MPFR_RNDZ); 1.1700 + MPFR_ASSERTD (inexact == 0); 1.1701 +diff -Naurd mpfr-3.0.0-a/tests/tset_ld.c mpfr-3.0.0-b/tests/tset_ld.c 1.1702 +--- mpfr-3.0.0-a/tests/tset_ld.c 2010-06-10 11:00:13.000000000 +0000 1.1703 ++++ mpfr-3.0.0-b/tests/tset_ld.c 2010-10-21 21:18:26.000000000 +0000 1.1704 +@@ -147,12 +147,39 @@ 1.1705 + test_fixed_bugs (void) 1.1706 + { 1.1707 + mpfr_t x; 1.1708 +- long double d; 1.1709 ++ long double l, m; 1.1710 + 1.1711 + /* bug found by Steve Kargl (2009-03-14) */ 1.1712 + mpfr_init2 (x, 64); 1.1713 + mpfr_set_ui_2exp (x, 1, -16447, MPFR_RNDN); 1.1714 +- d = mpfr_get_ld (x, MPFR_RNDN); /* an assertion failed in init2.c:50 */ 1.1715 ++ mpfr_get_ld (x, MPFR_RNDN); /* an assertion failed in init2.c:50 */ 1.1716 ++ 1.1717 ++ /* bug reported by Jakub Jelinek (2010-10-17) 1.1718 ++ https://gforge.inria.fr/tracker/?func=detail&aid=11300 */ 1.1719 ++ mpfr_set_prec (x, MPFR_LDBL_MANT_DIG); 1.1720 ++ /* l = 0x1.23456789abcdef0123456789abcdp-914L; */ 1.1721 ++ l = 8.215640181713713164092636634579e-276; 1.1722 ++ mpfr_set_ld (x, l, MPFR_RNDN); 1.1723 ++ m = mpfr_get_ld (x, MPFR_RNDN); 1.1724 ++ if (m != l) 1.1725 ++ { 1.1726 ++ printf ("Error in get_ld o set_ld for l=%Le\n", l); 1.1727 ++ printf ("Got m=%Le instead of l\n", m); 1.1728 ++ exit (1); 1.1729 ++ } 1.1730 ++ 1.1731 ++ /* another similar test which failed with extended double precision and the 1.1732 ++ generic code for mpfr_set_ld */ 1.1733 ++ /* l = 0x1.23456789abcdef0123456789abcdp-968L; */ 1.1734 ++ l = 4.560596445887084662336528403703e-292; 1.1735 ++ mpfr_set_ld (x, l, MPFR_RNDN); 1.1736 ++ m = mpfr_get_ld (x, MPFR_RNDN); 1.1737 ++ if (m != l) 1.1738 ++ { 1.1739 ++ printf ("Error in get_ld o set_ld for l=%Le\n", l); 1.1740 ++ printf ("Got m=%Le instead of l\n", m); 1.1741 ++ exit (1); 1.1742 ++ } 1.1743 + 1.1744 + mpfr_clear (x); 1.1745 + } 1.1746 +diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c 1.1747 +--- mpfr-3.0.0-a/version.c 2010-10-21 20:59:32.000000000 +0000 1.1748 ++++ mpfr-3.0.0-b/version.c 2010-10-21 21:18:26.000000000 +0000 1.1749 +@@ -25,5 +25,5 @@ 1.1750 + const char * 1.1751 + mpfr_get_version (void) 1.1752 + { 1.1753 +- return "3.0.0-p6"; 1.1754 ++ return "3.0.0-p7"; 1.1755 + } 1.1756 +diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES 1.1757 +--- mpfr-3.0.0-a/PATCHES 2010-11-09 15:15:07.000000000 +0000 1.1758 ++++ mpfr-3.0.0-b/PATCHES 2010-11-09 15:15:07.000000000 +0000 1.1759 +@@ -0,0 +1 @@ 1.1760 ++macros 1.1761 +diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION 1.1762 +--- mpfr-3.0.0-a/VERSION 2010-10-21 21:18:26.000000000 +0000 1.1763 ++++ mpfr-3.0.0-b/VERSION 2010-11-09 15:15:07.000000000 +0000 1.1764 +@@ -1 +1 @@ 1.1765 +-3.0.0-p7 1.1766 ++3.0.0-p8 1.1767 +diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h 1.1768 +--- mpfr-3.0.0-a/mpfr.h 2010-10-21 21:18:26.000000000 +0000 1.1769 ++++ mpfr-3.0.0-b/mpfr.h 2010-11-09 15:15:07.000000000 +0000 1.1770 +@@ -27,7 +27,7 @@ 1.1771 + #define MPFR_VERSION_MAJOR 3 1.1772 + #define MPFR_VERSION_MINOR 0 1.1773 + #define MPFR_VERSION_PATCHLEVEL 0 1.1774 +-#define MPFR_VERSION_STRING "3.0.0-p7" 1.1775 ++#define MPFR_VERSION_STRING "3.0.0-p8" 1.1776 + 1.1777 + /* Macros dealing with MPFR VERSION */ 1.1778 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) 1.1779 +@@ -67,6 +67,16 @@ 1.1780 + # define _MPFR_H_HAVE_INTMAX_T 1 1.1781 + #endif 1.1782 + 1.1783 ++/* Avoid some problems with macro expansion if the user defines macros 1.1784 ++ with the same name as keywords. By convention, identifiers and macro 1.1785 ++ names starting with mpfr_ are reserved by MPFR. */ 1.1786 ++typedef void mpfr_void; 1.1787 ++typedef int mpfr_int; 1.1788 ++typedef unsigned int mpfr_uint; 1.1789 ++typedef long mpfr_long; 1.1790 ++typedef unsigned long mpfr_ulong; 1.1791 ++typedef size_t mpfr_size_t; 1.1792 ++ 1.1793 + /* Definition of rounding modes (DON'T USE MPFR_RNDNA!). 1.1794 + Warning! Changing the contents of this enum should be seen as an 1.1795 + interface change since the old and the new types are not compatible 1.1796 +@@ -136,7 +146,7 @@ 1.1797 + typedef mp_exp_t mpfr_exp_t; 1.1798 + 1.1799 + /* Definition of the standard exponent limits */ 1.1800 +-#define MPFR_EMAX_DEFAULT ((mpfr_exp_t) (((unsigned long) 1 << 30) - 1)) 1.1801 ++#define MPFR_EMAX_DEFAULT ((mpfr_exp_t) (((mpfr_ulong) 1 << 30) - 1)) 1.1802 + #define MPFR_EMIN_DEFAULT (-(MPFR_EMAX_DEFAULT)) 1.1803 + 1.1804 + /* Definition of the main structure */ 1.1805 +@@ -725,13 +735,13 @@ 1.1806 + unexpected results with future compilers and aggressive optimisations. 1.1807 + Why not working only with signed types, using INT_MIN and LONG_MIN? */ 1.1808 + #if __GMP_MP_SIZE_T_INT 1.1809 +-#define __MPFR_EXP_NAN ((mpfr_exp_t)((~((~(unsigned int)0)>>1))+2)) 1.1810 +-#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(unsigned int)0)>>1))+1)) 1.1811 +-#define __MPFR_EXP_INF ((mpfr_exp_t)((~((~(unsigned int)0)>>1))+3)) 1.1812 ++#define __MPFR_EXP_NAN ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+2)) 1.1813 ++#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+1)) 1.1814 ++#define __MPFR_EXP_INF ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+3)) 1.1815 + #else 1.1816 +-#define __MPFR_EXP_NAN ((mpfr_exp_t)((~((~(unsigned long)0)>>1))+2)) 1.1817 +-#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(unsigned long)0)>>1))+1)) 1.1818 +-#define __MPFR_EXP_INF ((mpfr_exp_t)((~((~(unsigned long)0)>>1))+3)) 1.1819 ++#define __MPFR_EXP_NAN ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+2)) 1.1820 ++#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+1)) 1.1821 ++#define __MPFR_EXP_INF ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+3)) 1.1822 + #endif 1.1823 + 1.1824 + /* Define MPFR_USE_EXTENSION to avoid "gcc -pedantic" warnings. */ 1.1825 +@@ -760,9 +770,9 @@ 1.1826 + #define mpfr_inf_p(_x) ((_x)->_mpfr_exp == __MPFR_EXP_INF) 1.1827 + #define mpfr_zero_p(_x) ((_x)->_mpfr_exp == __MPFR_EXP_ZERO) 1.1828 + #define mpfr_regular_p(_x) ((_x)->_mpfr_exp > __MPFR_EXP_INF) 1.1829 +-#define mpfr_sgn(_x) \ 1.1830 +- ((_x)->_mpfr_exp < __MPFR_EXP_INF ? \ 1.1831 +- (mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (void) 0), 0 : \ 1.1832 ++#define mpfr_sgn(_x) \ 1.1833 ++ ((_x)->_mpfr_exp < __MPFR_EXP_INF ? \ 1.1834 ++ (mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (mpfr_void) 0), 0 : \ 1.1835 + MPFR_SIGN (_x)) 1.1836 + 1.1837 + /* Prevent them from using as lvalues */ 1.1838 +@@ -805,7 +815,19 @@ 1.1839 + Moreover casts to unsigned long have been added to avoid warnings in 1.1840 + programs that use MPFR and are compiled with -Wconversion; such casts 1.1841 + are OK since if X is a constant expression, then (unsigned long) X is 1.1842 +- also a constant expression, so that the optimizations still work. */ 1.1843 ++ also a constant expression, so that the optimizations still work. The 1.1844 ++ warnings are probably related to the following two bugs: 1.1845 ++ http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210 1.1846 ++ http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38470 (possibly a variant) 1.1847 ++ and the casts could be removed once these bugs are fixed. 1.1848 ++ Casts shouldn't be used on the generic calls (to the ..._2exp functions), 1.1849 ++ where implicit conversions are performed. Indeed, having at least one 1.1850 ++ implicit conversion in the macro allows the compiler to emit diagnostics 1.1851 ++ when normally expected, for instance in the following call: 1.1852 ++ mpfr_set_ui (x, "foo", MPFR_RNDN); 1.1853 ++ If this is not possible (for future macros), one of the tricks described 1.1854 ++ on http://groups.google.com/group/comp.std.c/msg/e92abd24bf9eaf7b could 1.1855 ++ be used. */ 1.1856 + #if defined (__GNUC__) && !defined(__ICC) && !defined(__cplusplus) 1.1857 + #if (__GNUC__ >= 2) 1.1858 + #undef mpfr_cmp_ui 1.1859 +@@ -813,45 +835,45 @@ 1.1860 + But warning! mpfr_sgn is specified as a macro in the API, thus the macro 1.1861 + mustn't be used if side effects are possible, like here. */ 1.1862 + #define mpfr_cmp_ui(_f,_u) \ 1.1863 +- (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ? \ 1.1864 ++ (__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ? \ 1.1865 + (mpfr_sgn) (_f) : \ 1.1866 +- mpfr_cmp_ui_2exp ((_f), (unsigned long) (_u), 0)) 1.1867 ++ mpfr_cmp_ui_2exp ((_f), (_u), 0)) 1.1868 + #undef mpfr_cmp_si 1.1869 +-#define mpfr_cmp_si(_f,_s) \ 1.1870 +- (__builtin_constant_p (_s) && (long) (_s) >= 0 ? \ 1.1871 +- mpfr_cmp_ui ((_f), (unsigned long) (long) (_s)) : \ 1.1872 +- mpfr_cmp_si_2exp ((_f), (long) (_s), 0)) 1.1873 ++#define mpfr_cmp_si(_f,_s) \ 1.1874 ++ (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ? \ 1.1875 ++ mpfr_cmp_ui ((_f), (mpfr_ulong) (mpfr_long) (_s)) : \ 1.1876 ++ mpfr_cmp_si_2exp ((_f), (_s), 0)) 1.1877 + #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95 1.1878 + #undef mpfr_set_ui 1.1879 + #define mpfr_set_ui(_f,_u,_r) \ 1.1880 +- (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ? \ 1.1881 ++ (__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ? \ 1.1882 + __extension__ ({ \ 1.1883 + mpfr_ptr _p = (_f); \ 1.1884 + _p->_mpfr_sign = 1; \ 1.1885 + _p->_mpfr_exp = __MPFR_EXP_ZERO; \ 1.1886 +- (void) (_r); 0; }) : \ 1.1887 +- mpfr_set_ui_2exp ((_f), (unsigned long) (_u), 0, (_r))) 1.1888 ++ (mpfr_void) (_r); 0; }) : \ 1.1889 ++ mpfr_set_ui_2exp ((_f), (_u), 0, (_r))) 1.1890 + #endif 1.1891 + #undef mpfr_set_si 1.1892 + #define mpfr_set_si(_f,_s,_r) \ 1.1893 +- (__builtin_constant_p (_s) && (long) (_s) >= 0 ? \ 1.1894 +- mpfr_set_ui ((_f), (unsigned long) (long) (_s), (_r)) : \ 1.1895 +- mpfr_set_si_2exp ((_f), (long) (_s), 0, (_r))) 1.1896 ++ (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ? \ 1.1897 ++ mpfr_set_ui ((_f), (mpfr_ulong) (mpfr_long) (_s), (_r)) : \ 1.1898 ++ mpfr_set_si_2exp ((_f), (_s), 0, (_r))) 1.1899 + #endif 1.1900 + #endif 1.1901 + 1.1902 + /* Macro version of mpfr_stack interface for fast access */ 1.1903 +-#define mpfr_custom_get_size(p) ((size_t) \ 1.1904 ++#define mpfr_custom_get_size(p) ((mpfr_size_t) \ 1.1905 + (((p)+GMP_NUMB_BITS-1)/GMP_NUMB_BITS*sizeof (mp_limb_t))) 1.1906 + #define mpfr_custom_init(m,p) do {} while (0) 1.1907 +-#define mpfr_custom_get_significand(x) ((void*)((x)->_mpfr_d)) 1.1908 ++#define mpfr_custom_get_significand(x) ((mpfr_void*)((x)->_mpfr_d)) 1.1909 + #define mpfr_custom_get_exp(x) ((x)->_mpfr_exp) 1.1910 + #define mpfr_custom_move(x,m) do { ((x)->_mpfr_d = (mp_limb_t*)(m)); } while (0) 1.1911 + #define mpfr_custom_init_set(x,k,e,p,m) do { \ 1.1912 + mpfr_ptr _x = (x); \ 1.1913 + mpfr_exp_t _e; \ 1.1914 + mpfr_kind_t _t; \ 1.1915 +- int _s, _k; \ 1.1916 ++ mpfr_int _s, _k; \ 1.1917 + _k = (k); \ 1.1918 + if (_k >= 0) { \ 1.1919 + _t = (mpfr_kind_t) _k; \ 1.1920 +@@ -868,11 +890,13 @@ 1.1921 + _x->_mpfr_exp = _e; \ 1.1922 + _x->_mpfr_d = (mp_limb_t*) (m); \ 1.1923 + } while (0) 1.1924 +-#define mpfr_custom_get_kind(x) \ 1.1925 +- ( (x)->_mpfr_exp > __MPFR_EXP_INF ? (int)MPFR_REGULAR_KIND*MPFR_SIGN (x) \ 1.1926 +- : (x)->_mpfr_exp == __MPFR_EXP_INF ? (int)MPFR_INF_KIND*MPFR_SIGN (x) \ 1.1927 +- : (x)->_mpfr_exp == __MPFR_EXP_NAN ? (int)MPFR_NAN_KIND \ 1.1928 +- : (int) MPFR_ZERO_KIND * MPFR_SIGN (x) ) 1.1929 ++#define mpfr_custom_get_kind(x) \ 1.1930 ++ ( (x)->_mpfr_exp > __MPFR_EXP_INF ? \ 1.1931 ++ (mpfr_int) MPFR_REGULAR_KIND * MPFR_SIGN (x) \ 1.1932 ++ : (x)->_mpfr_exp == __MPFR_EXP_INF ? \ 1.1933 ++ (mpfr_int) MPFR_INF_KIND * MPFR_SIGN (x) \ 1.1934 ++ : (x)->_mpfr_exp == __MPFR_EXP_NAN ? (mpfr_int) MPFR_NAN_KIND \ 1.1935 ++ : (mpfr_int) MPFR_ZERO_KIND * MPFR_SIGN (x) ) 1.1936 + 1.1937 + 1.1938 + #endif /* MPFR_USE_NO_MACRO */ 1.1939 +diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c 1.1940 +--- mpfr-3.0.0-a/version.c 2010-10-21 21:18:26.000000000 +0000 1.1941 ++++ mpfr-3.0.0-b/version.c 2010-11-09 15:15:07.000000000 +0000 1.1942 +@@ -25,5 +25,5 @@ 1.1943 + const char * 1.1944 + mpfr_get_version (void) 1.1945 + { 1.1946 +- return "3.0.0-p7"; 1.1947 ++ return "3.0.0-p8"; 1.1948 + }