Make small changes to libm-test.c to improve portability.

- Don't define llabs(). This breaks if llabs() is already a macro, which
  is allowed by the C standard/POSIX. llabs() was introduced in C99, so
  I think we can safely assume it is present on all interesting systems.

- Cast the parameters to fabs() to the floating point type. Clang has
  introduced some interesting warnings that trigger if the arguments to
  fabs*() are not the right type.
This commit is contained in:
Ed Schouten 2015-02-12 14:15:15 +01:00
parent b6ff8bbe91
commit d64ea4e5f9
1 changed files with 3 additions and 4 deletions

View File

@ -712,7 +712,6 @@ check_longlong (const char *test_name, long long int computed,
test_exceptions (test_name, exceptions);
noTests++;
#define llabs(x) (x < 0 ? -x : x)
if (llabs (diff) <= max_ulp)
ok = 1;
@ -2531,15 +2530,15 @@ fabs_test (void)
{
init_max_error ();
check_float ("fabs (0) == 0", FUNC(fabs) (0), 0, 0, 0, 0);
check_float ("fabs (0) == 0", FUNC(fabs) ((FLOAT)0.0), 0, 0, 0, 0);
check_float ("fabs (-0) == 0", FUNC(fabs) (minus_zero), 0, 0, 0, 0);
check_float ("fabs (inf) == inf", FUNC(fabs) (plus_infty), plus_infty, 0, 0, 0);
check_float ("fabs (-inf) == inf", FUNC(fabs) (minus_infty), plus_infty, 0, 0, 0);
check_float ("fabs (NaN) == NaN", FUNC(fabs) (nan_value), nan_value, 0, 0, 0);
check_float ("fabs (38.0) == 38.0", FUNC(fabs) (38.0), 38.0, 0, 0, 0);
check_float ("fabs (-e) == e", FUNC(fabs) (-M_El), M_El, 0, 0, 0);
check_float ("fabs (38.0) == 38.0", FUNC(fabs) ((FLOAT)38.0), 38.0, 0, 0, 0);
check_float ("fabs (-e) == e", FUNC(fabs) ((FLOAT)-M_El), M_El, 0, 0, 0);
print_max_error ("fabs", 0, 0);
}