From: Bruno Haible Date: Tue, 28 Feb 2012 10:50:03 +0000 (+0100) Subject: Avoid compilation errors with MSVC option -fp:strict. X-Git-Tag: v0.1~1020 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=ab1bdfa5247c71e8a0f34e44e6cab5dde9397e72;p=gnulib.git Avoid compilation errors with MSVC option -fp:strict. * lib/floor.c: Use MSVC specific pragma fenv_access. * lib/ceil.c: Likewise. * lib/trunc.c: Likewise. * lib/round.c: Likewise. * lib/rint.c: Likewise. * lib/fma.c: Likewise. * lib/integer_length.c: Likewise. * m4/round.m4 (gl_FUNC_ROUND): Likewise. * m4/roundf.m4 (gl_FUNC_ROUNDF): Likewise. * tests/test-floor2.c: Likewise. * tests/test-floorf2.c: Likewise. * tests/test-ceil2.c: Likewise. * tests/test-ceilf2.c: Likewise. * tests/test-trunc2.c: Likewise. * tests/test-truncf2.c: Likewise. Reported by Michael Goffioul . --- diff --git a/ChangeLog b/ChangeLog index 686f0a69cf..9e2c0cfcff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2012-02-28 Bruno Haible + + Avoid compilation errors with MSVC option -fp:strict. + * lib/floor.c: Use MSVC specific pragma fenv_access. + * lib/ceil.c: Likewise. + * lib/trunc.c: Likewise. + * lib/round.c: Likewise. + * lib/rint.c: Likewise. + * lib/fma.c: Likewise. + * lib/integer_length.c: Likewise. + * m4/round.m4 (gl_FUNC_ROUND): Likewise. + * m4/roundf.m4 (gl_FUNC_ROUNDF): Likewise. + * tests/test-floor2.c: Likewise. + * tests/test-floorf2.c: Likewise. + * tests/test-ceil2.c: Likewise. + * tests/test-ceilf2.c: Likewise. + * tests/test-trunc2.c: Likewise. + * tests/test-truncf2.c: Likewise. + Reported by Michael Goffioul . + 2012-02-27 Bruno Haible Tests for module 'sqrtl-ieee'. diff --git a/lib/ceil.c b/lib/ceil.c index 7a05acee94..c3d26c1bf2 100644 --- a/lib/ceil.c +++ b/lib/ceil.c @@ -54,6 +54,12 @@ # define MINUS_ZERO L_(-0.0) #endif +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + /* 2^(MANT_DIG-1). */ static const DOUBLE TWO_MANT_DIG = /* Assume MANT_DIG <= 5 * 31. diff --git a/lib/floor.c b/lib/floor.c index 86ae3ac8b4..9f4c951c81 100644 --- a/lib/floor.c +++ b/lib/floor.c @@ -42,6 +42,12 @@ # define L_(literal) literal##f #endif +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + /* 2^(MANT_DIG-1). */ static const DOUBLE TWO_MANT_DIG = /* Assume MANT_DIG <= 5 * 31. diff --git a/lib/fma.c b/lib/fma.c index b37f7ebb6b..9882e88498 100644 --- a/lib/fma.c +++ b/lib/fma.c @@ -66,6 +66,12 @@ #undef MIN #define MIN(a,b) ((a) < (b) ? (a) : (b)) +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + /* It is possible to write an implementation of fused multiply-add with floating-point operations alone. See Sylvie Boldo, Guillaume Melquiond: diff --git a/lib/integer_length.c b/lib/integer_length.c index 0719ff3c4d..d89df69fea 100644 --- a/lib/integer_length.c +++ b/lib/integer_length.c @@ -25,6 +25,12 @@ #include "float+.h" +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + #define NBITS (sizeof (unsigned int) * CHAR_BIT) int diff --git a/lib/rint.c b/lib/rint.c index 822e67158f..6da390a03b 100644 --- a/lib/rint.c +++ b/lib/rint.c @@ -53,6 +53,12 @@ # define MINUS_ZERO L_(-0.0) #endif +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + DOUBLE RINT (DOUBLE x) { diff --git a/lib/round.c b/lib/round.c index 0933484070..b52bd35858 100644 --- a/lib/round.c +++ b/lib/round.c @@ -64,6 +64,12 @@ # define MINUS_ZERO L_(-0.0) #endif +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + /* If we're being included from test-round2[f].c, it already defined names for our round implementations. Otherwise, pick the preferred implementation for this machine. */ diff --git a/lib/trunc.c b/lib/trunc.c index 0049cdd998..27c881c30c 100644 --- a/lib/trunc.c +++ b/lib/trunc.c @@ -54,6 +54,12 @@ # define MINUS_ZERO L_(-0.0) #endif +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + /* 2^(MANT_DIG-1). */ static const DOUBLE TWO_MANT_DIG = /* Assume MANT_DIG <= 5 * 31. diff --git a/m4/round.m4 b/m4/round.m4 index c97f435486..e2acf93669 100644 --- a/m4/round.m4 +++ b/m4/round.m4 @@ -1,4 +1,4 @@ -# round.m4 serial 13 +# round.m4 serial 14 dnl Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -25,6 +25,9 @@ AC_DEFUN([gl_FUNC_ROUND], AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif int main() { /* 2^DBL_MANT_DIG. */ diff --git a/m4/roundf.m4 b/m4/roundf.m4 index ffacba705d..58f4287bb8 100644 --- a/m4/roundf.m4 +++ b/m4/roundf.m4 @@ -1,4 +1,4 @@ -# roundf.m4 serial 14 +# roundf.m4 serial 15 dnl Copyright (C) 2007-2012 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -25,6 +25,9 @@ AC_DEFUN([gl_FUNC_ROUNDF], AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif int main() { /* 2^FLT_MANT_DIG. */ diff --git a/tests/test-ceil2.c b/tests/test-ceil2.c index 31baeb8b84..bff6730a5f 100644 --- a/tests/test-ceil2.c +++ b/tests/test-ceil2.c @@ -32,6 +32,12 @@ #include "minus-zero.h" #include "macros.h" +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + /* The reference implementation, taken from lib/ceil.c. */ diff --git a/tests/test-ceilf2.c b/tests/test-ceilf2.c index 69fdb67b1c..189de0f9a0 100644 --- a/tests/test-ceilf2.c +++ b/tests/test-ceilf2.c @@ -32,6 +32,12 @@ #include "minus-zero.h" #include "macros.h" +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + /* The reference implementation, taken from lib/ceil.c. */ diff --git a/tests/test-floor2.c b/tests/test-floor2.c index 292fbc5a80..19e5ab17f3 100644 --- a/tests/test-floor2.c +++ b/tests/test-floor2.c @@ -31,6 +31,12 @@ #include "isnand-nolibm.h" #include "macros.h" +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + /* The reference implementation, taken from lib/floor.c. */ diff --git a/tests/test-floorf2.c b/tests/test-floorf2.c index 1413778b15..beaf70bb94 100644 --- a/tests/test-floorf2.c +++ b/tests/test-floorf2.c @@ -31,6 +31,12 @@ #include "isnanf-nolibm.h" #include "macros.h" +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + /* The reference implementation, taken from lib/floor.c. */ diff --git a/tests/test-trunc2.c b/tests/test-trunc2.c index 3b15799a92..61f88b5e81 100644 --- a/tests/test-trunc2.c +++ b/tests/test-trunc2.c @@ -32,6 +32,12 @@ #include "minus-zero.h" #include "macros.h" +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + /* The reference implementation, taken from lib/trunc.c. */ diff --git a/tests/test-truncf2.c b/tests/test-truncf2.c index 96ba9a1bec..3b67d753ab 100644 --- a/tests/test-truncf2.c +++ b/tests/test-truncf2.c @@ -32,6 +32,12 @@ #include "minus-zero.h" #include "macros.h" +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + /* The reference implementation, taken from lib/trunc.c. */