From d64ea4e5f97fac82e8d05dd4a47e711a8cf8ca2e Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Thu, 12 Feb 2015 14:15:15 +0100 Subject: [PATCH] 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. --- test/libm-test.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/libm-test.c b/test/libm-test.c index 99f4718..604f13b 100644 --- a/test/libm-test.c +++ b/test/libm-test.c @@ -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); }