@@ -585,7 +585,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
@@ -610,7 +617,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") {
@@ -696,14 +703,12 @@ sub get_all_ulps_for_test {
my ($ldouble, $double, $float, $ildouble, $idouble, $ifloat);
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)";
+ my $choose_str = "CHOOSE (";
+ foreach $float (@all_floats) {
+ $choose_str .= &get_ulps ($test, $type, $float) . ", ";
+ }
+ $choose_str = substr ($choose_str, 0, -2) . ")";
+ return $choose_str;
} else {
die "get_all_ulps_for_test called for \"$test\" with no ulps\n";
}
@@ -712,7 +717,7 @@ sub get_all_ulps_for_test {
# Print include file
sub output_ulps {
my ($file, $ulps_filename) = @_;
- my ($i, $fct, $type, $ulp, $ulp_real, $ulp_imag);
+ my ($i, $fct, $type, $ulp, $ulp_real, $ulp_imag, $choose);
my (%func_ulps, %func_real_ulps, %func_imag_ulps);
open ULP, ">$file" or die ("Can't open $file: $!");
@@ -721,6 +726,25 @@ 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";
+ # Declare all the possible CHOOSE() variants based on the type being tested
+ # and whether inline functions are being tested.
+ $choose = "CHOOSE(C$all_floats[0]";
+ for ($i = 1; $i <= $#all_floats; $i++) {
+ $choose .= ", C" . $all_floats[$i];
+ }
+ $choose .= ")";
+ foreach my $type (@all_floats) {
+ if ($type =~ /^i/) {
+ $type = substr ($type, 1);
+ print ULP "#if defined TEST_" . uc ($type) . " && TEST_INLINE\n";
+ print ULP "# define " . $choose . " Ci$type\n";
+ } else {
+ print ULP "#if defined TEST_" . uc ($type) . " && !TEST_INLINE\n";
+ print ULP "# define " . $choose . " C$type\n";
+ }
+ print ULP "#endif\n";
+ }
+
foreach $fct (keys %results) {
$type = $results{$fct}{'type'};
if ($type eq 'normal') {
@@ -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
@@ -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"
@@ -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)
@@ -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)
@@ -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)
@@ -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"
@@ -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"
@@ -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)
@@ -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)
@@ -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)
@@ -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"
@@ -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"
@@ -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"
@@ -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"
@@ -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"
@@ -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"