return $rest;
}
-# Adjust an argument or expected value for use in a constant
-# initializer.
-sub adjust_arg {
- my ($arg, $in_func) = @_;
- if (!$in_func) {
- $arg =~ s/(plus_zero|minus_zero|plus_infty|minus_infty|qnan_value
- |max_value|min_value|min_subnorm_value)/\U$1\E_INIT/xg;
- }
- return $arg;
-}
-
# Treat some functions especially.
# Currently only sincos needs extra treatment.
sub special_functions {
- my ($file, $in_func, $args) = @_;
+ my ($file, $args) = @_;
my (@args, $str, $test, $cline);
@args = split /,\s*/, $args;
unless ($args[0] =~ /sincos/) {
die ("Don't know how to handle $args[0] extra.");
}
- if ($in_func) {
- $cline = " RUN_TEST_sincos (" . adjust_arg ($args[1], $in_func);
- } else {
- $cline = " { " . adjust_arg ($args[1], $in_func);
- }
+ $cline = " { $args[1]";
$str = 'sincos (' . &beautify ($args[1]) . ', &sin_res, &cos_res)';
# handle sin
$test = $str . ' puts ' . &beautify ($args[2]) . ' in sin_res';
- my ($sin_res_var) = ($in_func ? ", sin_res" : "");
- $cline .= ", \"$test\"$sin_res_var, " . adjust_arg ($args[2], $in_func);
+ $cline .= ", \"$test\", $args[2]";
$cline .= &new_test ($test, $args[4], 0);
# handle cos
$test = $str . ' puts ' . &beautify ($args[3]) . ' in cos_res';
- my ($cos_res_var) = ($in_func ? ", cos_res" : "");
- $cline .= ", \"$test\"$cos_res_var, " . adjust_arg ($args[3], $in_func);
+ $cline .= ", \"$test\", $args[3]";
$cline .= &new_test ($test, $args[4], 1);
- if ($in_func) {
- $cline .= ");\n";
- } else {
- $cline .= " },\n";
- }
+ $cline .= " },\n";
print $file $cline;
}
# Parse the arguments to TEST_x_y
sub parse_args {
- my ($file, $descr, $fct, $in_func, $args) = @_;
+ my ($file, $descr, $fct, $args) = @_;
my (@args, $str, $descr_args, $descr_res, @descr);
my ($current_arg, $cline, $i);
my (@special);
my ($extra_var, $call);
if ($descr eq 'extra') {
- &special_functions ($file, $in_func, $args);
+ &special_functions ($file, $args);
return;
}
($descr_args, $descr_res) = split /_/,$descr, 2;
# Reset some variables to start again
$current_arg = 1;
$extra_var = 0;
- if ($in_func) {
- $cline = "RUN_TEST_$descr";
- } else {
- $cline = "{ ";
- }
- # Special handling for some macros:
- if ($in_func && $args[0] =~ /fpclassify|isnormal|isfinite|isinf|isnan
- |issignaling|signbit|isgreater|isgreaterequal|isless|islessequal
- |islessgreater|isunordered/x) {
- $cline = "${cline}_tg";
- }
- if ($in_func) {
- $cline .= " (";
- }
- $cline .= "\"$str\"";
- if ($in_func) {
- $cline .= ", $args[0]";
- }
+ $cline = "{ \"$str\"";
@descr = split //,$descr_args;
for ($i=0; $i <= $#descr; $i++) {
# FLOAT, int, long int, long long int
if ($descr[$i] =~ /f|i|l|L/) {
- $cline .= ", " . adjust_arg ($args[$current_arg], $in_func);
+ $cline .= ", $args[$current_arg]";
$current_arg++;
next;
}
}
# complex
if ($descr[$i] eq 'c') {
- $cline .= ", " . adjust_arg ($args[$current_arg], $in_func);
- $cline .= ", " . adjust_arg ($args[$current_arg+1], $in_func);
+ $cline .= ", $args[$current_arg], $args[$current_arg+1]";
$current_arg += 2;
next;
}
@descr = split //,$descr_res;
foreach (@descr) {
if ($_ =~ /b|f|i|l|L/ ) {
- $cline .= adjust_arg ($args[$current_arg], $in_func);
+ $cline .= $args[$current_arg];
$current_arg++;
} elsif ($_ eq 'c') {
- $cline .= adjust_arg ($args[$current_arg], $in_func);
- $cline .= ", " . adjust_arg ($args[$current_arg+1], $in_func);
+ $cline .= "$args[$current_arg], $args[$current_arg+1]";
$current_arg += 2;
} elsif ($_ eq '1') {
push @special, $args[$current_arg];
my ($extra_expected) = $special[0];
my ($run_extra) = ($extra_expected ne "IGNORE" ? 1 : 0);
my ($str) = "$call sets x to $extra_expected";
- my ($out_var) = ($in_func ? ", x" : "");
if (!$run_extra) {
$str = "";
$extra_expected = "0";
}
- $cline .= ", \"$str\"$out_var, 123456789, $run_extra, $extra_expected";
+ $cline .= ", \"$str\", 123456789, $run_extra, $extra_expected";
if ($run_extra) {
$cline .= &new_test ($str, undef, 0);
} else {
my ($extra_expected) = $special[0];
my ($run_extra) = ($extra_expected ne "IGNORE" ? 1 : 0);
my ($str) = "$call sets signgam to $extra_expected";
- my ($out_var) = ($in_func ? ", signgam" : "");
if (!$run_extra) {
$str = "";
$extra_expected = "0";
}
- $cline .= ", \"$str\"$out_var, 0, $run_extra, $extra_expected";
+ $cline .= ", \"$str\", 0, $run_extra, $extra_expected";
if ($run_extra) {
$cline .= &new_test ($str, undef, 0);
} else {
my ($extra_expected) = $special[0];
my ($run_extra) = ($extra_expected ne "IGNORE" ? 1 : 0);
my ($str) = "$call sets x to $extra_expected";
- my ($out_var) = ($in_func ? ", x" : "");
if (!$run_extra) {
$str = "";
$extra_expected = "0";
}
- $extra_expected = adjust_arg ($extra_expected, $in_func);
- $cline .= ", \"$str\"$out_var, 123.456789, $run_extra, $extra_expected";
+ $cline .= ", \"$str\", 123.456789, $run_extra, $extra_expected";
if ($run_extra) {
$cline .= &new_test ($str, undef, 0);
} else {
my ($extra_expected) = $special[0];
my ($run_extra) = ($extra_expected ne "IGNORE" ? 1 : 0);
my ($str) = "$call sets x to $extra_expected";
- my ($out_var) = ($in_func ? ", x" : "");
if (!$run_extra) {
$str = "";
$extra_expected = "0";
}
- $cline .= ", \"$str\"$out_var, 123456789, $run_extra, $extra_expected";
+ $cline .= ", \"$str\", 123456789, $run_extra, $extra_expected";
if ($run_extra) {
$cline .= &new_test ($str, undef, 0);
} else {
}
}
}
- if ($in_func) {
- print $file " $cline);\n";
- } else {
- print $file " $cline },\n";
- }
+ print $file " $cline },\n";
}
# Generate libm-test.c
sub generate_testfile {
my ($input, $output) = @_;
my ($lasttext);
- my (@args, $i, $str, $thisfct, $in_func);
+ my (@args, $i, $str, $thisfct);
open INPUT, $input or die ("Can't open $input: $!");
open OUTPUT, ">$output" or die ("Can't open $output: $!");
# Replace the special macros
- $in_func = 0;
while (<INPUT>) {
# TEST_...
my ($descr, $args);
chop;
($descr, $args) = ($_ =~ /TEST_(\w+)\s*\((.*)\)/);
- &parse_args (\*OUTPUT, $descr, $thisfct, $in_func, $args);
+ &parse_args (\*OUTPUT, $descr, $thisfct, $args);
next;
}
# START_DATA (function)
if (/START_DATA/) {
($thisfct) = ($_ =~ /START_DATA\s*\((.*)\)/);
- $in_func = 0;
next;
}
# START (function)
if (/START/) {
($thisfct) = ($_ =~ /START\s*\((.*)\)/);
- $in_func = 1;
print OUTPUT " init_max_error ();\n";
next;
}
# END (function)
if (/END/) {
my ($fct, $line, $type);
- $in_func = 0;
if (/complex/) {
s/,\s*complex\s*//;
$type = 'complex';
static int output_points; /* Should the single function results printed? */
static int ignore_max_ulp; /* Should we ignore max_ulp? */
-#define PLUS_ZERO_INIT CHOOSE (0.0L, 0.0, 0.0f, \
+#define plus_zero CHOOSE (0.0L, 0.0, 0.0f, \
0.0L, 0.0, 0.0f)
-#define MINUS_ZERO_INIT CHOOSE (-0.0L, -0.0, -0.0f, \
+#define minus_zero CHOOSE (-0.0L, -0.0, -0.0f, \
-0.0L, -0.0, -0.0f)
-#define PLUS_INFTY_INIT CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF, \
+#define plus_infty CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF, \
HUGE_VALL, HUGE_VAL, HUGE_VALF)
-#define MINUS_INFTY_INIT CHOOSE (-HUGE_VALL, -HUGE_VAL, -HUGE_VALF, \
- -HUGE_VALL, -HUGE_VAL, -HUGE_VALF)
-#define QNAN_VALUE_INIT FUNC (__builtin_nan) ("")
-#define MAX_VALUE_INIT CHOOSE (LDBL_MAX, DBL_MAX, FLT_MAX, \
+#define minus_infty CHOOSE (-HUGE_VALL, -HUGE_VAL, -HUGE_VALF, \
+ -HUGE_VALL, -HUGE_VAL, -HUGE_VALF)
+#define qnan_value FUNC (__builtin_nan) ("")
+#define max_value CHOOSE (LDBL_MAX, DBL_MAX, FLT_MAX, \
LDBL_MAX, DBL_MAX, FLT_MAX)
-#define MIN_VALUE_INIT CHOOSE (LDBL_MIN, DBL_MIN, FLT_MIN, \
+#define min_value CHOOSE (LDBL_MIN, DBL_MIN, FLT_MIN, \
LDBL_MIN, DBL_MIN, FLT_MIN)
-#define MIN_SUBNORM_VALUE_INIT CHOOSE (__LDBL_DENORM_MIN__, \
+#define min_subnorm_value CHOOSE (__LDBL_DENORM_MIN__, \
__DBL_DENORM_MIN__, \
__FLT_DENORM_MIN__, \
__LDBL_DENORM_MIN__, \
__DBL_DENORM_MIN__, \
__FLT_DENORM_MIN__)
-static const FLOAT plus_zero = PLUS_ZERO_INIT;
-static const FLOAT minus_zero = MINUS_ZERO_INIT;
-static const FLOAT plus_infty = PLUS_INFTY_INIT;
-static const FLOAT minus_infty = MINUS_INFTY_INIT;
-static const FLOAT qnan_value = QNAN_VALUE_INIT;
-static const FLOAT max_value = MAX_VALUE_INIT;
-static const FLOAT min_value = MIN_VALUE_INIT;
-static const FLOAT min_subnorm_value = MIN_SUBNORM_VALUE_INIT;
-
static FLOAT max_error, real_max_error, imag_max_error;