]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - math/libm-test-support.c
Add test infrastructure for narrowing libm functions.
[thirdparty/glibc.git] / math / libm-test-support.c
index 2e4f9ef926fd584c084b49d844c2ee3333be5ad2..e59f15b4d9829200101130bc17c39f82add0d113 100644 (file)
@@ -135,6 +135,7 @@ static int verbose;
 static int output_max_error;   /* Should the maximal errors printed?  */
 static int output_points;      /* Should the single function results printed?  */
 static int ignore_max_ulp;     /* Should we ignore max_ulp?  */
+static int test_ibm128;                /* Is argument or result IBM long double?  */
 
 static FLOAT max_error, real_max_error, imag_max_error;
 
@@ -212,11 +213,12 @@ find_ulps (const char *name, const struct ulp_data *data, size_t nmemb)
 }
 
 void
-init_max_error (const char *name, int exact)
+init_max_error (const char *name, int exact, int testing_ibm128)
 {
   max_error = 0;
   real_max_error = 0;
   imag_max_error = 0;
+  test_ibm128 = testing_ibm128;
   prev_max_error = find_ulps (name, func_ulps,
                              sizeof (func_ulps) / sizeof (func_ulps[0]));
   prev_real_max_error = find_ulps (name, func_real_ulps,
@@ -225,15 +227,14 @@ init_max_error (const char *name, int exact)
   prev_imag_max_error = find_ulps (name, func_imag_ulps,
                                   (sizeof (func_imag_ulps)
                                    / sizeof (func_imag_ulps[0])));
-#if TEST_COND_ibm128
-  /* The documented accuracy of IBM long double division is 3ulp (see
-     libgcc/config/rs6000/ibm-ldouble-format), so do not require
-     better accuracy for libm functions that are exactly defined for
-     other formats.  */
-  max_valid_error = exact ? 3 : 16;
-#else
-  max_valid_error = exact ? 0 : 9;
-#endif
+  if (testing_ibm128)
+    /* The documented accuracy of IBM long double division is 3ulp
+       (see libgcc/config/rs6000/ibm-ldouble-format), so do not
+       require better accuracy for libm functions that are exactly
+       defined for other formats.  */
+    max_valid_error = exact ? 3 : 16;
+  else
+    max_valid_error = exact ? 0 : 9;
   prev_max_error = (prev_max_error <= max_valid_error
                    ? prev_max_error
                    : max_valid_error);
@@ -518,14 +519,14 @@ test_exceptions (const char *test_name, int exception)
         arithmetic.  */
 #ifdef FE_UNDERFLOW
       if ((exception & UNDERFLOW_EXCEPTION_OK) == 0
-         && !(TEST_COND_ibm128
+         && !(test_ibm128
               && (exception & UNDERFLOW_EXCEPTION) == 0))
        test_single_exception (test_name, exception, UNDERFLOW_EXCEPTION,
                               FE_UNDERFLOW, "Underflow");
 #endif
 #ifdef FE_INEXACT
       if ((exception & (INEXACT_EXCEPTION | NO_INEXACT_EXCEPTION)) != 0
-         && !(TEST_COND_ibm128
+         && !(test_ibm128
               && (exception & NO_INEXACT_EXCEPTION) != 0))
        test_single_exception (test_name, exception, INEXACT_EXCEPTION,
                               FE_INEXACT, "Inexact");