]> git.ipfire.org Git - thirdparty/glibc.git/blob - math/gen-libm-test.pl
Test scalbn and scalbln in all rounding modes, add more tests of negative arguments.
[thirdparty/glibc.git] / math / gen-libm-test.pl
1 #!/usr/bin/perl -w
2 # Copyright (C) 1999-2014 Free Software Foundation, Inc.
3 # This file is part of the GNU C Library.
4 # Contributed by Andreas Jaeger <aj@suse.de>, 1999.
5
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.
10
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.
15
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/>.
19
20 # This file needs to be tidied up
21 # Note that functions and tests share the same namespace.
22
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)
32 # are used.
33 # $results{$test}{$type}{"ulp"}{$float} is defined and has a delta as value
34
35
36 use Getopt::Std;
37
38 use strict;
39
40 use vars qw ($input $output $auto_input);
41 use vars qw (%results);
42 use vars qw (%beautify @all_floats);
43 use vars qw ($output_dir $ulps_file $srcdir);
44 use vars qw (%auto_tests);
45
46 # all_floats is sorted and contains all recognised float types
47 @all_floats = ('double', 'float', 'idouble',
48 'ifloat', 'ildouble', 'ldouble');
49
50 %beautify =
51 ( "minus_zero" => "-0",
52 "plus_zero" => "+0",
53 "-0x0p+0f" => "-0",
54 "-0x0p+0" => "-0",
55 "-0x0p+0L" => "-0",
56 "0x0p+0f" => "+0",
57 "0x0p+0" => "+0",
58 "0x0p+0L" => "+0",
59 "minus_infty" => "-inf",
60 "plus_infty" => "inf",
61 "qnan_value" => "qNaN",
62 );
63
64
65 # get Options
66 # Options:
67 # u: ulps-file
68 # h: help
69 # o: output-directory
70 # n: generate new ulps file
71 use vars qw($opt_u $opt_h $opt_o $opt_n);
72 getopts('u:o:nh');
73
74 $ulps_file = 'libm-test-ulps';
75 $output_dir = '';
76 ($srcdir = $0) =~ s{[^/]*$}{};
77
78 if ($opt_h) {
79 print "Usage: gen-libm-test.pl [OPTIONS]\n";
80 print " -h print this help, then exit\n";
81 print " -o DIR directory where generated files will be placed\n";
82 print " -n only generate sorted file NewUlps from libm-test-ulps\n";
83 print " -u FILE input file with ulps\n";
84 exit 0;
85 }
86
87 $ulps_file = $opt_u if ($opt_u);
88 $output_dir = $opt_o if ($opt_o);
89
90 $input = "libm-test.inc";
91 $auto_input = "${srcdir}auto-libm-test-out";
92 $output = "${output_dir}libm-test.c";
93
94 &parse_ulps ($ulps_file);
95 &parse_auto_input ($auto_input);
96 &generate_testfile ($input, $output) unless ($opt_n);
97 &output_ulps ("${output_dir}libm-test-ulps.h", $ulps_file) unless ($opt_n);
98 &print_ulps_file ("${output_dir}NewUlps") if ($opt_n);
99
100 # Return a nicer representation
101 sub beautify {
102 my ($arg) = @_;
103 my ($tmp);
104
105 if (exists $beautify{$arg}) {
106 return $beautify{$arg};
107 }
108 if ($arg =~ /^-/) {
109 $tmp = $arg;
110 $tmp =~ s/^-//;
111 if (exists $beautify{$tmp}) {
112 return '-' . $beautify{$tmp};
113 }
114 }
115 if ($arg =~ /^-?0x[0-9a-f.]*p[-+][0-9]+f$/) {
116 $arg =~ s/f$//;
117 }
118 if ($arg =~ /[0-9]L$/) {
119 $arg =~ s/L$//;
120 }
121 return $arg;
122 }
123
124 # Return a nicer representation of a complex number
125 sub build_complex_beautify {
126 my ($r, $i) = @_;
127 my ($str1, $str2);
128
129 $str1 = &beautify ($r);
130 $str2 = &beautify ($i);
131 if ($str2 =~ /^-/) {
132 $str2 =~ s/^-//;
133 $str1 .= ' - ' . $str2;
134 } else {
135 $str1 .= ' + ' . $str2;
136 }
137 $str1 .= ' i';
138 return $str1;
139 }
140
141 # Return the text to put in an initializer for a test's exception
142 # information.
143 sub show_exceptions {
144 my ($ignore_result, $exception) = @_;
145 $ignore_result = ($ignore_result ? "IGNORE_RESULT|" : "");
146 if (defined $exception) {
147 return ", ${ignore_result}$exception";
148 } else {
149 return ", ${ignore_result}0";
150 }
151 }
152
153 # Parse the arguments to TEST_x_y
154 sub parse_args {
155 my ($file, $descr, $args) = @_;
156 my (@args, $descr_args, $descr_res, @descr);
157 my ($current_arg, $cline, $cline_res, $i);
158 my (@special);
159 my ($call_args);
160 my ($ignore_result_any, $ignore_result_all);
161 my ($num_res, @args_res, @start_rm, $rm);
162 my (@plus_oflow, @minus_oflow, @plus_uflow, @minus_uflow);
163
164 ($descr_args, $descr_res) = split /_/,$descr, 2;
165
166 @args = split /,\s*/, $args;
167
168 $call_args = "";
169
170 # Generate first the string that's shown to the user
171 $current_arg = 1;
172 @descr = split //,$descr_args;
173 for ($i = 0; $i <= $#descr; $i++) {
174 my $comma = "";
175 if ($current_arg > 1) {
176 $comma = ', ';
177 }
178 # FLOAT, int, long int, long long int
179 if ($descr[$i] =~ /f|i|l|L/) {
180 $call_args .= $comma . &beautify ($args[$current_arg]);
181 ++$current_arg;
182 next;
183 }
184 # &FLOAT, &int - simplify call by not showing argument.
185 if ($descr[$i] =~ /F|I/) {
186 next;
187 }
188 # complex
189 if ($descr[$i] eq 'c') {
190 $call_args .= $comma . &build_complex_beautify ($args[$current_arg], $args[$current_arg+1]);
191 $current_arg += 2;
192 next;
193 }
194
195 die ("$descr[$i] is unknown");
196 }
197
198 # Result
199 @args_res = @args[$current_arg .. $#args];
200 $num_res = 0;
201 @descr = split //,$descr_res;
202 foreach (@descr) {
203 if ($_ =~ /f|i|l|L/) {
204 ++$num_res;
205 } elsif ($_ eq 'c') {
206 $num_res += 2;
207 } elsif ($_ eq 'b') {
208 # boolean
209 ++$num_res;
210 } elsif ($_ eq '1') {
211 ++$num_res;
212 } else {
213 die ("$_ is unknown");
214 }
215 }
216 # consistency check
217 if ($#args_res == $num_res - 1) {
218 # One set of results for all rounding modes, no flags.
219 @start_rm = ( 0, 0, 0, 0 );
220 } elsif ($#args_res == $num_res) {
221 # One set of results for all rounding modes, with flags.
222 die ("wrong number of arguments")
223 unless ($args_res[$#args_res] =~ /EXCEPTION|ERRNO|IGNORE_ZERO_INF_SIGN|TEST_NAN_SIGN|NO_TEST_INLINE|XFAIL_TEST/);
224 @start_rm = ( 0, 0, 0, 0 );
225 } elsif ($#args_res == 4 * $num_res + 3) {
226 # One set of results per rounding mode, with flags.
227 @start_rm = ( 0, $num_res + 1, 2 * $num_res + 2, 3 * $num_res + 3 );
228 } else {
229 die ("wrong number of arguments");
230 }
231
232 # Put the C program line together
233 # Reset some variables to start again
234 $current_arg = 1;
235 $cline = "{ \"$call_args\"";
236 @descr = split //,$descr_args;
237 for ($i=0; $i <= $#descr; $i++) {
238 # FLOAT, int, long int, long long int
239 if ($descr[$i] =~ /f|i|l|L/) {
240 $cline .= ", $args[$current_arg]";
241 $current_arg++;
242 next;
243 }
244 # &FLOAT, &int
245 if ($descr[$i] =~ /F|I/) {
246 next;
247 }
248 # complex
249 if ($descr[$i] eq 'c') {
250 $cline .= ", $args[$current_arg], $args[$current_arg+1]";
251 $current_arg += 2;
252 next;
253 }
254 }
255
256 @descr = split //,$descr_res;
257 @plus_oflow = qw(max_value plus_infty max_value plus_infty);
258 @minus_oflow = qw(minus_infty minus_infty -max_value -max_value);
259 @plus_uflow = qw(plus_zero plus_zero plus_zero min_subnorm_value);
260 @minus_uflow = qw(-min_subnorm_value minus_zero minus_zero minus_zero);
261 for ($rm = 0; $rm <= 3; $rm++) {
262 $current_arg = $start_rm[$rm];
263 $ignore_result_any = 0;
264 $ignore_result_all = 1;
265 $cline_res = "";
266 @special = ();
267 foreach (@descr) {
268 if ($_ =~ /b|f|i|l|L/ ) {
269 my ($result) = $args_res[$current_arg];
270 if ($result eq "IGNORE") {
271 $ignore_result_any = 1;
272 $result = "0";
273 } else {
274 $ignore_result_all = 0;
275 }
276 $cline_res .= ", $result";
277 $current_arg++;
278 } elsif ($_ eq 'c') {
279 my ($result1) = $args_res[$current_arg];
280 if ($result1 eq "IGNORE") {
281 $ignore_result_any = 1;
282 $result1 = "0";
283 } else {
284 $ignore_result_all = 0;
285 }
286 my ($result2) = $args_res[$current_arg + 1];
287 if ($result2 eq "IGNORE") {
288 $ignore_result_any = 1;
289 $result2 = "0";
290 } else {
291 $ignore_result_all = 0;
292 }
293 $cline_res .= ", $result1, $result2";
294 $current_arg += 2;
295 } elsif ($_ eq '1') {
296 push @special, $args_res[$current_arg];
297 ++$current_arg;
298 }
299 }
300 if ($ignore_result_any && !$ignore_result_all) {
301 die ("some but not all function results ignored\n");
302 }
303 # Add exceptions.
304 $cline_res .= show_exceptions ($ignore_result_any,
305 ($current_arg <= $#args_res)
306 ? $args_res[$current_arg]
307 : undef);
308
309 # special treatment for some functions
310 $i = 0;
311 foreach (@special) {
312 ++$i;
313 my ($extra_expected) = $_;
314 my ($run_extra) = ($extra_expected ne "IGNORE" ? 1 : 0);
315 if (!$run_extra) {
316 $extra_expected = "0";
317 }
318 $cline_res .= ", $run_extra, $extra_expected";
319 }
320 $cline_res =~ s/^, //;
321 $cline_res =~ s/plus_oflow/$plus_oflow[$rm]/g;
322 $cline_res =~ s/minus_oflow/$minus_oflow[$rm]/g;
323 $cline_res =~ s/plus_uflow/$plus_uflow[$rm]/g;
324 $cline_res =~ s/minus_uflow/$minus_uflow[$rm]/g;
325 $cline .= ", { $cline_res }";
326 }
327 print $file " $cline },\n";
328 }
329
330 # Convert a condition from auto-libm-test-out to C form.
331 sub convert_condition {
332 my ($cond) = @_;
333 my (@conds, $ret);
334 @conds = split /:/, $cond;
335 foreach (@conds) {
336 s/-/_/g;
337 s/^/TEST_COND_/;
338 }
339 $ret = join " && ", @conds;
340 return "($ret)";
341 }
342
343 # Return text to OR a value into an accumulated flags string.
344 sub or_value {
345 my ($cond) = @_;
346 if ($cond eq "0") {
347 return "";
348 } else {
349 return " | $cond";
350 }
351 }
352
353 # Return a conditional expression between two values.
354 sub cond_value {
355 my ($cond, $if, $else) = @_;
356 if ($cond eq "1") {
357 return $if;
358 } elsif ($cond eq "0") {
359 return $else;
360 } else {
361 return "($cond ? $if : $else)";
362 }
363 }
364
365 # Return text to OR a conditional expression between two values into
366 # an accumulated flags string.
367 sub or_cond_value {
368 my ($cond, $if, $else) = @_;
369 return or_value (cond_value ($cond, $if, $else));
370 }
371
372 # Generate libm-test.c
373 sub generate_testfile {
374 my ($input, $output) = @_;
375
376 open INPUT, $input or die ("Can't open $input: $!");
377 open OUTPUT, ">$output" or die ("Can't open $output: $!");
378
379 # Replace the special macros
380 while (<INPUT>) {
381 # AUTO_TESTS (function, mode),
382 if (/^\s*AUTO_TESTS_/) {
383 my ($descr, $func, $mode, $auto_test, $num_auto_tests);
384 ($descr, $func, $mode) = ($_ =~ /AUTO_TESTS_(\w+)\s*\((\w+),\s*(\w+)\)/);
385 $num_auto_tests = 0;
386 foreach $auto_test (sort keys %{$auto_tests{$func}{$mode}}) {
387 my ($finputs, $format, $inputs, $outputs, $flags);
388 my ($format_conv, $flags_conv, @flags, %flag_cond);
389 $num_auto_tests++;
390 ($finputs, $outputs, $flags) = split / : */, $auto_test;
391 ($format, $inputs) = split / /, $finputs, 2;
392 $inputs =~ s/ /, /g;
393 $outputs =~ s/ /, /g;
394 $format_conv = convert_condition ($format);
395 print OUTPUT "#if $format_conv\n";
396 @flags = split / /, $flags;
397 foreach (@flags) {
398 if (/^([^:]*):(.*)$/) {
399 my ($flag, $cond);
400 $flag = $1;
401 $cond = convert_condition ($2);
402 if (defined ($flag_cond{$flag})) {
403 if ($flag_cond{$flag} ne "1") {
404 $flag_cond{$flag} .= " || $cond";
405 }
406 } else {
407 $flag_cond{$flag} = $cond;
408 }
409 } else {
410 $flag_cond{$_} = "1";
411 }
412 }
413 $flags_conv = "";
414 if (defined ($flag_cond{"no-test-inline"})) {
415 $flags_conv .= or_cond_value ($flag_cond{"no-test-inline"},
416 "NO_TEST_INLINE", "0");
417 }
418 if (defined ($flag_cond{"xfail"})) {
419 $flags_conv .= or_cond_value ($flag_cond{"xfail"},
420 "XFAIL_TEST", "0");
421 }
422 my (@exc_list) = qw(divbyzero inexact invalid overflow underflow);
423 my ($exc);
424 foreach $exc (@exc_list) {
425 my ($exc_expected, $exc_ok, $no_exc, $exc_cond, $exc_ok_cond);
426 $exc_expected = "\U$exc\E_EXCEPTION";
427 $exc_ok = "\U$exc\E_EXCEPTION_OK";
428 $no_exc = "0";
429 if ($exc eq "inexact") {
430 $exc_ok = "0";
431 $no_exc = "NO_INEXACT_EXCEPTION";
432 }
433 if (defined ($flag_cond{$exc})) {
434 $exc_cond = $flag_cond{$exc};
435 } else {
436 $exc_cond = "0";
437 }
438 if (defined ($flag_cond{"$exc-ok"})) {
439 $exc_ok_cond = $flag_cond{"$exc-ok"};
440 } else {
441 $exc_ok_cond = "0";
442 }
443 $flags_conv .= or_cond_value ($exc_cond,
444 cond_value ($exc_ok_cond,
445 $exc_ok, $exc_expected),
446 cond_value ($exc_ok_cond,
447 $exc_ok, $no_exc));
448 }
449 my ($errno_expected, $errno_unknown_cond);
450 if (defined ($flag_cond{"errno-edom"})) {
451 if ($flag_cond{"errno-edom"} ne "1") {
452 die ("unexpected condition for errno-edom");
453 }
454 if (defined ($flag_cond{"errno-erange"})) {
455 die ("multiple errno values expected");
456 }
457 $errno_expected = "ERRNO_EDOM";
458 } elsif (defined ($flag_cond{"errno-erange"})) {
459 if ($flag_cond{"errno-erange"} ne "1") {
460 die ("unexpected condition for errno-erange");
461 }
462 $errno_expected = "ERRNO_ERANGE";
463 } else {
464 $errno_expected = "ERRNO_UNCHANGED";
465 }
466 if (defined ($flag_cond{"errno-edom-ok"})) {
467 if (defined ($flag_cond{"errno-erange-ok"})
468 && $flag_cond{"errno-erange-ok"} ne $flag_cond{"errno-edom-ok"}) {
469 $errno_unknown_cond = "($flag_cond{\"errno-edom-ok\"} || $flag_cond{\"errno-erange-ok\"})";
470 } else {
471 $errno_unknown_cond = $flag_cond{"errno-edom-ok"};
472 }
473 } elsif (defined ($flag_cond{"errno-erange-ok"})) {
474 $errno_unknown_cond = $flag_cond{"errno-erange-ok"};
475 } else {
476 $errno_unknown_cond = "0";
477 }
478 $flags_conv .= or_cond_value ($errno_unknown_cond,
479 "0", $errno_expected);
480 if ($flags_conv ne "") {
481 $flags_conv =~ s/^ \|/,/;
482 }
483 &parse_args (\*OUTPUT, $descr,
484 "$func, $inputs, $outputs$flags_conv");
485 print OUTPUT "#endif\n";
486 }
487 if ($num_auto_tests == 0) {
488 die ("no automatic tests for $func, $mode\n");
489 }
490 next;
491 }
492
493 # TEST_...
494 if (/^\s*TEST_/) {
495 my ($descr, $args);
496 chop;
497 ($descr, $args) = ($_ =~ /TEST_(\w+)\s*\((.*)\)/);
498 &parse_args (\*OUTPUT, $descr, $args);
499 next;
500 }
501 print OUTPUT;
502 }
503 close INPUT;
504 close OUTPUT;
505 }
506
507
508
509 # Parse ulps file
510 sub parse_ulps {
511 my ($file) = @_;
512 my ($test, $type, $float, $eps);
513
514 # $type has the following values:
515 # "normal": No complex variable
516 # "real": Real part of complex result
517 # "imag": Imaginary part of complex result
518 open ULP, $file or die ("Can't open $file: $!");
519 while (<ULP>) {
520 chop;
521 # ignore comments and empty lines
522 next if /^#/;
523 next if /^\s*$/;
524 if (/^Function: /) {
525 if (/Real part of/) {
526 s/Real part of //;
527 $type = 'real';
528 } elsif (/Imaginary part of/) {
529 s/Imaginary part of //;
530 $type = 'imag';
531 } else {
532 $type = 'normal';
533 }
534 ($test) = ($_ =~ /^Function:\s*\"([a-zA-Z0-9_]+)\"/);
535 next;
536 }
537 if (/^i?(float|double|ldouble):/) {
538 ($float, $eps) = split /\s*:\s*/,$_,2;
539
540 if ($eps eq "0") {
541 # ignore
542 next;
543 } else {
544 $results{$test}{$type}{'ulp'}{$float} = $eps;
545 $results{$test}{'has_ulps'} = 1;
546 }
547 if ($type =~ /^real|imag$/) {
548 $results{$test}{'type'} = 'complex';
549 } elsif ($type eq 'normal') {
550 $results{$test}{'type'} = 'normal';
551 }
552 next;
553 }
554 print "Skipping unknown entry: `$_'\n";
555 }
556 close ULP;
557 }
558
559
560 # Clean up a floating point number
561 sub clean_up_number {
562 my ($number) = @_;
563
564 # Remove trailing zeros after the decimal point
565 if ($number =~ /\./) {
566 $number =~ s/0+$//;
567 $number =~ s/\.$//;
568 }
569 return $number;
570 }
571
572 # Output a file which can be read in as ulps file.
573 sub print_ulps_file {
574 my ($file) = @_;
575 my ($test, $type, $float, $eps, $fct, $last_fct);
576
577 $last_fct = '';
578 open NEWULP, ">$file" or die ("Can't open $file: $!");
579 print NEWULP "# Begin of automatic generation\n";
580 print NEWULP "\n# Maximal error of functions:\n";
581
582 foreach $fct (sort keys %results) {
583 foreach $type ('real', 'imag', 'normal') {
584 if (exists $results{$fct}{$type}) {
585 if ($type eq 'normal') {
586 print NEWULP "Function: \"$fct\":\n";
587 } elsif ($type eq 'real') {
588 print NEWULP "Function: Real part of \"$fct\":\n";
589 } elsif ($type eq 'imag') {
590 print NEWULP "Function: Imaginary part of \"$fct\":\n";
591 }
592 foreach $float (@all_floats) {
593 if (exists $results{$fct}{$type}{'ulp'}{$float}) {
594 print NEWULP "$float: ",
595 &clean_up_number ($results{$fct}{$type}{'ulp'}{$float}),
596 "\n";
597 }
598 }
599 print NEWULP "\n";
600 }
601 }
602 }
603 print NEWULP "# end of automatic generation\n";
604 close NEWULP;
605 }
606
607 sub get_ulps {
608 my ($test, $type, $float) = @_;
609
610 return (exists $results{$test}{$type}{'ulp'}{$float}
611 ? $results{$test}{$type}{'ulp'}{$float} : "0");
612 }
613
614 # Return the ulps value for a single test.
615 sub get_all_ulps_for_test {
616 my ($test, $type) = @_;
617 my ($ldouble, $double, $float, $ildouble, $idouble, $ifloat);
618
619 if (exists $results{$test}{'has_ulps'}) {
620 # XXX use all_floats (change order!)
621 $ldouble = &get_ulps ($test, $type, "ldouble");
622 $double = &get_ulps ($test, $type, "double");
623 $float = &get_ulps ($test, $type, "float");
624 $ildouble = &get_ulps ($test, $type, "ildouble");
625 $idouble = &get_ulps ($test, $type, "idouble");
626 $ifloat = &get_ulps ($test, $type, "ifloat");
627 return "CHOOSE ($ldouble, $double, $float, $ildouble, $idouble, $ifloat)";
628 } else {
629 die "get_all_ulps_for_test called for \"$test\" with no ulps\n";
630 }
631 }
632
633 # Print include file
634 sub output_ulps {
635 my ($file, $ulps_filename) = @_;
636 my ($i, $fct, $type, $ulp, $ulp_real, $ulp_imag);
637 my (%func_ulps, %func_real_ulps, %func_imag_ulps);
638
639 open ULP, ">$file" or die ("Can't open $file: $!");
640
641 print ULP "/* This file is automatically generated\n";
642 print ULP " from $ulps_filename with gen-libm-test.pl.\n";
643 print ULP " Don't change it - change instead the master files. */\n\n";
644
645 foreach $fct (keys %results) {
646 $type = $results{$fct}{'type'};
647 if ($type eq 'normal') {
648 $ulp = get_all_ulps_for_test ($fct, 'normal');
649 } elsif ($type eq 'complex') {
650 $ulp_real = get_all_ulps_for_test ($fct, 'real');
651 $ulp_imag = get_all_ulps_for_test ($fct, 'imag');
652 } else {
653 die "unknown results ($fct) type $type\n";
654 }
655 if ($type eq 'normal') {
656 $func_ulps{$fct} = $ulp;
657 } else {
658 $func_real_ulps{$fct} = $ulp_real;
659 $func_imag_ulps{$fct} = $ulp_imag;
660 }
661 }
662 print ULP "\n/* Maximal error of functions. */\n";
663 print ULP "static const struct ulp_data func_ulps[] =\n {\n";
664 foreach $fct (sort keys %func_ulps) {
665 print ULP " { \"$fct\", $func_ulps{$fct} },\n";
666 }
667 print ULP " };\n";
668 print ULP "static const struct ulp_data func_real_ulps[] =\n {\n";
669 foreach $fct (sort keys %func_real_ulps) {
670 print ULP " { \"$fct\", $func_real_ulps{$fct} },\n";
671 }
672 print ULP " };\n";
673 print ULP "static const struct ulp_data func_imag_ulps[] =\n {\n";
674 foreach $fct (sort keys %func_imag_ulps) {
675 print ULP " { \"$fct\", $func_imag_ulps{$fct} },\n";
676 }
677 print ULP " };\n";
678 close ULP;
679 }
680
681 # Parse auto-libm-test-out.
682 sub parse_auto_input {
683 my ($file) = @_;
684 open AUTO, $file or die ("Can't open $file: $!");
685 while (<AUTO>) {
686 chop;
687 next if !/^= /;
688 s/^= //;
689 if (/^(\S+) (\S+) (.*)$/) {
690 $auto_tests{$1}{$2}{$3} = 1;
691 } else {
692 die ("bad automatic test line: $_\n");
693 }
694 }
695 close AUTO;
696 }