summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2003-01-25 01:31:35 +0100
committerKevin Ryde <user42@zip.com.au>2003-01-25 01:31:35 +0100
commit1199e5403de2c5c0fd5b5772e0213463769b0e96 (patch)
treeb10344307d63d1c580293e130aa3a0942120d07b
parent389a951b8713d53b1f32c854710f50277ee4488c (diff)
downloadgmp-1199e5403de2c5c0fd5b5772e0213463769b0e96.tar.gz
* mpfr/*: Update to mpfr cvs 2003-01-25.
-rw-r--r--mpfr/Makefile.am2
-rw-r--r--mpfr/Makefile.in9
-rw-r--r--mpfr/mpfr-impl.h20
-rw-r--r--mpfr/mpfr-test.h2
-rw-r--r--mpfr/set_ld.c13
-rw-r--r--mpfr/tests/tset_ld.c14
-rw-r--r--mpfr/volatile.c41
7 files changed, 88 insertions, 13 deletions
diff --git a/mpfr/Makefile.am b/mpfr/Makefile.am
index 38ef26459..c67f4c30a 100644
--- a/mpfr/Makefile.am
+++ b/mpfr/Makefile.am
@@ -44,7 +44,7 @@ TEXINFO_TEX = ../texinfo.tex
# Override automake default AR=ar with the value from GMP_PROG_AR.
AR = @AR@
-libmpfr_a_SOURCES = mpfr.h mpf2mpfr.h mpfr-impl.h mpfr-math.h mpfr-test.h log_b2.h exceptions.c save_expo.c extract.c uceil_exp2.c uceil_log2.c ufloor_log2.c add.c add1.c add_one_ulp.c add_ui.c agm.c clear.c cmp.c cmp_abs.c cmp_si.c cmp_ui.c comparisons.c div_2exp.c div_2si.c div_2ui.c div.c div_ui.c dump.c eq.c exp2.c exp3.c exp.c frac.c get_d.c get_exp.c get_str.c init.c inp_str.c isinteger.c isinf.c isnan.c isnum.c const_log2.c log.c mul_2exp.c mul_2si.c mul_2ui.c mul.c mul_ui.c neg.c next.c out_str.c const_pi.c pow.c pow_si.c pow_ui.c print_raw.c print_rnd_mode.c random2.c random.c reldiff.c round_prec.c set.c setmax.c setmin.c set_d.c set_dfl_prec.c set_exp.c set_rnd.c set_f.c set_prc_raw.c set_prec.c set_q.c set_si.c set_str.c set_str_raw.c set_ui.c set_z.c sqrt.c sqrt_ui.c sub.c sub1.c sub_one_ulp.c sub_ui.c rint.c ui_div.c ui_sub.c urandomb.c get_z_exp.c swap.c factorial.c cosh.c sinh.c tanh.c acosh.c asinh.c atanh.c atan.c cmp2.c exp_2.c asin.c const_euler.c cos.c sin.c tan.c fma.c hypot.c log1p.c expm1.c log2.c log10.c ui_pow.c ui_pow_ui.c minmax.c dim.c copysign.c gmp_op.c init2.c acos.c sin_cos.c set_nan.c set_inf.c powerof2.c gamma.c set_ld.c get_ld.c cbrt.c
+libmpfr_a_SOURCES = mpfr.h mpf2mpfr.h mpfr-impl.h mpfr-math.h mpfr-test.h log_b2.h exceptions.c save_expo.c extract.c uceil_exp2.c uceil_log2.c ufloor_log2.c add.c add1.c add_one_ulp.c add_ui.c agm.c clear.c cmp.c cmp_abs.c cmp_si.c cmp_ui.c comparisons.c div_2exp.c div_2si.c div_2ui.c div.c div_ui.c dump.c eq.c exp2.c exp3.c exp.c frac.c get_d.c get_exp.c get_str.c init.c inp_str.c isinteger.c isinf.c isnan.c isnum.c const_log2.c log.c mul_2exp.c mul_2si.c mul_2ui.c mul.c mul_ui.c neg.c next.c out_str.c const_pi.c pow.c pow_si.c pow_ui.c print_raw.c print_rnd_mode.c random2.c random.c reldiff.c round_prec.c set.c setmax.c setmin.c set_d.c set_dfl_prec.c set_exp.c set_rnd.c set_f.c set_prc_raw.c set_prec.c set_q.c set_si.c set_str.c set_str_raw.c set_ui.c set_z.c sqrt.c sqrt_ui.c sub.c sub1.c sub_one_ulp.c sub_ui.c rint.c ui_div.c ui_sub.c urandomb.c get_z_exp.c swap.c factorial.c cosh.c sinh.c tanh.c acosh.c asinh.c atanh.c atan.c cmp2.c exp_2.c asin.c const_euler.c cos.c sin.c tan.c fma.c hypot.c log1p.c expm1.c log2.c log10.c ui_pow.c ui_pow_ui.c minmax.c dim.c copysign.c gmp_op.c init2.c acos.c sin_cos.c set_nan.c set_inf.c powerof2.c gamma.c set_ld.c get_ld.c cbrt.c volatile.c
libmpfr_a_LIBADD = @LIBOBJS@
diff --git a/mpfr/Makefile.in b/mpfr/Makefile.in
index 683d1228f..21f4be50e 100644
--- a/mpfr/Makefile.in
+++ b/mpfr/Makefile.in
@@ -216,7 +216,7 @@ mpfr_TEXINFOS = ../fdl.texi
AM_MAKEINFOFLAGS = -I$(top_srcdir)
TEXINFO_TEX = ../texinfo.tex
-libmpfr_a_SOURCES = mpfr.h mpf2mpfr.h mpfr-impl.h mpfr-math.h mpfr-test.h log_b2.h exceptions.c save_expo.c extract.c uceil_exp2.c uceil_log2.c ufloor_log2.c add.c add1.c add_one_ulp.c add_ui.c agm.c clear.c cmp.c cmp_abs.c cmp_si.c cmp_ui.c comparisons.c div_2exp.c div_2si.c div_2ui.c div.c div_ui.c dump.c eq.c exp2.c exp3.c exp.c frac.c get_d.c get_exp.c get_str.c init.c inp_str.c isinteger.c isinf.c isnan.c isnum.c const_log2.c log.c mul_2exp.c mul_2si.c mul_2ui.c mul.c mul_ui.c neg.c next.c out_str.c const_pi.c pow.c pow_si.c pow_ui.c print_raw.c print_rnd_mode.c random2.c random.c reldiff.c round_prec.c set.c setmax.c setmin.c set_d.c set_dfl_prec.c set_exp.c set_rnd.c set_f.c set_prc_raw.c set_prec.c set_q.c set_si.c set_str.c set_str_raw.c set_ui.c set_z.c sqrt.c sqrt_ui.c sub.c sub1.c sub_one_ulp.c sub_ui.c rint.c ui_div.c ui_sub.c urandomb.c get_z_exp.c swap.c factorial.c cosh.c sinh.c tanh.c acosh.c asinh.c atanh.c atan.c cmp2.c exp_2.c asin.c const_euler.c cos.c sin.c tan.c fma.c hypot.c log1p.c expm1.c log2.c log10.c ui_pow.c ui_pow_ui.c minmax.c dim.c copysign.c gmp_op.c init2.c acos.c sin_cos.c set_nan.c set_inf.c powerof2.c gamma.c set_ld.c get_ld.c cbrt.c
+libmpfr_a_SOURCES = mpfr.h mpf2mpfr.h mpfr-impl.h mpfr-math.h mpfr-test.h log_b2.h exceptions.c save_expo.c extract.c uceil_exp2.c uceil_log2.c ufloor_log2.c add.c add1.c add_one_ulp.c add_ui.c agm.c clear.c cmp.c cmp_abs.c cmp_si.c cmp_ui.c comparisons.c div_2exp.c div_2si.c div_2ui.c div.c div_ui.c dump.c eq.c exp2.c exp3.c exp.c frac.c get_d.c get_exp.c get_str.c init.c inp_str.c isinteger.c isinf.c isnan.c isnum.c const_log2.c log.c mul_2exp.c mul_2si.c mul_2ui.c mul.c mul_ui.c neg.c next.c out_str.c const_pi.c pow.c pow_si.c pow_ui.c print_raw.c print_rnd_mode.c random2.c random.c reldiff.c round_prec.c set.c setmax.c setmin.c set_d.c set_dfl_prec.c set_exp.c set_rnd.c set_f.c set_prc_raw.c set_prec.c set_q.c set_si.c set_str.c set_str_raw.c set_ui.c set_z.c sqrt.c sqrt_ui.c sub.c sub1.c sub_one_ulp.c sub_ui.c rint.c ui_div.c ui_sub.c urandomb.c get_z_exp.c swap.c factorial.c cosh.c sinh.c tanh.c acosh.c asinh.c atanh.c atan.c cmp2.c exp_2.c asin.c const_euler.c cos.c sin.c tan.c fma.c hypot.c log1p.c expm1.c log2.c log10.c ui_pow.c ui_pow_ui.c minmax.c dim.c copysign.c gmp_op.c init2.c acos.c sin_cos.c set_nan.c set_inf.c powerof2.c gamma.c set_ld.c get_ld.c cbrt.c volatile.c
libmpfr_a_LIBADD = @LIBOBJS@
@@ -270,7 +270,8 @@ am_libmpfr_a_OBJECTS = exceptions$U.$(OBJEXT) save_expo$U.$(OBJEXT) \
copysign$U.$(OBJEXT) gmp_op$U.$(OBJEXT) init2$U.$(OBJEXT) \
acos$U.$(OBJEXT) sin_cos$U.$(OBJEXT) set_nan$U.$(OBJEXT) \
set_inf$U.$(OBJEXT) powerof2$U.$(OBJEXT) gamma$U.$(OBJEXT) \
- set_ld$U.$(OBJEXT) get_ld$U.$(OBJEXT) cbrt$U.$(OBJEXT)
+ set_ld$U.$(OBJEXT) get_ld$U.$(OBJEXT) cbrt$U.$(OBJEXT) \
+ volatile$U.$(OBJEXT)
libmpfr_a_OBJECTS = $(am_libmpfr_a_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
@@ -617,6 +618,8 @@ ui_sub_.c: ui_sub.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ui_sub.c; then echo $(srcdir)/ui_sub.c; else echo ui_sub.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
urandomb_.c: urandomb.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/urandomb.c; then echo $(srcdir)/urandomb.c; else echo urandomb.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+volatile_.c: volatile.c $(ANSI2KNR)
+ $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/volatile.c; then echo $(srcdir)/volatile.c; else echo volatile.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
acos_.$(OBJEXT) acos_.lo acosh_.$(OBJEXT) acosh_.lo add_.$(OBJEXT) \
add_.lo add1_.$(OBJEXT) add1_.lo add_one_ulp_.$(OBJEXT) add_one_ulp_.lo \
add_ui_.$(OBJEXT) add_ui_.lo agm_.$(OBJEXT) agm_.lo asin_.$(OBJEXT) \
@@ -673,7 +676,7 @@ tanh_.lo uceil_exp2_.$(OBJEXT) uceil_exp2_.lo uceil_log2_.$(OBJEXT) \
uceil_log2_.lo ufloor_log2_.$(OBJEXT) ufloor_log2_.lo ui_div_.$(OBJEXT) \
ui_div_.lo ui_pow_.$(OBJEXT) ui_pow_.lo ui_pow_ui_.$(OBJEXT) \
ui_pow_ui_.lo ui_sub_.$(OBJEXT) ui_sub_.lo urandomb_.$(OBJEXT) \
-urandomb_.lo : $(ANSI2KNR)
+urandomb_.lo volatile_.$(OBJEXT) volatile_.lo : $(ANSI2KNR)
mostlyclean-libtool:
-rm -f *.lo
diff --git a/mpfr/mpfr-impl.h b/mpfr/mpfr-impl.h
index df4d7b30a..a974ad9dd 100644
--- a/mpfr/mpfr-impl.h
+++ b/mpfr/mpfr-impl.h
@@ -107,6 +107,26 @@ typedef union ieee_double_extract Ieee_double_extract;
#define DBL_NEG_INF (-1.0/0.0)
#define DBL_NAN (0.0/0.0)
+
+/* Execute the code "action" if x is a NaN.
+ Under IEEE rules, NaN is not equal to anything, including itself.
+ "volatile" here stops "cc" on mips64-sgi-irix6.5 from optimizing away
+ x!=x. */
+#define LONGDOUBLE_NAN_ACTION(x, action) \
+ do { \
+ volatile long double __x = LONGDOUBLE_VOLATILE (x); \
+ if ((x) != __x) \
+ { action; } \
+ } while (0)
+
+#ifdef volatile
+long double __gmpfr_longdouble_volatile __GMP_PROTO ((long double)) ATTRIBUTE_CONST;
+#define LONGDOUBLE_VOLATILE(x) (__gmpfr_longdouble_volatile (x))
+#else
+#define LONGDOUBLE_VOLATILE(x) (x)
+#endif
+
+
/* bit 31 of _mpfr_size is used for sign,
bit 30 of _mpfr_size is used for Nan flag,
bit 29 of _mpfr_size is used for Inf flag,
diff --git a/mpfr/mpfr-test.h b/mpfr/mpfr-test.h
index 9ba7bf921..4f6686eb5 100644
--- a/mpfr/mpfr-test.h
+++ b/mpfr/mpfr-test.h
@@ -84,4 +84,4 @@ double dbl _PROTO ((double, int));
double Ulp _PROTO ((double));
int Isnan _PROTO ((double));
-#define LONGDOUBLE_ISNAN(x) ((x) != (x))
+
diff --git a/mpfr/set_ld.c b/mpfr/set_ld.c
index 2f83124ed..52954588a 100644
--- a/mpfr/set_ld.c
+++ b/mpfr/set_ld.c
@@ -36,8 +36,6 @@ MA 02111-1307, USA. */
#define CHAR_BIT 8
#endif
-#define LONGDOUBLE_ISNAN(x) ((x) != (x))
-
/* Various i386 systems have been seen with float.h LDBL constants equal to
the DBL ones, whereas they ought to be bigger, reflecting the 10-byte
@@ -69,11 +67,7 @@ mpfr_set_ld (mpfr_ptr r, long double d, mp_rnd_t rnd_mode)
mpfr_t t, u;
int inexact, shift_exp = 0, inexact2 = 0;
- if (LONGDOUBLE_ISNAN(d))
- {
- MPFR_SET_NAN(r);
- MPFR_RET_NAN;
- }
+ LONGDOUBLE_NAN_ACTION (d, goto nan);
if (d > MPFR_LDBL_MAX)
{
@@ -187,4 +181,9 @@ mpfr_set_ld (mpfr_ptr r, long double d, mp_rnd_t rnd_mode)
mpfr_clear (u);
return inexact;
+
+
+ nan:
+ MPFR_SET_NAN(r);
+ MPFR_RET_NAN;
}
diff --git a/mpfr/tests/tset_ld.c b/mpfr/tests/tset_ld.c
index 88b49a0b5..8f0c7be18 100644
--- a/mpfr/tests/tset_ld.c
+++ b/mpfr/tests/tset_ld.c
@@ -24,9 +24,21 @@ MA 02111-1307, USA. */
#include <float.h>
#include <time.h>
#include "gmp.h"
+#include "gmp-impl.h"
#include "mpfr.h"
+#include "mpfr-impl.h"
#include "mpfr-test.h"
+
+static int
+Isnan_ld (long double d)
+{
+ LONGDOUBLE_NAN_ACTION (d, goto yes);
+ return 0;
+ yes:
+ return 1;
+}
+
/* checks that a long double converted to a mpfr (with precision >=113),
then converted back to a long double gives the initial value,
or in other words mpfr_get_ld(mpfr_set_ld(d)) = d.
@@ -45,7 +57,7 @@ check_set_get (long double d, mpfr_t x)
exit (1);
}
e = mpfr_get_ld (x, r);
- if (e != d && !(LONGDOUBLE_ISNAN(e) && LONGDOUBLE_ISNAN(d)))
+ if (e != d && !(Isnan_ld(e) && Isnan_ld(d)))
{
fprintf (stderr, "Error: mpfr_get_ld o mpfr_set_ld <> Id\n");
fprintf (stderr, "d=%1.30Le get_ld(set_ld(d))=%1.30Le\n", d, e);
diff --git a/mpfr/volatile.c b/mpfr/volatile.c
new file mode 100644
index 000000000..637ac59b3
--- /dev/null
+++ b/mpfr/volatile.c
@@ -0,0 +1,41 @@
+/* __gmpfr_longdouble_volatile -- support for LONGDOUBLE_NAN_ACTION.
+
+ THE FUNCTIONS IN THIS FILE ARE FOR INTERNAL USE ONLY. THEY'RE ALMOST
+ CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
+ FUTURE MPFR RELEASES.
+
+Copyright 2003 Free Software Foundation, Inc.
+
+This file is part of the MPFR Library.
+
+The MPFR Library is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 of the License, or (at your
+option) any later version.
+
+The MPFR Library is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the MPFR Library; see the file COPYING.LIB. If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+#include "mpfr.h"
+#include "mpfr-impl.h"
+
+
+/* Only needed if "volatile" doesn't work, ie. has been #defined to empty in
+ config.h. */
+
+#ifdef volatile
+long double
+__gmpfr_longdouble_volatile (long double x)
+{
+ return x;
+}
+#endif