summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2003-12-19 11:54:48 +0000
committerpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2003-12-19 11:54:48 +0000
commitcc7beec4dbcacef7817a27bd05374a63a11f0c30 (patch)
tree5a8588bf8d6b6e4b55ec133653b2275cd0c8bc1a
parent04746017d1c00291f2f8617350130bc2c2355872 (diff)
downloadmpfr-cc7beec4dbcacef7817a27bd05374a63a11f0c30.tar.gz
Remove one warning in mpf_compat.h
Create a new macro: MPFR_RET_NEVER_GO_HERE Modify ui_sub/div to use it to make Insure++ happy. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2583 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--mpfr-impl.h70
-rw-r--r--sub1sp.c4
-rw-r--r--tests/mpf_compat.h2
-rw-r--r--ui_div.c2
-rw-r--r--ui_sub.c2
5 files changed, 35 insertions, 45 deletions
diff --git a/mpfr-impl.h b/mpfr-impl.h
index 7f70c933b..687d08098 100644
--- a/mpfr-impl.h
+++ b/mpfr-impl.h
@@ -1,7 +1,7 @@
/* Utilities for MPFR developers, not exported.
Copyright 1999, 2000, 2001, 2002, 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
@@ -48,7 +48,17 @@ MA 02111-1307, USA. */
#define strncasecmp mpfr_strncasecmp
#endif
-/* Definition of MPFR_LIMB_HIGHBIT */
+/* Check GMP */
+#if GMP_NAIL_BITS != 0
+# error "MPFR doesn't support nonzero values of GMP_NAIL_BITS"
+#endif
+
+#if (BITS_PER_MP_LIMB & (BITS_PER_MP_LIMB - 1))
+# error "BITS_PER_MP_LIMB must be a power of 2"
+#endif
+
+
+/* Definition of MPFR_LIMB_HIGHBIT and MPFR_LIMB_ONE */
#ifdef GMP_LIMB_HIGHBIT
# define MPFR_LIMB_HIGHBIT GMP_LIMB_HIGHBIT
#else
@@ -59,12 +69,9 @@ MA 02111-1307, USA. */
# endif
#endif
-#if GMP_NAIL_BITS != 0
-# error "MPFR doesn't support nonzero values of GMP_NAIL_BITS"
-#endif
-
-#if (BITS_PER_MP_LIMB & (BITS_PER_MP_LIMB - 1))
-# error "BITS_PER_MP_LIMB must be a power of 2"
+#define MPFR_LIMB_ONE ((mp_limb_t) 1)
+#ifndef MP_LIMB_T_ONE
+# define MP_LIMB_T_ONE MPFR_LIMB_ONE
#endif
/* Check if we can represent the number of limbs
@@ -75,8 +82,14 @@ MA 02111-1307, USA. */
# error "Incompatibilty between mp_size_t and mpfr_prec_t."
# endif
#else
-# if (MP_SIZE_T_MAX < (ULONG_MAX/BYTES_PER_MP_LIMB))
-# error "Incompatibilty between mp_size_t and mpfr_prec_t."
+# ifdef MPFR_PREC_FORMAT_SHORT
+# if (MP_SIZE_T_MAX < (USHORT_MAX/BYTES_PER_MP_LIMB))
+# error "Incompatibilty between mp_size_t and mpfr_prec_t."
+# endif
+# else
+# if (MP_SIZE_T_MAX < (ULONG_MAX/BYTES_PER_MP_LIMB))
+# error "Incompatibilty between mp_size_t and mpfr_prec_t."
+# endif
# endif
#endif
@@ -86,46 +99,20 @@ MA 02111-1307, USA. */
/* Defined limits and unsigned type of exponent */
#if __GMP_MP_SIZE_T_INT == 1
-typedef unsigned int mpfr_exp_unsigned_t;
+typedef unsigned int mpfr_uexp_t;
# define MPFR_EXP_MAX (INT_MAX)
# define MPFR_EXP_MIN (INT_MIN)
#else
-typedef unsigned long int mpfr_exp_unsigned_t;
+typedef unsigned long int mpfr_uexp_t;
# define MPFR_EXP_MAX (LONG_MAX)
# define MPFR_EXP_MIN (LONG_MIN)
#endif
#ifndef mp_exp_unsigned_t
-# define mp_exp_unsigned_t mpfr_exp_unsigned_t
-#endif
-
-#define MPFR_LIMB_ONE ((mp_limb_t) 1)
-#ifndef MP_LIMB_T_ONE
-# define MP_LIMB_T_ONE MPFR_LIMB_ONE
+# define mp_exp_unsigned_t mpfr_uexp_t
#endif
#define MPFR_INTPREC_MAX (ULONG_MAX & ~(unsigned long) (BITS_PER_MP_LIMB - 1))
-/* Redefine MPN_COPY if compilation for small vars FIXME: Usefull ?*/
-#ifdef SMALL
-#undef MPN_COPY
-#define MPN_COPY(dest, src, n) \
- do { \
- if ((n) != 0) \
- { \
- mp_size_t __n = ((n)-1); \
- mp_ptr __dst = (dest); \
- mp_srcptr __src = (src); \
- mp_limb_t __x = *__src++;\
- if (__n) \
- do { \
- *__dst++ = __x; \
- __x = *__src++; \
- } while (--__n); \
- *__dst = __x; \
- } \
- } while (0)
-#endif
-
/* Assertions */
/* Compile with -DWANT_ASSERT to check all assert statements */
@@ -146,6 +133,7 @@ typedef unsigned long int mpfr_exp_unsigned_t;
# define MPFR_ASSERTD(expr) ((void) 0)
#endif
+/* Check if the args are correct */
#define MPFR_CHECK1(x,r) \
MPFR_ASSERTD(mpfr_check(x) && GMP_RNDN <= r && r <= GMP_RNDD)
#define MPFR_CHECK2(x,y,r) \
@@ -154,6 +142,10 @@ typedef unsigned long int mpfr_exp_unsigned_t;
MPFR_ASSERTD(mpfr_check(x) && mpfr_check(y) && mpfr_check(z) && \
GMP_RNDN <= r && r <= GMP_RNDD)
+/* Code to deal with impossible
+ WARNING: It doesn't use do { } while (0) for Insure++*/
+#define MPFR_RET_NEVER_GO_HERE() {MPFR_ASSERTN(0); return 0;}
+
/* Theses macros help the compiler to determine if a test is
* likely or unlikely. */
#if __GNUC__ >= 3
diff --git a/sub1sp.c b/sub1sp.c
index d82ef1214..500628dd5 100644
--- a/sub1sp.c
+++ b/sub1sp.c
@@ -40,7 +40,7 @@ MA 02111-1307, USA. */
#else
# define DEBUG(x) /**/
#endif
-
+
/* Rounding Sub */
/* A0...Ap-1
@@ -606,7 +606,7 @@ mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
goto truncate;
}
}
- MPFR_ASSERTN(0);
+ MPFR_RET_NEVER_GO_HERE();
/* Sub one ulp to the result */
sub_one_ulp:
diff --git a/tests/mpf_compat.h b/tests/mpf_compat.h
index 6fc145e9d..fbdd7ea5e 100644
--- a/tests/mpf_compat.h
+++ b/tests/mpf_compat.h
@@ -189,8 +189,6 @@ main ()
mpf_random2 (x, 17, 17);
/* clear all variables */
-
- done:
mpf_clear (y);
mpf_clear (x);
diff --git a/ui_div.c b/ui_div.c
index 4e2dd757c..3150f371c 100644
--- a/ui_div.c
+++ b/ui_div.c
@@ -63,7 +63,7 @@ mpfr_ui_div (mpfr_ptr y, unsigned long int u, mpfr_srcptr x, mp_rnd_t rnd_mode)
}
}
else
- MPFR_ASSERTN(0);
+ MPFR_RET_NEVER_GO_HERE();
}
else if (u)
{
diff --git a/ui_sub.c b/ui_sub.c
index e73fd8de5..c5bd379f8 100644
--- a/ui_sub.c
+++ b/ui_sub.c
@@ -51,7 +51,7 @@ mpfr_ui_sub (mpfr_ptr y, unsigned long int u, mpfr_srcptr x, mp_rnd_t rnd_mode)
return mpfr_set_ui(y, u, rnd_mode);
/* Should never reach this code */
else
- MPFR_ASSERTN(0);
+ MPFR_RET_NEVER_GO_HERE();
}
else if (u)
{