2 # Copyright (C) 1999-2018 Free Software Foundation, Inc.
3 # This file is part of the GNU C Library.
4 # Contributed by Andreas Jaeger <aj@suse.de>, 1999.
6 # The GNU C Library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
11 # The GNU C Library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with the GNU C Library; if not, see
18 # <http://www.gnu.org/licenses/>.
20 # This file needs to be tidied up
21 # Note that functions and tests share the same namespace.
23 # Information about tests are stored in: %results
24 # $results{$test}{"type"} is the result type, e.g. normal or complex.
25 # $results{$test}{"has_ulps"} is set if deltas exist.
26 # In the following description $type and $float are:
27 # - $type is either "normal", "real" (for the real part of a complex number)
28 # or "imag" (for the imaginary part # of a complex number).
29 # - $float is either of float, ifloat, double, idouble, ldouble, ildouble;
30 # It represents the underlying floating point type (float, double or long
31 # double) and if inline functions (the leading i stands for inline)
33 # $results{$test}{$type}{"ulp"}{$float} is defined and has a delta as value
40 use vars qw
($input $output $auto_input);
41 use vars qw
(%results);
42 use vars qw
(%beautify @all_floats %all_floats_pfx);
43 use vars qw
($ulps_file);
44 use vars qw
(%auto_tests);
46 # all_floats is sorted and contains all recognised float types
47 @all_floats = ('double', 'float', 'float128', 'idouble',
48 'ifloat', 'ifloat128', 'ildouble', 'ldouble');
50 # all_floats_pfx maps C types to their C like prefix for macros.
55 "float128" => "FLT128",
59 ( "minus_zero" => "-0",
67 "minus_infty" => "-inf",
68 "plus_infty" => "inf",
69 "qnan_value" => "qNaN",
70 "snan_value" => "sNaN",
71 "snan_value_ld" => "sNaN",
77 # a: auto-libm-test-out input file
81 # C: libm-test.c output file
82 # H: libm-test-ulps.h output file
84 use vars
qw($opt_a $opt_c $opt_u $opt_n $opt_C $opt_H $opt_h);
85 getopts('a:c:u:n:C:H:h');
87 $ulps_file = 'libm-test-ulps';
90 print "Usage: gen-libm-test.pl [OPTIONS]\n";
91 print " -h print this help, then exit\n";
92 print " -a FILE input file with automatically generated tests\n";
93 print " -c FILE input file .inc file with tests\n";
94 print " -u FILE input file with ulps\n";
95 print " -n FILE generate sorted file FILE from libm-test-ulps\n";
96 print " -C FILE generate output C file FILE from libm-test.inc\n";
97 print " -H FILE generate output ulps header FILE from libm-test-ulps\n";
101 $ulps_file = $opt_u if ($opt_u);
103 $input = $opt_c if ($opt_c);
104 $auto_input = $opt_a if ($opt_a);
105 $output = $opt_C if ($opt_C);
107 &parse_ulps ($ulps_file) if ($opt_H || $opt_n);
108 &parse_auto_input ($auto_input) if ($opt_C);
109 &generate_testfile ($input, $output) if ($opt_C);
110 &output_ulps ($opt_H, $ulps_file) if ($opt_H);
111 &print_ulps_file ($opt_n) if ($opt_n);
113 # Return a nicer representation
118 if (exists $beautify{$arg}) {
119 return $beautify{$arg};
124 if (exists $beautify{$tmp}) {
125 return '-' . $beautify{$tmp};
128 if ($arg =~ /^-?0x[0-9a-f.]*p[-+][0-9]+f$/) {
131 if ($arg =~ /[0-9]L$/) {
137 # Return a nicer representation of a complex number
138 sub build_complex_beautify {
142 $str1 = &beautify ($r);
143 $str2 = &beautify ($i);
146 $str1 .= ' - ' . $str2;
148 $str1 .= ' + ' . $str2;
154 # Return the text to put in an initializer for a test's exception
156 sub show_exceptions {
157 my ($ignore_result, $non_finite, $test_snan, $exception) = @_;
158 $ignore_result = ($ignore_result ? "IGNORE_RESULT|" : "");
159 $non_finite = ($non_finite ? "NON_FINITE|" : "");
160 $test_snan = ($test_snan ? "TEST_SNAN|" : "");
161 if (defined $exception) {
162 return ", ${ignore_result}${non_finite}${test_snan}$exception";
164 return ", ${ignore_result}${non_finite}${test_snan}0";
168 # Apply the LIT(x) or ARG_LIT(x) macro to a literal floating point constant
169 # and strip any existing suffix.
171 my ($macro, $lit) = @_;
172 my $exp_re = "([+-])?[[:digit:]]+";
173 # Don't wrap something that does not look like a:
174 # * Hexadecimal FP value
175 # * Decimal FP value without a decimal point
176 # * Decimal value with a fraction
177 return $lit if $lit !~ /([+-])?0x[[:xdigit:]\.]+[pP]$exp_re/
178 and $lit !~ /[[:digit:]]+[eE]$exp_re/
179 and $lit !~ /[[:digit:]]*\.[[:digit:]]*([eE]$exp_re)?/;
181 # Strip any existing literal suffix.
184 return "$macro (${lit})";
187 # Apply LIT macro to individual tokens within an expression.
189 # This function assumes the C expression follows GNU coding
190 # standards. Specifically, a space separates each lexical
191 # token. Otherwise, this post-processing may apply LIT
192 # incorrectly, or around an entire expression.
195 my @toks = split (/ /, $lit);
197 $_ = _apply_lit ("LIT", $_);
199 return join (' ', @toks);
202 # Likewise, but apply ARG_LIT for arguments to narrowing functions.
205 my @toks = split (/ /, $lit);
207 $_ = _apply_lit ("ARG_LIT", $_);
209 return join (' ', @toks);
212 # Parse the arguments to TEST_x_y
214 my ($file, $descr, $args) = @_;
215 my (@args, $descr_args, $descr_res, @descr);
216 my ($current_arg, $cline, $cline_res, $i);
219 my ($ignore_result_any, $ignore_result_all);
220 my ($num_res, @args_res, @start_rm, $rm);
221 my (@plus_oflow, @minus_oflow, @plus_uflow, @minus_uflow);
222 my (@errno_plus_oflow, @errno_minus_oflow);
223 my (@errno_plus_uflow, @errno_minus_uflow);
224 my (@xfail_rounding_ibm128_libgcc);
225 my ($non_finite, $test_snan);
227 ($descr_args, $descr_res) = split /_/,$descr, 2;
229 @args = split /,\s*/, $args;
233 # Generate first the string that's shown to the user
235 @descr = split //,$descr_args;
236 for ($i = 0; $i <= $#descr; $i++) {
238 if ($current_arg > 1) {
241 # FLOAT, ARG_FLOAT, long double, int, unsigned int, long int, long long int
242 if ($descr[$i] =~ /f|a|j|i|u|l|L/) {
243 $call_args .= $comma . &beautify ($args[$current_arg]);
247 # Argument passed via pointer.
248 if ($descr[$i] =~ /p/) {
251 # &FLOAT, &int - simplify call by not showing argument.
252 if ($descr[$i] =~ /F|I/) {
256 if ($descr[$i] eq 'c') {
257 $call_args .= $comma . &build_complex_beautify ($args[$current_arg], $args[$current_arg+1]);
262 die ("$descr[$i] is unknown");
266 @args_res = @args[$current_arg .. $#args];
268 @descr = split //,$descr_res;
270 if ($_ =~ /f|i|l|L|M|U/) {
272 } elsif ($_ eq 'c') {
274 } elsif ($_ eq 'b') {
277 } elsif ($_ eq '1') {
280 die ("$_ is unknown");
284 if ($#args_res == $num_res - 1) {
285 # One set of results for all rounding modes, no flags.
286 @start_rm = ( 0, 0, 0, 0 );
287 } elsif ($#args_res == $num_res) {
288 # One set of results for all rounding modes, with flags.
289 die ("wrong number of arguments")
290 unless ($args_res[$#args_res] =~ /EXCEPTION|ERRNO|IGNORE_ZERO_INF_SIGN|TEST_NAN_SIGN|NO_TEST_INLINE|XFAIL/);
291 @start_rm = ( 0, 0, 0, 0 );
292 } elsif ($#args_res == 4 * $num_res + 3) {
293 # One set of results per rounding mode, with flags.
294 @start_rm = ( 0, $num_res + 1, 2 * $num_res + 2, 3 * $num_res + 3 );
296 die ("wrong number of arguments");
299 # Put the C program line together
300 # Reset some variables to start again
302 $call_args =~ s/\"/\\\"/g;
303 $cline = "{ \"$call_args\"";
304 @descr = split //,$descr_args;
305 for ($i=0; $i <= $#descr; $i++) {
306 # FLOAT, ARG_FLOAT, long double, int, unsigned int, long int, long long int
307 if ($descr[$i] =~ /f|a|j|i|u|l|L/) {
308 if ($descr[$i] eq "f") {
309 $cline .= ", " . &apply_lit ($args[$current_arg]);
310 } elsif ($descr[$i] eq "a") {
311 $cline .= ", " . &apply_arglit ($args[$current_arg]);
313 $cline .= ", $args[$current_arg]";
318 # &FLOAT, &int, argument passed via pointer
319 if ($descr[$i] =~ /F|I|p/) {
323 if ($descr[$i] eq 'c') {
324 $cline .= ", " . &apply_lit ($args[$current_arg]);
325 $cline .= ", " . &apply_lit ($args[$current_arg+1]);
331 @descr = split //,$descr_res;
332 @plus_oflow = qw(max_value plus_infty max_value plus_infty);
333 @minus_oflow = qw(minus_infty minus_infty -max_value -max_value);
334 @plus_uflow = qw(plus_zero plus_zero plus_zero min_subnorm_value);
335 @minus_uflow = qw(-min_subnorm_value minus_zero minus_zero minus_zero);
336 @errno_plus_oflow = qw(0 ERRNO_ERANGE 0 ERRNO_ERANGE);
337 @errno_minus_oflow = qw(ERRNO_ERANGE ERRNO_ERANGE 0 0);
338 @errno_plus_uflow = qw(ERRNO_ERANGE ERRNO_ERANGE ERRNO_ERANGE 0);
339 @errno_minus_uflow = qw(0 ERRNO_ERANGE ERRNO_ERANGE ERRNO_ERANGE);
340 @xfail_rounding_ibm128_libgcc = qw(XFAIL_IBM128_LIBGCC 0
341 XFAIL_IBM128_LIBGCC XFAIL_IBM128_LIBGCC);
342 for ($rm = 0; $rm <= 3; $rm++) {
343 $current_arg = $start_rm[$rm];
344 $ignore_result_any = 0;
345 $ignore_result_all = 1;
349 if ($_ =~ /b|f|j|i|l|L|M|U/ ) {
350 my ($result) = $args_res[$current_arg];
351 if ($result eq "IGNORE") {
352 $ignore_result_any = 1;
355 $ignore_result_all = 0;
358 $result = apply_lit
($result);
360 $cline_res .= ", $result";
362 } elsif ($_ eq 'c') {
363 my ($result1) = $args_res[$current_arg];
364 if ($result1 eq "IGNORE") {
365 $ignore_result_any = 1;
368 $ignore_result_all = 0;
370 my ($result2) = $args_res[$current_arg + 1];
371 if ($result2 eq "IGNORE") {
372 $ignore_result_any = 1;
375 $ignore_result_all = 0;
377 $result1 = apply_lit
($result1);
378 $result2 = apply_lit
($result2);
379 $cline_res .= ", $result1, $result2";
381 } elsif ($_ eq '1') {
382 push @special, $args_res[$current_arg];
386 if ($ignore_result_any && !$ignore_result_all) {
387 die ("some but not all function results ignored\n");
389 # Determine whether any arguments or results, for any rounding
390 # mode, are non-finite.
391 $non_finite = ($args =~ /qnan_value|snan_value|plus_infty|minus_infty/);
392 $test_snan = ($args =~ /snan_value/);
394 $cline_res .= show_exceptions
($ignore_result_any,
397 ($current_arg <= $#args_res)
398 ?
$args_res[$current_arg]
401 # special treatment for some functions
405 my ($extra_expected) = $_;
406 my ($run_extra) = ($extra_expected ne "IGNORE" ?
1 : 0);
408 $extra_expected = "0";
410 $extra_expected = apply_lit
($extra_expected);
412 $cline_res .= ", $run_extra, $extra_expected";
414 $cline_res =~ s/^, //;
415 $cline_res =~ s/plus_oflow/$plus_oflow[$rm]/g;
416 $cline_res =~ s/minus_oflow/$minus_oflow[$rm]/g;
417 $cline_res =~ s/plus_uflow/$plus_uflow[$rm]/g;
418 $cline_res =~ s/minus_uflow/$minus_uflow[$rm]/g;
419 $cline_res =~ s/ERRNO_PLUS_OFLOW/$errno_plus_oflow[$rm]/g;
420 $cline_res =~ s/ERRNO_MINUS_OFLOW/$errno_minus_oflow[$rm]/g;
421 $cline_res =~ s/ERRNO_PLUS_UFLOW/$errno_plus_uflow[$rm]/g;
422 $cline_res =~ s/ERRNO_MINUS_UFLOW/$errno_minus_uflow[$rm]/g;
423 $cline_res =~ s/XFAIL_ROUNDING_IBM128_LIBGCC/$xfail_rounding_ibm128_libgcc[$rm]/g;
424 $cline .= ", { $cline_res }";
426 print $file " $cline },\n";
429 # Convert a condition from auto-libm-test-out to C form.
430 sub convert_condition
{
433 @conds = split /:/, $cond;
435 if ($_ !~ /^arg_fmt\(/) {
440 $ret = join " && ", @conds;
444 # Return text to OR a value into an accumulated flags string.
454 # Return a conditional expression between two values.
456 my ($cond, $if, $else) = @_;
459 } elsif ($cond eq "0") {
462 return "($cond ? $if : $else)";
466 # Return text to OR a conditional expression between two values into
467 # an accumulated flags string.
469 my ($cond, $if, $else) = @_;
470 return or_value
(cond_value
($cond, $if, $else));
473 # Generate libm-test.c
474 sub generate_testfile
{
475 my ($input, $output) = @_;
477 open INPUT
, $input or die ("Can't open $input: $!");
478 open OUTPUT
, ">$output" or die ("Can't open $output: $!");
480 # Replace the special macros
482 # AUTO_TESTS (function),
483 if (/^\s*AUTO_TESTS_/) {
484 my ($descr, $func, @modes, $auto_test, $num_auto_tests);
485 my (@rm_tests, $rm, $i);
486 @modes = qw(downward tonearest towardzero upward);
487 ($descr, $func) = ($_ =~ /AUTO_TESTS_(\w+)\s*\((\w+)\)/);
488 for ($rm = 0; $rm <= 3; $rm++) {
489 $rm_tests[$rm] = [sort keys %{$auto_tests{$func}{$modes[$rm]}}];
491 $num_auto_tests = scalar @
{$rm_tests[0]};
492 for ($rm = 1; $rm <= 3; $rm++) {
493 if ($num_auto_tests != scalar @
{$rm_tests[$rm]}) {
494 die ("inconsistent numbers of tests for $func\n");
496 for ($i = 0; $i < $num_auto_tests; $i++) {
497 if ($rm_tests[0][$i] ne $rm_tests[$rm][$i]) {
498 die ("inconsistent list of tests of $func\n");
502 if ($num_auto_tests == 0) {
503 die ("no automatic tests for $func\n");
505 foreach $auto_test (@
{$rm_tests[0]}) {
506 my ($format, $inputs, $format_conv, $args_str);
507 ($format, $inputs) = split / /, $auto_test, 2;
509 $format_conv = convert_condition
($format);
510 print OUTPUT
"#if $format_conv\n";
511 $args_str = "$func, $inputs";
512 for ($rm = 0; $rm <= 3; $rm++) {
513 my ($auto_test_out, $outputs, $flags);
514 my ($flags_conv, @flags, %flag_cond);
515 $auto_test_out = $auto_tests{$func}{$modes[$rm]}{$auto_test};
516 ($outputs, $flags) = split / : */, $auto_test_out;
517 $outputs =~ s/ /, /g;
518 @flags = split / /, $flags;
520 if (/^([^:]*):(.*)$/) {
523 $cond = convert_condition
($2);
524 if (defined ($flag_cond{$flag})) {
525 if ($flag_cond{$flag} ne "1") {
526 $flag_cond{$flag} .= " || $cond";
529 $flag_cond{$flag} = $cond;
532 $flag_cond{$_} = "1";
536 if (defined ($flag_cond{"ignore-zero-inf-sign"})) {
537 $flags_conv .= or_cond_value
($flag_cond{"ignore-zero-inf-sign"},
538 "IGNORE_ZERO_INF_SIGN", "0");
540 if (defined ($flag_cond{"no-test-inline"})) {
541 $flags_conv .= or_cond_value
($flag_cond{"no-test-inline"},
542 "NO_TEST_INLINE", "0");
544 if (defined ($flag_cond{"xfail"})) {
545 $flags_conv .= or_cond_value
($flag_cond{"xfail"},
548 my (@exc_list) = qw(divbyzero inexact invalid overflow underflow);
550 foreach $exc (@exc_list) {
551 my ($exc_expected, $exc_ok, $no_exc, $exc_cond, $exc_ok_cond);
552 $exc_expected = "\U$exc\E_EXCEPTION";
553 $exc_ok = "\U$exc\E_EXCEPTION_OK";
555 if ($exc eq "inexact") {
557 $no_exc = "NO_INEXACT_EXCEPTION";
559 if (defined ($flag_cond{$exc})) {
560 $exc_cond = $flag_cond{$exc};
564 if (defined ($flag_cond{"$exc-ok"})) {
565 $exc_ok_cond = $flag_cond{"$exc-ok"};
569 $flags_conv .= or_cond_value
($exc_cond,
570 cond_value
($exc_ok_cond,
571 $exc_ok, $exc_expected),
572 cond_value
($exc_ok_cond,
575 my ($errno_expected, $errno_unknown_cond);
576 if (defined ($flag_cond{"errno-edom"})) {
577 if ($flag_cond{"errno-edom"} ne "1") {
578 die ("unexpected condition for errno-edom");
580 if (defined ($flag_cond{"errno-erange"})) {
581 die ("multiple errno values expected");
583 $errno_expected = "ERRNO_EDOM";
584 } elsif (defined ($flag_cond{"errno-erange"})) {
585 if ($flag_cond{"errno-erange"} ne "1") {
586 die ("unexpected condition for errno-erange");
588 $errno_expected = "ERRNO_ERANGE";
590 $errno_expected = "ERRNO_UNCHANGED";
592 if (defined ($flag_cond{"errno-edom-ok"})) {
593 if (defined ($flag_cond{"errno-erange-ok"})
594 && ($flag_cond{"errno-erange-ok"}
595 ne $flag_cond{"errno-edom-ok"})) {
596 $errno_unknown_cond = "($flag_cond{\"errno-edom-ok\"} || $flag_cond{\"errno-erange-ok\"})";
598 $errno_unknown_cond = $flag_cond{"errno-edom-ok"};
600 } elsif (defined ($flag_cond{"errno-erange-ok"})) {
601 $errno_unknown_cond = $flag_cond{"errno-erange-ok"};
603 $errno_unknown_cond = "0";
605 $flags_conv .= or_cond_value
($errno_unknown_cond,
606 "0", $errno_expected);
607 if ($flags_conv eq "") {
608 $flags_conv = ", NO_EXCEPTION";
610 $flags_conv =~ s/^ \|/,/;
612 $args_str .= ", $outputs$flags_conv";
614 &parse_args
(\
*OUTPUT
, $descr, $args_str);
615 print OUTPUT
"#endif\n";
624 ($descr, $args) = ($_ =~ /TEST_(\w+)\s*\((.*)\)/);
625 &parse_args
(\
*OUTPUT
, $descr, $args);
639 my ($test, $type, $float, $eps, $float_regex);
641 # Build a basic regex to match type entries in the
642 # generated ULPS file.
643 foreach my $ftype (@all_floats) {
644 $float_regex .= "|" . $ftype;
646 $float_regex = "^" . substr ($float_regex, 1) . ":";
648 # $type has the following values:
649 # "normal": No complex variable
650 # "real": Real part of complex result
651 # "imag": Imaginary part of complex result
652 open ULP
, $file or die ("Can't open $file: $!");
655 # ignore comments and empty lines
659 if (/Real part of/) {
662 } elsif (/Imaginary part of/) {
663 s/Imaginary part of //;
668 ($test) = ($_ =~ /^Function:\s*\"([a-zA-Z0-9_]+)\"/);
671 if (/$float_regex/) {
672 ($float, $eps) = split /\s*:\s*/,$_,2;
678 if (!defined ($results{$test}{$type}{'ulp'}{$float})
679 || $results{$test}{$type}{'ulp'}{$float} < $eps) {
680 $results{$test}{$type}{'ulp'}{$float} = $eps;
681 $results{$test}{'has_ulps'} = 1;
684 if ($type =~ /^real|imag$/) {
685 $results{$test}{'type'} = 'complex';
686 } elsif ($type eq 'normal') {
687 $results{$test}{'type'} = 'normal';
691 print "Skipping unknown entry: `$_'\n";
697 # Clean up a floating point number
698 sub clean_up_number
{
701 # Remove trailing zeros after the decimal point
702 if ($number =~ /\./) {
709 # Output a file which can be read in as ulps file.
710 sub print_ulps_file
{
712 my ($test, $type, $float, $eps, $fct, $last_fct);
715 open NEWULP
, ">$file" or die ("Can't open $file: $!");
716 print NEWULP
"# Begin of automatic generation\n";
717 print NEWULP
"\n# Maximal error of functions:\n";
719 foreach $fct (sort keys %results) {
720 foreach $type ('real', 'imag', 'normal') {
721 if (exists $results{$fct}{$type}) {
722 if ($type eq 'normal') {
723 print NEWULP
"Function: \"$fct\":\n";
724 } elsif ($type eq 'real') {
725 print NEWULP
"Function: Real part of \"$fct\":\n";
726 } elsif ($type eq 'imag') {
727 print NEWULP
"Function: Imaginary part of \"$fct\":\n";
729 foreach $float (@all_floats) {
730 if (exists $results{$fct}{$type}{'ulp'}{$float}) {
731 print NEWULP
"$float: ",
732 &clean_up_number
($results{$fct}{$type}{'ulp'}{$float}),
740 print NEWULP
"# end of automatic generation\n";
745 my ($test, $type, $float) = @_;
747 return (exists $results{$test}{$type}{'ulp'}{$float}
748 ?
$results{$test}{$type}{'ulp'}{$float} : "0");
751 # Return the ulps value for a single test.
752 sub get_all_ulps_for_test
{
753 my ($test, $type) = @_;
754 my ($ldouble, $double, $float, $ildouble, $idouble, $ifloat);
757 if (exists $results{$test}{'has_ulps'}) {
758 foreach $float (@all_floats) {
759 $ulps_str .= &get_ulps
($test, $type, $float) . ", ";
761 return "{" . substr ($ulps_str, 0, -2) . "}";
763 die "get_all_ulps_for_test called for \"$test\" with no ulps\n";
769 my ($file, $ulps_filename) = @_;
770 my ($i, $fct, $type, $ulp, $ulp_real, $ulp_imag);
771 my (%func_ulps, %func_real_ulps, %func_imag_ulps);
773 open ULP
, ">$file" or die ("Can't open $file: $!");
775 print ULP
"/* This file is automatically generated\n";
776 print ULP
" from $ulps_filename with gen-libm-test.pl.\n";
777 print ULP
" Don't change it - change instead the master files. */\n\n";
779 print ULP
"struct ulp_data\n";
781 print ULP
" const char *name;\n";
782 print ULP
" FLOAT max_ulp[" . @all_floats . "];\n";
785 for ($i = 0; $i <= $#all_floats; $i++) {
786 $type = $all_floats[$i];
787 print ULP
"#define ULP_";
790 $type = substr $type, 1;
792 print ULP
"$all_floats_pfx{$type} $i\n";
795 foreach $fct (keys %results) {
796 $type = $results{$fct}{'type'};
797 if ($type eq 'normal') {
798 $ulp = get_all_ulps_for_test
($fct, 'normal');
799 } elsif ($type eq 'complex') {
800 $ulp_real = get_all_ulps_for_test
($fct, 'real');
801 $ulp_imag = get_all_ulps_for_test
($fct, 'imag');
803 die "unknown results ($fct) type $type\n";
805 if ($type eq 'normal') {
806 $func_ulps{$fct} = $ulp;
808 $func_real_ulps{$fct} = $ulp_real;
809 $func_imag_ulps{$fct} = $ulp_imag;
812 print ULP
"\n/* Maximal error of functions. */\n";
813 print ULP
"static const struct ulp_data func_ulps[] =\n {\n";
814 foreach $fct (sort keys %func_ulps) {
815 print ULP
" { \"$fct\", $func_ulps{$fct} },\n";
818 print ULP
"static const struct ulp_data func_real_ulps[] =\n {\n";
819 foreach $fct (sort keys %func_real_ulps) {
820 print ULP
" { \"$fct\", $func_real_ulps{$fct} },\n";
823 print ULP
"static const struct ulp_data func_imag_ulps[] =\n {\n";
824 foreach $fct (sort keys %func_imag_ulps) {
825 print ULP
" { \"$fct\", $func_imag_ulps{$fct} },\n";
831 # Parse auto-libm-test-out.
832 sub parse_auto_input
{
834 open AUTO
, $file or die ("Can't open $file: $!");
839 if (/^(\S+) (\S+) ([^: ][^ ]* [^:]*) : (.*)$/) {
840 $auto_tests{$1}{$2}{$3} = $4;
842 die ("bad automatic test line: $_\n");