diff options
author | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-09-20 14:45:32 +0000 |
---|---|---|
committer | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-09-20 14:45:32 +0000 |
commit | d10329556c3b664495584896df408970b3869a59 (patch) | |
tree | 96f0814c3af7c2099128065b2f94acca4219f6bb | |
parent | d6b32be3cf7fcc0c3ee0adffb41f77b787f44552 (diff) | |
download | mpfr-d10329556c3b664495584896df408970b3869a59.tar.gz |
Add ICC detection && support.
Remove some potential warnings in the test files.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2977 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | configure.in | 14 | ||||
-rw-r--r-- | get_d.c | 2 | ||||
-rw-r--r-- | mpfr-impl.h | 14 | ||||
-rw-r--r-- | mpfr.h | 6 | ||||
-rw-r--r-- | set_d.c | 20 | ||||
-rw-r--r-- | strtofr.c | 2 | ||||
-rw-r--r-- | tests/memory.c | 3 | ||||
-rw-r--r-- | tests/tdiv.c | 2 | ||||
-rw-r--r-- | tests/tests.c | 10 | ||||
-rw-r--r-- | tests/tget_str.c | 6 | ||||
-rw-r--r-- | tests/trint.c | 4 | ||||
-rw-r--r-- | tests/tset_d.c | 5 | ||||
-rw-r--r-- | tests/tset_q.c | 2 | ||||
-rw-r--r-- | tests/tset_str.c | 4 | ||||
-rw-r--r-- | tests/tstrtofr.c | 6 |
15 files changed, 65 insertions, 35 deletions
diff --git a/configure.in b/configure.in index 5472a01d7..c547b9d93 100644 --- a/configure.in +++ b/configure.in @@ -49,6 +49,20 @@ AC_CANONICAL_HOST AC_CHECK_OS AC_CHECK_MACHTYPE +dnl Check if compiler is ICC, and if such a case, disable GCC +dnl And add some specific flags. +dnl Don't add Warnings Flags (Otherwise you'll get more than 20000 warnings). +dnl Add -long_double flags ? +AC_MSG_CHECKING(for ICC) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#if !defined(__ICC) +# error "ICC Not Found" +#endif +]], [[]])],[AC_MSG_RESULT(yes) + GCC= + CFLAGS="-pc64 -fp_port -mp $CFLAGS" +],[AC_MSG_RESULT(no)]) + dnl If compiler is gcc, then use some specific flags. dnl But don't touch user specified flags. if test "$test_CFLAGS" != set && test -n "$GCC"; then @@ -81,7 +81,7 @@ static const struct dbl_bytes dbl_nan = #endif /* _GMP_IEEE_FLOATS */ - + /* multiplies 1/2 <= d <= 1 by 2^exp */ static double mpfr_scale2 (double d, int exp) diff --git a/mpfr-impl.h b/mpfr-impl.h index cc956cf06..363de98e1 100644 --- a/mpfr-impl.h +++ b/mpfr-impl.h @@ -24,9 +24,11 @@ MA 02111-1307, USA. */ /* Include 'config.h' before using ANY configure macros if needed NOTE: It isn't MPFR 'config.h', but GMP's one! */ +#if defined(HAVE_CONFIG_H) #if HAVE_CONFIG_H #include "config.h" #endif +#endif #ifdef MPFR_HAVE_GMP_IMPL /* Build with gmp internals*/ @@ -61,7 +63,7 @@ MA 02111-1307, USA. */ #endif #undef MPFR_NEED_LONGLONG_H -/* Macros to detect STDC, GCC, GLIBC and GMP version */ +/* Macros to detect STDC, GCC, GLIBC, GMP and ICC version */ #if defined(__STDC_VERSION__) # define __MPFR_STDC(version) (__STDC_VERSION__>=(version)) #elif defined(__STDC__) @@ -69,7 +71,7 @@ MA 02111-1307, USA. */ #else # define __MPFR_STDC(version) 0 #endif -#if defined(__GNUC__) && defined(__GNUC_MINOR__) +#if defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__ICC) # define __MPFR_GNUC(a, i) (MPFR_VERSION_NUM(__GNUC__,__GNUC_MINOR__,0)>=MPFR_VERSION_NUM(a,i,0)) #else # define __MPFR_GNUC(a, i) 0 @@ -84,7 +86,11 @@ MA 02111-1307, USA. */ #else # define __MPFR_GMP(a, b, c) 0 #endif - +#if defined(__ICC) +# define __MPFR_ICC(a,b,c) (__ICC >= (a)*100+(b)*10+c) +#else +# define __MPFR_ICC(a,b,c) 0 +#endif /* Define strcasecmp and strncasecmp if needed */ #ifndef HAVE_STRCASECMP @@ -193,7 +199,7 @@ typedef unsigned long int mpfr_uexp_t; /* Theses macros help the compiler to determine if a test is * likely or unlikely. */ -#if __MPFR_GNUC(3,0) +#if __MPFR_GNUC(3,0) || __MPFR_ICC(8,1,0) # define MPFR_LIKELY(x) (__builtin_expect(!!(x),1)) # define MPFR_UNLIKELY(x) (__builtin_expect((x),0)) #else @@ -511,8 +511,10 @@ int mpfr_strtofr _MPFR_PROTO ((mpfr_ptr, __gmp_const char *, char **, # define mpz_set_fr mpfr_get_z #endif -/* When using GCC, optimize certain common comparisons. */ -#if defined (__GNUC__) +/* When using GCC, optimize certain common comparisons. + Remove ICC since it defines __GNUC__, but produces a + huge number of warnings if you use this code */ +#if defined (__GNUC__) && !defined(__ICC) #undef mpfr_cmp_ui #define mpfr_cmp_ui(_f,_u) \ (__builtin_constant_p (_u) && (_u) == 0 ? \ @@ -159,7 +159,13 @@ mpfr_set_d (mpfr_ptr r, double d, mp_rnd_t rnd_mode) MPFR_CLEAR_FLAGS(r); - if (MPFR_UNLIKELY(d == 0)) + + if (MPFR_UNLIKELY(DOUBLE_ISNAN(d))) + { + MPFR_SET_NAN(r); + MPFR_RET_NAN; + } + else if (MPFR_UNLIKELY(d == 0)) { #if _GMP_IEEE_FLOATS union ieee_double_extract x; @@ -172,7 +178,7 @@ mpfr_set_d (mpfr_ptr r, double d, mp_rnd_t rnd_mode) else MPFR_SET_POS(r); #else /* _GMP_IEEE_FLOATS */ - MPFR_SET_ZERO(r); + MPFR_SET_ZERO(r); { /* This is to get the sign of zero on non-IEEE hardware Some systems support +0.0, -0.0 and unsigned zero. @@ -190,13 +196,8 @@ mpfr_set_d (mpfr_ptr r, double d, mp_rnd_t rnd_mode) #endif return 0; /* 0 is exact */ } - else if (MPFR_UNLIKELY(DOUBLE_ISNAN(d))) - { - MPFR_SET_NAN(r); - MPFR_RET_NAN; - } else if (MPFR_UNLIKELY(DOUBLE_ISINF(d))) - { + { MPFR_SET_INF(r); if (d > 0) MPFR_SET_POS(r); @@ -259,3 +260,6 @@ mpfr_set_d (mpfr_ptr r, double d, mp_rnd_t rnd_mode) return mpfr_check_range (r, inexact, rnd_mode); } + + + @@ -313,7 +313,7 @@ parse_string (mpfr_t x, struct parsed_string *pstr, c = digit_value_in_base (c, base); if (c == -1) break; - *mant++ = c; + *mant++ = (char) c; if (!point) pstr->exp_base ++; } diff --git a/tests/memory.c b/tests/memory.c index 6b202e5a1..dd1fb1b19 100644 --- a/tests/memory.c +++ b/tests/memory.c @@ -6,6 +6,7 @@ This file is part of the GNU MP Library. ChangeLog: tests_memory_valid has been commented out since it is not used + tests_memory_list is declared as static The GNU MP 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 @@ -44,7 +45,7 @@ struct header { struct header *next; }; -struct header *tests_memory_list = NULL; +static struct header *tests_memory_list = NULL; /* Return a pointer to a pointer to the found block (so it can be updated when unlinking). */ diff --git a/tests/tdiv.c b/tests/tdiv.c index cfc9ecc5f..4e9457b56 100644 --- a/tests/tdiv.c +++ b/tests/tdiv.c @@ -214,7 +214,7 @@ check_convergence (void) mpfr_div (y, x, y, j); if (mpfr_cmp_ui (y, 1)) { - printf ("mpfr_div failed for x=1.0, y=1.0, prec=%u rnd=%s\n", + printf ("mpfr_div failed for x=1.0, y=1.0, prec=%d rnd=%s\n", i, mpfr_print_rnd_mode(j)); printf ("got "); mpfr_print_binary(y); puts (""); exit (1); diff --git a/tests/tests.c b/tests/tests.c index d3765d59a..495410f18 100644 --- a/tests/tests.c +++ b/tests/tests.c @@ -19,8 +19,10 @@ 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. */ -#if HAVE_CONFIG_H -#include "config.h" /* for a build within gmp */ +#ifdef HAVE_CONFIG_H +# if HAVE_CONFIG_H +# include "config.h" /* for a build within gmp */ +# endif #endif #include <stdio.h> @@ -38,8 +40,8 @@ MA 02111-1307, USA. */ #include "mpfr-test.h" -void tests_rand_start _MPFR_PROTO ((void)); -void tests_rand_end _MPFR_PROTO ((void)); +static void tests_rand_start (void); +static void tests_rand_end (void); void tests_start_mpfr (void) diff --git a/tests/tget_str.c b/tests/tget_str.c index 36404a9f0..e89792c14 100644 --- a/tests/tget_str.c +++ b/tests/tget_str.c @@ -456,7 +456,7 @@ check_special (int b, mp_prec_t p) /* s should be 1 followed by (m-1) zeros, and e should be i+1 */ if ((e != i+1) || strncmp (s, s2, m) != 0) { - printf ("Error in mpfr_get_str for %u^%u\n", b, i); + printf ("Error in mpfr_get_str for %d^%d\n", b, i); exit (1); } } @@ -472,7 +472,7 @@ check_special (int b, mp_prec_t p) for (j=0; (j < i) && (s[j] == c); j++); if ((j < i) || (e != i)) { - printf ("Error in mpfr_get_str for %u^%u-1\n", b, i); + printf ("Error in mpfr_get_str for %d^%d-1\n", b, i); printf ("got 0.%s*2^%d\n", s, (int) e); exit (1); } @@ -483,7 +483,7 @@ check_special (int b, mp_prec_t p) /* should be b^i */ if ((e != i+1) || strncmp (s, s2, i - 1) != 0) { - printf ("Error in mpfr_get_str for %u^%u-1\n", b, i); + printf ("Error in mpfr_get_str for %d^%d-1\n", b, i); printf ("got 0.%s*2^%d\n", s, (int) e); exit (1); } diff --git a/tests/trint.c b/tests/trint.c index 30bd06565..a7475bed5 100644 --- a/tests/trint.c +++ b/tests/trint.c @@ -134,7 +134,7 @@ special (void) mpfr_clear (y); } -#if __STDC_VERSION__ >= 199901L +#if __MPFR_STDC (199901L) static void test_fct (double (*f)(double), int (*g)(), char *s, mp_rnd_t r) @@ -342,7 +342,7 @@ main (int argc, char *argv[]) special (); -#if __STDC_VERSION__ >= 199901L +#if __MPFR_STDC (199901L) if (argc > 1 && strcmp (argv[1], "-s") == 0) test_against_libc (); #endif diff --git a/tests/tset_d.c b/tests/tset_d.c index 0ba0b9ba9..0f096e30a 100644 --- a/tests/tset_d.c +++ b/tests/tset_d.c @@ -46,6 +46,7 @@ main (int argc, char *argv[]) mpfr_set_nan (x); d = mpfr_get_d (x, GMP_RNDN); + MPFR_ASSERTN (DOUBLE_ISNAN (d)); mpfr_set_ui (x, 0, GMP_RNDN); mpfr_set_d (x, d, GMP_RNDN); MPFR_ASSERTN(mpfr_nan_p (x)); @@ -166,3 +167,7 @@ main (int argc, char *argv[]) tests_end_mpfr (); return 0; } + + + + diff --git a/tests/tset_q.c b/tests/tset_q.c index 02853c5e6..6dc01bb77 100644 --- a/tests/tset_q.c +++ b/tests/tset_q.c @@ -41,7 +41,7 @@ check (long int n, long int d, mp_rnd_t rnd, const char *ys) /* check values */ if (mpfr_cmp_str1(x, ys)) { - printf ("Error for q=%ld/%lu and rnd=%s\n", n, d, + printf ("Error for q=%ld/%ld and rnd=%s\n", n, d, mpfr_print_rnd_mode (rnd)); printf ("correct result is %s, mpfr_set_q gives ", ys); mpfr_out_str(stdout, 10, 0, x, GMP_RNDN); diff --git a/tests/tset_str.c b/tests/tset_str.c index 4fc8a6463..52beb6982 100644 --- a/tests/tset_str.c +++ b/tests/tset_str.c @@ -110,7 +110,7 @@ main (int argc, char *argv[]) *(str2++) = '.'; for (k = 1; k < nc - 17 - bd; k++) - *(str2++) = '0' + (randlimb () & 1); + *(str2++) = '0' + (char) (randlimb () & 1); *(str2++) = 'e'; sprintf (str2, "%d", (int) (randlimb () & INT_MAX) + INT_MIN/2); @@ -450,7 +450,7 @@ main (int argc, char *argv[]) if (mpfr_cmp (x, y) != 0) { - printf ("Error in mpfr_set_str for nb_digit=%u, base=%u, " + printf ("Error in mpfr_set_str for nb_digit=%u, base=%d, " "rnd=%s:\n", (unsigned int) nb_digit, base[cbase], mpfr_print_rnd_mode (rnd[crnd])); printf ("instead of: "); diff --git a/tests/tstrtofr.c b/tests/tstrtofr.c index a3f8347ed..f3f14717e 100644 --- a/tests/tstrtofr.c +++ b/tests/tstrtofr.c @@ -27,10 +27,6 @@ MA 02111-1307, USA. */ #include "mpfr-test.h" -int -mpfr_strtofr (mpfr_t x, const char *string, char **end, unsigned int base, - mp_rnd_t rnd); - static void check_reftable (void); static void check_special (void); static void check_retval (void); @@ -225,7 +221,7 @@ int main() } #endif -struct dymmy_test { +static struct dymmy_test { mp_prec_t prec; int base; const char *str; |