Fix math/test-misc.c for undefined fenv.h macros.

math/test-misc.c contains some code that uses fenv.h macros
FE_UNDERFLOW, FE_OVERFLOW and FE_UPWARD without being conditional on
those macros being defined.

That would normally break the build for configurations (typically
soft-float) not defining those macros.  However, the code in question
is inside LDBL_MANT_DIG > DBL_MANT_DIG conditionals.  And, while we
have configurations lacking rounding mode and exception support where
LDBL_MANT_DIG > DBL_MANT_DIG (soft-float MIPS64 and RISC-V), those
configurations currently define the fenv.h macros in question even for
soft-float.

There may be some case for defining those macros in cases where a
soft-float compilation could use a hard-float libm (where both
soft-float and hard-float can use the same ABI, as on ARM and RISC-V,
for example).  But MIPS is not such a case - the hard-float and
soft-float ABIs are incompatible - and thus I am testing a patch to
stop defining those macros for soft-float MIPS (motivated by reducing
the extent to which architectures need their own definitions of
math-tests.h macros - if lack of rounding mode / exception support can
be determined by the lack of macros in fenv.h, that avoids the need
for math-tests.h to declare that lack as well).  Introducing a case of
LDBL_MANT_DIG > DBL_MANT_DIG without these macros defined shows up the
problem with math/test-misc.c.  This patch then fixes that problem by
adding appropriate conditionals.

Tested for MIPS64 in conjunction with changes to stop defining the
macros in question in bits/fenv.h for soft-float.

	* math/test-misc.c (do_test) [LDBL_MANT_DIG > DBL_MANT_DIG]: Make
	code using FE_UNDERFLOW conditional on [FE_UNDERFLOW], code using
	FE_OVERFLOW conditional on [FE_OVERFLOW] and code using FE_UPWARD
	conditional on [FE_UPWARD].
This commit is contained in:
Joseph Myers 2018-08-01 22:22:00 +00:00
parent fa67ba06ee
commit f6dcefbe60
2 changed files with 13 additions and 0 deletions

View File

@ -1,3 +1,10 @@
2018-08-01 Joseph Myers <joseph@codesourcery.com>
* math/test-misc.c (do_test) [LDBL_MANT_DIG > DBL_MANT_DIG]: Make
code using FE_UNDERFLOW conditional on [FE_UNDERFLOW], code using
FE_OVERFLOW conditional on [FE_OVERFLOW] and code using FE_UPWARD
conditional on [FE_UPWARD].
2018-08-01 Paul Eggert <eggert@cs.ucla.edu>
regex: fix memory leak in Gnulib

View File

@ -976,11 +976,13 @@ do_test (void)
puts ("scalbl (LDBL_MIN, 2147483647) returns -Inf");
result = 1;
}
# ifdef FE_UNDERFLOW
else if (fetestexcept (FE_UNDERFLOW))
{
puts ("scalbl (LDBL_MIN, 2147483647) raises underflow exception");
result = 1;
}
# endif
feclearexcept (FE_ALL_EXCEPT);
r = scalbl (LDBL_MAX, -2147483647);
@ -994,11 +996,13 @@ do_test (void)
puts ("scalbl (LDBL_MAX, -2147483647) returns -Inf");
result = 1;
}
# ifdef FE_OVERFLOW
else if (fetestexcept (FE_OVERFLOW))
{
puts ("scalbl (LDBL_MAX, -2147483647) raises overflow exception");
result = 1;
}
# endif
}
#endif
@ -1178,6 +1182,7 @@ do_test (void)
}
}
# ifdef FE_UPWARD
volatile long double ld7 = nextafterl (0.0L, 1.0L);
volatile double d7;
(void) &ld7;
@ -1195,6 +1200,7 @@ do_test (void)
else
puts ("ignoring this failure");
}
# endif
# endif
#endif