diff options
author | Paul E. Murphy <murphyp@linux.vnet.ibm.com> | 2016-06-08 14:37:15 -0500 |
---|---|---|
committer | Paul E. Murphy <murphyp@linux.vnet.ibm.com> | 2016-06-08 14:37:15 -0500 |
commit | 9c665e085f092d2fd1c0c159532d94191b8e2aec (patch) | |
tree | c1603caf0e6366d2e2532c2ebd76c76c5506a890 /math | |
parent | 89385134849a9a4aa66f5b2ebaedaad7d63a11db (diff) | |
download | glibc-9c665e085f092d2fd1c0c159532d94191b8e2aec.tar glibc-9c665e085f092d2fd1c0c159532d94191b8e2aec.tar.gz glibc-9c665e085f092d2fd1c0c159532d94191b8e2aec.tar.bz2 glibc-9c665e085f092d2fd1c0c159532d94191b8e2aec.zip |
Remove CHOOSE() macro from libm-tests.inc
Use gen-libm-test.pl to generate a list of macros
mapping to libm-test-ulps.h as this simplifies adding new
types without having to modify a growing number of
static headers each time a type is added.
This also removes the final usage of the TEST_(DOUBLE|FLOAT|LDOUBLE)
macros. Thus, they too are removed.
Diffstat (limited to 'math')
-rwxr-xr-x | math/gen-libm-test.pl | 49 | ||||
-rw-r--r-- | math/libm-test.inc | 13 | ||||
-rw-r--r-- | math/test-double-finite.c | 1 | ||||
-rw-r--r-- | math/test-double-vlen2.h | 1 | ||||
-rw-r--r-- | math/test-double-vlen4.h | 1 | ||||
-rw-r--r-- | math/test-double-vlen8.h | 1 | ||||
-rw-r--r-- | math/test-double.c | 1 | ||||
-rw-r--r-- | math/test-double.h | 1 | ||||
-rw-r--r-- | math/test-float-finite.c | 1 | ||||
-rw-r--r-- | math/test-float-vlen16.h | 1 | ||||
-rw-r--r-- | math/test-float-vlen4.h | 1 | ||||
-rw-r--r-- | math/test-float-vlen8.h | 1 | ||||
-rw-r--r-- | math/test-float.c | 1 | ||||
-rw-r--r-- | math/test-float.h | 1 | ||||
-rw-r--r-- | math/test-idouble.c | 1 | ||||
-rw-r--r-- | math/test-ifloat.c | 1 | ||||
-rw-r--r-- | math/test-ildoubl.c | 1 | ||||
-rw-r--r-- | math/test-ldouble-finite.c | 1 | ||||
-rw-r--r-- | math/test-ldouble.c | 1 | ||||
-rw-r--r-- | math/test-ldouble.h | 1 |
20 files changed, 41 insertions, 39 deletions
diff --git a/math/gen-libm-test.pl b/math/gen-libm-test.pl index 9d0fc006ba..9cdcc4343a 100755 --- a/math/gen-libm-test.pl +++ b/math/gen-libm-test.pl @@ -39,7 +39,7 @@ use strict; use vars qw ($input $output $auto_input); use vars qw (%results); -use vars qw (%beautify @all_floats); +use vars qw (%beautify @all_floats %all_floats_pfx); use vars qw ($output_dir $ulps_file $srcdir); use vars qw (%auto_tests); @@ -47,6 +47,13 @@ use vars qw (%auto_tests); @all_floats = ('double', 'float', 'idouble', 'ifloat', 'ildouble', 'ldouble'); +# all_floats_pfx maps C types to their C like prefix for macros. +%all_floats_pfx = + ( "double" => "DBL", + "ldouble" => "LDBL", + "float" => "FLT", + ); + %beautify = ( "minus_zero" => "-0", "plus_zero" => "+0", @@ -586,7 +593,14 @@ sub generate_testfile { # Parse ulps file sub parse_ulps { my ($file) = @_; - my ($test, $type, $float, $eps); + my ($test, $type, $float, $eps, $float_regex); + + # Build a basic regex to match type entries in the + # generated ULPS file. + foreach my $ftype (@all_floats) { + $float_regex .= "|" . $ftype; + } + $float_regex = "^" . substr ($float_regex, 1) . ":"; # $type has the following values: # "normal": No complex variable @@ -611,7 +625,7 @@ sub parse_ulps { ($test) = ($_ =~ /^Function:\s*\"([a-zA-Z0-9_]+)\"/); next; } - if (/^i?(float|double|ldouble):/) { + if (/$float_regex/) { ($float, $eps) = split /\s*:\s*/,$_,2; if ($eps eq "0") { @@ -695,16 +709,13 @@ sub get_ulps { sub get_all_ulps_for_test { my ($test, $type) = @_; my ($ldouble, $double, $float, $ildouble, $idouble, $ifloat); + my ($ulps_str); if (exists $results{$test}{'has_ulps'}) { - # XXX use all_floats (change order!) - $ldouble = &get_ulps ($test, $type, "ldouble"); - $double = &get_ulps ($test, $type, "double"); - $float = &get_ulps ($test, $type, "float"); - $ildouble = &get_ulps ($test, $type, "ildouble"); - $idouble = &get_ulps ($test, $type, "idouble"); - $ifloat = &get_ulps ($test, $type, "ifloat"); - return "CHOOSE ($ldouble, $double, $float, $ildouble, $idouble, $ifloat)"; + foreach $float (@all_floats) { + $ulps_str .= &get_ulps ($test, $type, $float) . ", "; + } + return "{" . substr ($ulps_str, 0, -2) . "}"; } else { die "get_all_ulps_for_test called for \"$test\" with no ulps\n"; } @@ -722,6 +733,22 @@ sub output_ulps { print ULP " from $ulps_filename with gen-libm-test.pl.\n"; print ULP " Don't change it - change instead the master files. */\n\n"; + print ULP "struct ulp_data\n"; + print ULP "{\n"; + print ULP " const char *name;\n"; + print ULP " FLOAT max_ulp[" . @all_floats . "];\n"; + print ULP "};\n\n"; + + for ($i = 0; $i <= $#all_floats; $i++) { + $type = $all_floats[$i]; + print ULP "#define ULP_"; + if ($type =~ /^i/) { + print ULP "I_"; + $type = substr $type, 1; + } + print ULP "$all_floats_pfx{$type} $i\n"; + } + foreach $fct (keys %results) { $type = $results{$fct}{'type'}; if ($type eq 'normal') { diff --git a/math/libm-test.inc b/math/libm-test.inc index 3218cefd7a..ef869a7979 100644 --- a/math/libm-test.inc +++ b/math/libm-test.inc @@ -26,7 +26,6 @@ name with correct suffix (e.g. cosl or cosf) FLOAT: floating point type to test - TEST_MSG: informal message to be displayed - CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat): chooses one of the parameters as delta for testing equality PRINTF_EXPR Floating point conversion specification to print a variable @@ -131,14 +130,6 @@ #include <math-tests.h> #include <math-tests-arch.h> -/* Structure for ulp data for a function, or the real or imaginary - part of a function. */ -struct ulp_data -{ - const char *name; - FLOAT max_ulp; -}; - /* This header defines func_ulps, func_real_ulps and func_imag_ulps arrays. */ #include "libm-test-ulps.h" @@ -202,8 +193,10 @@ struct ulp_data #define FSTR_MAX (128) #if TEST_INLINE +# define ULP_IDX __CONCATX (ULP_I_, PREFIX) # define QTYPE_STR "i" TYPE_STR #else +# define ULP_IDX __CONCATX (ULP_, PREFIX) # define QTYPE_STR TYPE_STR #endif @@ -369,7 +362,7 @@ find_ulps (const char *name, const struct ulp_data *data, size_t nmemb) if (entry == NULL) return 0; else - return entry->max_ulp; + return entry->max_ulp[ULP_IDX]; } static void diff --git a/math/test-double-finite.c b/math/test-double-finite.c index e7fa2a9dd4..7f107aa649 100644 --- a/math/test-double-finite.c +++ b/math/test-double-finite.c @@ -21,6 +21,5 @@ #include "test-math-scalar.h" #define TEST_MSG "testing double (finite-math-only)\n" -#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cdouble #include "libm-test.c" diff --git a/math/test-double-vlen2.h b/math/test-double-vlen2.h index 8a1d0683eb..45351cb254 100644 --- a/math/test-double-vlen2.h +++ b/math/test-double-vlen2.h @@ -21,7 +21,6 @@ #include "test-math-vector.h" #define TEST_MSG "testing double vector math (without inline functions)\n" -#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cdouble #define EXCEPTION_TESTS_double 0 #define ROUNDING_TESTS_double(MODE) ((MODE) == FE_TONEAREST) diff --git a/math/test-double-vlen4.h b/math/test-double-vlen4.h index 40ab58c490..7078893f53 100644 --- a/math/test-double-vlen4.h +++ b/math/test-double-vlen4.h @@ -21,7 +21,6 @@ #include "test-math-vector.h" #define TEST_MSG "testing double vector math (without inline functions)\n" -#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cdouble #define EXCEPTION_TESTS_double 0 #define ROUNDING_TESTS_double(MODE) ((MODE) == FE_TONEAREST) diff --git a/math/test-double-vlen8.h b/math/test-double-vlen8.h index dddb52c008..57168c58cd 100644 --- a/math/test-double-vlen8.h +++ b/math/test-double-vlen8.h @@ -21,7 +21,6 @@ #include "test-math-vector.h" #define TEST_MSG "testing double vector math (without inline functions)\n" -#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cdouble #define EXCEPTION_TESTS_double 0 #define ROUNDING_TESTS_double(MODE) ((MODE) == FE_TONEAREST) diff --git a/math/test-double.c b/math/test-double.c index 2647f66a8c..3f84f40433 100644 --- a/math/test-double.c +++ b/math/test-double.c @@ -23,6 +23,5 @@ #include "test-math-scalar.h" #define TEST_MSG "testing double (without inline functions)\n" -#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cdouble #include "libm-test.c" diff --git a/math/test-double.h b/math/test-double.h index 3667883efc..b9e8cd840c 100644 --- a/math/test-double.h +++ b/math/test-double.h @@ -21,7 +21,6 @@ #define PRINTF_EXPR "e" #define PRINTF_XEXPR "a" #define PRINTF_NEXPR "f" -#define TEST_DOUBLE 1 #define BUILD_COMPLEX(real, imag) (CMPLX ((real), (imag))) #define PREFIX DBL #define LIT(x) (x) diff --git a/math/test-float-finite.c b/math/test-float-finite.c index bd25a7bc31..3f5fe1952f 100644 --- a/math/test-float-finite.c +++ b/math/test-float-finite.c @@ -21,6 +21,5 @@ #include "test-math-scalar.h" #define TEST_MSG "testing float (finite-math-only)\n" -#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cfloat #include "libm-test.c" diff --git a/math/test-float-vlen16.h b/math/test-float-vlen16.h index a2db3a5c4d..d31336a799 100644 --- a/math/test-float-vlen16.h +++ b/math/test-float-vlen16.h @@ -21,7 +21,6 @@ #include "test-math-vector.h" #define TEST_MSG "testing float vector math (without inline functions)\n" -#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cfloat #define EXCEPTION_TESTS_float 0 #define ROUNDING_TESTS_float(MODE) ((MODE) == FE_TONEAREST) diff --git a/math/test-float-vlen4.h b/math/test-float-vlen4.h index 164749d85c..5a88fb857d 100644 --- a/math/test-float-vlen4.h +++ b/math/test-float-vlen4.h @@ -21,7 +21,6 @@ #include "test-math-vector.h" #define TEST_MSG "testing float vector math (without inline functions)\n" -#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cfloat #define EXCEPTION_TESTS_float 0 #define ROUNDING_TESTS_float(MODE) ((MODE) == FE_TONEAREST) diff --git a/math/test-float-vlen8.h b/math/test-float-vlen8.h index ce32df200a..d1e5e6e3d0 100644 --- a/math/test-float-vlen8.h +++ b/math/test-float-vlen8.h @@ -21,7 +21,6 @@ #include "test-math-vector.h" #define TEST_MSG "testing float vector math (without inline functions)\n" -#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cfloat #define EXCEPTION_TESTS_float 0 #define ROUNDING_TESTS_float(MODE) ((MODE) == FE_TONEAREST) diff --git a/math/test-float.c b/math/test-float.c index 153b9ad4dc..6be57bb8a3 100644 --- a/math/test-float.c +++ b/math/test-float.c @@ -23,6 +23,5 @@ #include "test-math-scalar.h" #define TEST_MSG "testing float (without inline functions)\n" -#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cfloat #include "libm-test.c" diff --git a/math/test-float.h b/math/test-float.h index 4f9149f89c..e783c094c9 100644 --- a/math/test-float.h +++ b/math/test-float.h @@ -21,7 +21,6 @@ #define PRINTF_EXPR "e" #define PRINTF_XEXPR "a" #define PRINTF_NEXPR "f" -#define TEST_FLOAT 1 #define BUILD_COMPLEX(real, imag) (CMPLXF ((real), (imag))) #define PREFIX FLT #define TYPE_STR "float" diff --git a/math/test-idouble.c b/math/test-idouble.c index fc1e8f89c1..10a3685b5e 100644 --- a/math/test-idouble.c +++ b/math/test-idouble.c @@ -21,6 +21,5 @@ #include "test-math-scalar.h" #define TEST_MSG "testing double (inline functions)\n" -#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cinlinedouble #include "libm-test.c" diff --git a/math/test-ifloat.c b/math/test-ifloat.c index 72c53ad643..88bb5b844f 100644 --- a/math/test-ifloat.c +++ b/math/test-ifloat.c @@ -21,6 +21,5 @@ #include "test-math-scalar.h" #define TEST_MSG "testing float (inline functions)\n" -#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cinlinefloat #include "libm-test.c" diff --git a/math/test-ildoubl.c b/math/test-ildoubl.c index 08317ed621..dc0efaa879 100644 --- a/math/test-ildoubl.c +++ b/math/test-ildoubl.c @@ -21,6 +21,5 @@ #include "test-math-scalar.h" #define TEST_MSG "testing long double (inline functions)\n" -#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cinlinelongdouble #include "libm-test.c" diff --git a/math/test-ldouble-finite.c b/math/test-ldouble-finite.c index 4c09778ec1..8ac2d335c5 100644 --- a/math/test-ldouble-finite.c +++ b/math/test-ldouble-finite.c @@ -21,6 +21,5 @@ #include "test-math-scalar.h" #define TEST_MSG "testing long double (finite-math-only)\n" -#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Clongdouble #include "libm-test.c" diff --git a/math/test-ldouble.c b/math/test-ldouble.c index 944f6ddfe6..a705fa4aea 100644 --- a/math/test-ldouble.c +++ b/math/test-ldouble.c @@ -23,6 +23,5 @@ #include "test-math-scalar.h" #define TEST_MSG "testing long double (without inline functions)\n" -#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Clongdouble #include "libm-test.c" diff --git a/math/test-ldouble.h b/math/test-ldouble.h index f3a8d8da9f..b877711758 100644 --- a/math/test-ldouble.h +++ b/math/test-ldouble.h @@ -21,7 +21,6 @@ #define PRINTF_EXPR "Le" #define PRINTF_XEXPR "La" #define PRINTF_NEXPR "Lf" -#define TEST_LDOUBLE 1 #define BUILD_COMPLEX(real, imag) (CMPLXL ((real), (imag))) #define PREFIX LDBL #define TYPE_STR "ldouble" |