Remove NO_LONG_DOUBLE conditionals in libm tests (bug 21607).

As noted in bug 21607, NO_LONG_DOUBLE conditionals in libm tests are
no longer effective.  For most this is harmless - they were only
present because of long double functions not being declared with _LIBC
defined, and _LIBC is no longer defined for building most tests.  For
the few where this is actually relevant to the test, testing
LDBL_MANT_DIG > DBL_MANT_DIG is more appropriate as that limits the
test to public APIs.  This patch fixes the tests accordingly.

Tested for x86_64 and arm.

	[BZ #21607]
	* math/basic-test.c [!NO_LONG_DOUBLE]: Change conditionals to
	[LDBL_MANT_DIG > DBL_MANT_DIG].
	* math/bug-nextafter.c [!NO_LONG_DOUBLE]: Remove conditionals.
	* math/bug-nexttoward.c [!NO_LONG_DOUBLE]: Likewise.
	* math/test-math-isinff.cc [!NO_LONG_DOUBLE]: Likewise.
	* math/test-math-iszero.cc [!NO_LONG_DOUBLE]: Likewise.
	* math/test-nan-overflow.c [!NO_LONG_DOUBLE]: Likewise.
	* math/test-nan-payload.c [!NO_LONG_DOUBLE]: Likewise.
	* math/test-nearbyint-except-2.c [!NO_LONG_DOUBLE]: Likewise.
	* math/test-nearbyint-except.c [!NO_LONG_DOUBLE]: Likewise.
	* math/test-powl.c [!NO_LONG_DOUBLE]: Likewise.
	* math/test-signgam-finite-c99.c [!NO_LONG_DOUBLE]: Likewise.
	* math/test-signgam-finite.c [!NO_LONG_DOUBLE]: Likewise.
	* math/test-signgam-main.c [!NO_LONG_DOUBLE]: Likewise.
	* math/test-snan.c [!NO_LONG_DOUBLE]: Likewise.
	* math/test-tgmath-ret.c [!NO_LONG_DOUBLE]: Likewise.
	* math/test-tgmath.c: Include <float.h>.
	[!NO_LONG_DOUBLE]: Change conditionals to [LDBL_MANT_DIG >
	DBL_MANT_DIG].
	* math/test-tgmath2.c: Include <float.h>.
	[!NO_LONG_DOUBLE]: Change conditionals to [LDBL_MANT_DIG >
	DBL_MANT_DIG].
This commit is contained in:
Joseph Myers 2017-06-28 16:01:20 +00:00
parent 2dd0aec531
commit 51737193a9
18 changed files with 36 additions and 48 deletions

View File

@ -1,5 +1,29 @@
2017-06-28 Joseph Myers <joseph@codesourcery.com> 2017-06-28 Joseph Myers <joseph@codesourcery.com>
[BZ #21607]
* math/basic-test.c [!NO_LONG_DOUBLE]: Change conditionals to
[LDBL_MANT_DIG > DBL_MANT_DIG].
* math/bug-nextafter.c [!NO_LONG_DOUBLE]: Remove conditionals.
* math/bug-nexttoward.c [!NO_LONG_DOUBLE]: Likewise.
* math/test-math-isinff.cc [!NO_LONG_DOUBLE]: Likewise.
* math/test-math-iszero.cc [!NO_LONG_DOUBLE]: Likewise.
* math/test-nan-overflow.c [!NO_LONG_DOUBLE]: Likewise.
* math/test-nan-payload.c [!NO_LONG_DOUBLE]: Likewise.
* math/test-nearbyint-except-2.c [!NO_LONG_DOUBLE]: Likewise.
* math/test-nearbyint-except.c [!NO_LONG_DOUBLE]: Likewise.
* math/test-powl.c [!NO_LONG_DOUBLE]: Likewise.
* math/test-signgam-finite-c99.c [!NO_LONG_DOUBLE]: Likewise.
* math/test-signgam-finite.c [!NO_LONG_DOUBLE]: Likewise.
* math/test-signgam-main.c [!NO_LONG_DOUBLE]: Likewise.
* math/test-snan.c [!NO_LONG_DOUBLE]: Likewise.
* math/test-tgmath-ret.c [!NO_LONG_DOUBLE]: Likewise.
* math/test-tgmath.c: Include <float.h>.
[!NO_LONG_DOUBLE]: Change conditionals to [LDBL_MANT_DIG >
DBL_MANT_DIG].
* math/test-tgmath2.c: Include <float.h>.
[!NO_LONG_DOUBLE]: Change conditionals to [LDBL_MANT_DIG >
DBL_MANT_DIG].
* math/gen-tgmath-tests.py: New file. * math/gen-tgmath-tests.py: New file.
* math/Makefile [PYTHON] (tests): Add test-tgmath3. * math/Makefile [PYTHON] (tests): Add test-tgmath3.
[PYTHON] (generated): Add test-tgmath3.c. [PYTHON] (generated): Add test-tgmath3.c.

View File

@ -191,7 +191,7 @@ TEST_FUNC (float_test, float, f, FLT_EPSILON, HUGE_VALF)
TEST_FUNC (double_test, double, , DBL_EPSILON, HUGE_VAL) TEST_FUNC (double_test, double, , DBL_EPSILON, HUGE_VAL)
TEST_CONVERT (convert_dfsf_test, float, double, ) TEST_CONVERT (convert_dfsf_test, float, double, )
TEST_CONVERT (convert_sfdf_test, double, float, f) TEST_CONVERT (convert_sfdf_test, double, float, f)
#ifndef NO_LONG_DOUBLE #if LDBL_MANT_DIG > DBL_MANT_DIG
TEST_FUNC (ldouble_test, long double, l, LDBL_EPSILON, HUGE_VALL) TEST_FUNC (ldouble_test, long double, l, LDBL_EPSILON, HUGE_VALL)
TEST_CONVERT (convert_tfsf_test, float, long double, l) TEST_CONVERT (convert_tfsf_test, float, long double, l)
TEST_CONVERT (convert_sftf_test, long double, float, f) TEST_CONVERT (convert_sftf_test, long double, float, f)
@ -207,7 +207,7 @@ do_test (void)
convert_dfsf_test(); convert_dfsf_test();
convert_sfdf_test(); convert_sfdf_test();
#ifndef NO_LONG_DOUBLE #if LDBL_MANT_DIG > DBL_MANT_DIG
ldouble_test (); ldouble_test ();
convert_tfsf_test(); convert_tfsf_test();
convert_sftf_test(); convert_sftf_test();

View File

@ -219,7 +219,6 @@ main (void)
++result; ++result;
} }
#ifndef NO_LONG_DOUBLE
long double li = INFINITY; long double li = INFINITY;
long double lm = LDBL_MAX; long double lm = LDBL_MAX;
feclearexcept (FE_ALL_EXCEPT); feclearexcept (FE_ALL_EXCEPT);
@ -319,7 +318,6 @@ main (void)
puts ("nextafterl- did not underflow"); puts ("nextafterl- did not underflow");
++result; ++result;
} }
#endif
return result; return result;
} }

View File

@ -221,7 +221,6 @@ main (void)
++result; ++result;
} }
#ifndef NO_LONG_DOUBLE
long double li = INFINITY; long double li = INFINITY;
long double lm = LDBL_MAX; long double lm = LDBL_MAX;
feclearexcept (FE_ALL_EXCEPT); feclearexcept (FE_ALL_EXCEPT);
@ -321,7 +320,6 @@ main (void)
puts ("nexttowardl- did not underflow"); puts ("nexttowardl- did not underflow");
++result; ++result;
} }
#endif
return result; return result;
} }

View File

@ -30,16 +30,12 @@ do_test (void)
header fix this test will not compile. */ header fix this test will not compile. */
if (isinff (1.0f) if (isinff (1.0f)
|| !isinff (INFINITY) || !isinff (INFINITY)
#ifndef NO_LONG_DOUBLE
|| isinfl (1.0L) || isinfl (1.0L)
|| !isinfl (INFINITY) || !isinfl (INFINITY)
#endif
|| isnanf (2.0f) || isnanf (2.0f)
|| !isnanf (NAN) || !isnanf (NAN)
#ifndef NO_LONG_DOUBLE
|| isnanl (2.0L) || isnanl (2.0L)
|| !isnanl (NAN) || !isnanl (NAN)
#endif
) )
{ {
printf ("FAIL: Failed to call is* functions.\n"); printf ("FAIL: Failed to call is* functions.\n");

View File

@ -77,9 +77,7 @@ do_test (void)
{ {
check_type<float> (); check_type<float> ();
check_type<double> (); check_type<double> ();
#ifndef NO_LONG_DOUBLE
check_type<long double> (); check_type<long double> ();
#endif
return errors; return errors;
} }

View File

@ -57,9 +57,7 @@ do_test (void)
while (0) while (0)
NAN_TEST (float, nanf); NAN_TEST (float, nanf);
NAN_TEST (double, nan); NAN_TEST (double, nan);
#ifndef NO_LONG_DOUBLE
NAN_TEST (long double, nanl); NAN_TEST (long double, nanl);
#endif
return result; return result;
} }

View File

@ -112,9 +112,7 @@ do_test (void)
int result = 0; int result = 0;
RUN_TESTS (float, strtof, nanf, FLT_MANT_DIG); RUN_TESTS (float, strtof, nanf, FLT_MANT_DIG);
RUN_TESTS (double, strtod, nan, DBL_MANT_DIG); RUN_TESTS (double, strtod, nan, DBL_MANT_DIG);
#ifndef NO_LONG_DOUBLE
RUN_TESTS (long double, strtold, nanl, LDBL_MANT_DIG); RUN_TESTS (long double, strtold, nanl, LDBL_MANT_DIG);
#endif
return result; return result;
} }

View File

@ -46,9 +46,7 @@ NAME (void) \
TEST_FUNC (float_test, float, f) TEST_FUNC (float_test, float, f)
TEST_FUNC (double_test, double, ) TEST_FUNC (double_test, double, )
#ifndef NO_LONG_DOUBLE
TEST_FUNC (ldouble_test, long double, l) TEST_FUNC (ldouble_test, long double, l)
#endif
static int static int
do_test (void) do_test (void)
@ -61,10 +59,8 @@ do_test (void)
int result = float_test (); int result = float_test ();
feenableexcept (FE_INEXACT); feenableexcept (FE_INEXACT);
result |= double_test (); result |= double_test ();
#ifndef NO_LONG_DOUBLE
feenableexcept (FE_INEXACT); feenableexcept (FE_INEXACT);
result |= ldouble_test (); result |= ldouble_test ();
#endif
return result; return result;
} }

View File

@ -69,18 +69,14 @@ NAME (void) \
TEST_FUNC (float_test, float, f) TEST_FUNC (float_test, float, f)
TEST_FUNC (double_test, double, ) TEST_FUNC (double_test, double, )
#ifndef NO_LONG_DOUBLE
TEST_FUNC (ldouble_test, long double, l) TEST_FUNC (ldouble_test, long double, l)
#endif
static int static int
do_test (void) do_test (void)
{ {
int result = float_test (); int result = float_test ();
result |= double_test (); result |= double_test ();
#ifndef NO_LONG_DOUBLE
result |= ldouble_test (); result |= ldouble_test ();
#endif
if (!any_supported) if (!any_supported)
return 77; return 77;
return result; return result;

View File

@ -26,7 +26,6 @@ do_test (void)
{ {
int result = 0; int result = 0;
#ifndef NO_LONG_DOUBLE
#if LDBL_MANT_DIG == 64 #if LDBL_MANT_DIG == 64
{ {
long double x = 1e-20; long double x = 1e-20;
@ -43,7 +42,6 @@ do_test (void)
result = 1; result = 1;
} }
} }
# endif
#endif #endif
return result; return result;

View File

@ -59,8 +59,6 @@ main (void)
int result = 0; int result = 0;
RUN_TESTS (lgammaf, float); RUN_TESTS (lgammaf, float);
RUN_TESTS (lgamma, double); RUN_TESTS (lgamma, double);
#ifndef NO_LONG_DOUBLE
RUN_TESTS (lgammal, long double); RUN_TESTS (lgammal, long double);
#endif
return result; return result;
} }

View File

@ -54,10 +54,8 @@ do_test (void)
RUN_TESTS (gammaf, float); RUN_TESTS (gammaf, float);
RUN_TESTS (lgamma, double); RUN_TESTS (lgamma, double);
RUN_TESTS (gamma, double); RUN_TESTS (gamma, double);
#ifndef NO_LONG_DOUBLE
RUN_TESTS (lgammal, long double); RUN_TESTS (lgammal, long double);
RUN_TESTS (gammal, long double); RUN_TESTS (gammal, long double);
#endif
return result; return result;
} }

View File

@ -64,8 +64,6 @@ main (void)
int result = 0; int result = 0;
RUN_TESTS (lgammaf, float); RUN_TESTS (lgammaf, float);
RUN_TESTS (lgamma, double); RUN_TESTS (lgamma, double);
#ifndef NO_LONG_DOUBLE
RUN_TESTS (lgammal, long double); RUN_TESTS (lgammal, long double);
#endif
return result; return result;
} }

View File

@ -123,9 +123,7 @@ NAME (void) \
TEST_FUNC (float_test, float, f) TEST_FUNC (float_test, float, f)
TEST_FUNC (double_test, double, ) TEST_FUNC (double_test, double, )
#ifndef NO_LONG_DOUBLE
TEST_FUNC (ldouble_test, long double, l) TEST_FUNC (ldouble_test, long double, l)
#endif
static int static int
do_test (void) do_test (void)
@ -134,9 +132,7 @@ do_test (void)
float_test (); float_test ();
double_test (); double_test ();
#ifndef NO_LONG_DOUBLE
ldouble_test (); ldouble_test ();
#endif
return errors != 0; return errors != 0;
} }

View File

@ -47,12 +47,8 @@ our_error (const char *c)
CHECK_RET_CONST_TYPE (func, rettype, fx, float, ## __VA_ARGS__) CHECK_RET_CONST_TYPE (func, rettype, fx, float, ## __VA_ARGS__)
#define CHECK_RET_CONST_DOUBLE(func, rettype, ...) \ #define CHECK_RET_CONST_DOUBLE(func, rettype, ...) \
CHECK_RET_CONST_TYPE (func, rettype, dx, double, ## __VA_ARGS__) CHECK_RET_CONST_TYPE (func, rettype, dx, double, ## __VA_ARGS__)
#ifdef NO_LONG_DOUBLE
# define CHECK_RET_CONST_LDOUBLE(func, rettype, ...)
#else
#define CHECK_RET_CONST_LDOUBLE(func, rettype, ...) \ #define CHECK_RET_CONST_LDOUBLE(func, rettype, ...) \
CHECK_RET_CONST_TYPE (func, rettype, lx, long double, ## __VA_ARGS__) CHECK_RET_CONST_TYPE (func, rettype, lx, long double, ## __VA_ARGS__)
#endif
#define CHECK_RET_CONST(func, rettype, ...) \ #define CHECK_RET_CONST(func, rettype, ...) \
static void \ static void \

View File

@ -21,6 +21,7 @@
#ifndef HAVE_MAIN #ifndef HAVE_MAIN
#undef __NO_MATH_INLINES #undef __NO_MATH_INLINES
#define __NO_MATH_INLINES 1 #define __NO_MATH_INLINES 1
#include <float.h>
#include <math.h> #include <math.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
@ -30,7 +31,7 @@
static void compile_test (void); static void compile_test (void);
static void compile_testf (void); static void compile_testf (void);
#ifndef NO_LONG_DOUBLE #if LDBL_MANT_DIG > DBL_MANT_DIG
static void compile_testl (void); static void compile_testl (void);
#endif #endif
@ -135,7 +136,7 @@ do_test (void)
result = 1; result = 1;
} }
#ifndef NO_LONG_DOUBLE #if LDBL_MANT_DIG > DBL_MANT_DIG
count_float = count_double = count_ldouble = 0; count_float = count_double = count_ldouble = 0;
count_cfloat = count_cdouble = count_cldouble = 0; count_cfloat = count_cdouble = count_cldouble = 0;
compile_testl (); compile_testl ();
@ -200,7 +201,7 @@ do_test (void)
#define ccount count_cfloat #define ccount count_cfloat
#include "test-tgmath.c" #include "test-tgmath.c"
#ifndef NO_LONG_DOUBLE #if LDBL_MANT_DIG > DBL_MANT_DIG
#define F(name) name##l #define F(name) name##l
#define TYPE long double #define TYPE long double
#define x lx #define x lx

View File

@ -20,6 +20,7 @@
#ifndef HAVE_MAIN #ifndef HAVE_MAIN
#undef __NO_MATH_INLINES #undef __NO_MATH_INLINES
#define __NO_MATH_INLINES 1 #define __NO_MATH_INLINES 1
#include <float.h>
#include <math.h> #include <math.h>
#include <complex.h> #include <complex.h>
#include <stdio.h> #include <stdio.h>
@ -30,7 +31,7 @@
typedef complex float cfloat; typedef complex float cfloat;
typedef complex double cdouble; typedef complex double cdouble;
#ifndef NO_LONG_DOUBLE #if LDBL_MANT_DIG > DBL_MANT_DIG
typedef long double ldouble; typedef long double ldouble;
typedef complex long double cldouble; typedef complex long double cldouble;
#else #else
@ -62,7 +63,7 @@ enum
Tcfloat, Tcfloat,
Tdouble, Tdouble,
Tcdouble, Tcdouble,
#ifndef NO_LONG_DOUBLE #if LDBL_MANT_DIG > DBL_MANT_DIG
Tldouble, Tldouble,
Tcldouble, Tcldouble,
#else #else
@ -470,7 +471,7 @@ do_test (void)
#define C Tcfloat #define C Tcfloat
#include "test-tgmath2.c" #include "test-tgmath2.c"
#ifndef NO_LONG_DOUBLE #if LDBL_MANT_DIG > DBL_MANT_DIG
#define F(name) name##l #define F(name) name##l
#define TYPE ldouble #define TYPE ldouble
#define CTYPE cldouble #define CTYPE cldouble