Remove __GNU_LIBRARY__ conditionals from rpcgen.
[glibc.git] / math / gen-libm-test.pl
blob579fbe5a9e6e134357a22a80f8b00c7ccab64668
1 #!/usr/bin/perl -w
2 # Copyright (C) 1999, 2006 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}{"kind"} is either "fct" or "test" and flags whether this
25 # is a maximal error of a function or a single test.
26 # $results{$test}{"type"} is the result type, e.g. normal or complex.
27 # $results{$test}{"has_ulps"} is set if deltas exist.
28 # $results{$test}{"has_fails"} is set if exptected failures exist.
29 # In the following description $type and $float are:
30 # - $type is either "normal", "real" (for the real part of a complex number)
31 # or "imag" (for the imaginary part # of a complex number).
32 # - $float is either of float, ifloat, double, idouble, ldouble, ildouble;
33 # It represents the underlying floating point type (float, double or long
34 # double) and if inline functions (the leading i stands for inline)
35 # are used.
36 # $results{$test}{$type}{"fail"}{$float} is defined and has a 1 if
37 # the test is expected to fail
38 # $results{$test}{$type}{"ulp"}{$float} is defined and has a delta as value
41 use Getopt::Std;
43 use strict;
45 use vars qw ($input $output);
46 use vars qw (%results);
47 use vars qw (@tests @functions);
48 use vars qw ($count);
49 use vars qw (%beautify @all_floats);
50 use vars qw ($output_dir $ulps_file);
52 # all_floats is sorted and contains all recognised float types
53 @all_floats = ('double', 'float', 'idouble',
54 'ifloat', 'ildouble', 'ldouble');
56 %beautify =
57 ( "minus_zero" => "-0",
58 "plus_zero" => "+0",
59 "minus_infty" => "-inf",
60 "plus_infty" => "inf",
61 "nan_value" => "NaN",
62 "M_El" => "e",
63 "M_E2l" => "e^2",
64 "M_E3l" => "e^3",
65 "M_LOG10El", "log10(e)",
66 "M_PIl" => "pi",
67 "M_PI_34l" => "3/4 pi",
68 "M_PI_2l" => "pi/2",
69 "M_PI_4l" => "pi/4",
70 "M_PI_6l" => "pi/6",
71 "M_PI_34_LOG10El" => "3/4 pi*log10(e)",
72 "M_PI_LOG10El" => "pi*log10(e)",
73 "M_PI2_LOG10El" => "pi/2*log10(e)",
74 "M_PI4_LOG10El" => "pi/4*log10(e)",
75 "M_LOG_SQRT_PIl" => "log(sqrt(pi))",
76 "M_LOG_2_SQRT_PIl" => "log(2*sqrt(pi))",
77 "M_2_SQRT_PIl" => "2 sqrt (pi)",
78 "M_SQRT_PIl" => "sqrt (pi)",
79 "INVALID_EXCEPTION" => "invalid exception",
80 "DIVIDE_BY_ZERO_EXCEPTION" => "division by zero exception",
81 "INVALID_EXCEPTION_OK" => "invalid exception allowed",
82 "DIVIDE_BY_ZERO_EXCEPTION_OK" => "division by zero exception allowed",
83 "EXCEPTIONS_OK" => "exceptions allowed",
84 "IGNORE_ZERO_INF_SIGN" => "sign of zero/inf not specified",
85 "INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN" => "invalid exception and sign of zero/inf not specified"
89 # get Options
90 # Options:
91 # u: ulps-file
92 # h: help
93 # o: output-directory
94 # n: generate new ulps file
95 use vars qw($opt_u $opt_h $opt_o $opt_n);
96 getopts('u:o:nh');
98 $ulps_file = 'libm-test-ulps';
99 $output_dir = '';
101 if ($opt_h) {
102 print "Usage: gen-libm-test.pl [OPTIONS]\n";
103 print " -h print this help, then exit\n";
104 print " -o DIR directory where generated files will be placed\n";
105 print " -n only generate sorted file NewUlps from libm-test-ulps\n";
106 print " -u FILE input file with ulps\n";
107 exit 0;
110 $ulps_file = $opt_u if ($opt_u);
111 $output_dir = $opt_o if ($opt_o);
113 $input = "libm-test.inc";
114 $output = "${output_dir}libm-test.c";
116 $count = 0;
118 &parse_ulps ($ulps_file);
119 &generate_testfile ($input, $output) unless ($opt_n);
120 &output_ulps ("${output_dir}libm-test-ulps.h", $ulps_file) unless ($opt_n);
121 &print_ulps_file ("${output_dir}NewUlps") if ($opt_n);
123 # Return a nicer representation
124 sub beautify {
125 my ($arg) = @_;
126 my ($tmp);
128 if (exists $beautify{$arg}) {
129 return $beautify{$arg};
131 if ($arg =~ /^-/) {
132 $tmp = $arg;
133 $tmp =~ s/^-//;
134 if (exists $beautify{$tmp}) {
135 return '-' . $beautify{$tmp};
138 if ($arg =~ /[0-9]L$/) {
139 $arg =~ s/L$//;
141 return $arg;
144 # Return a nicer representation of a complex number
145 sub build_complex_beautify {
146 my ($r, $i) = @_;
147 my ($str1, $str2);
149 $str1 = &beautify ($r);
150 $str2 = &beautify ($i);
151 if ($str2 =~ /^-/) {
152 $str2 =~ s/^-//;
153 $str1 .= ' - ' . $str2;
154 } else {
155 $str1 .= ' + ' . $str2;
157 $str1 .= ' i';
158 return $str1;
161 # Return name of a variable
162 sub get_variable {
163 my ($number) = @_;
165 return "x" if ($number == 1);
166 return "y" if ($number == 2);
167 return "z" if ($number == 3);
168 # return x1,x2,...
169 $number =-3;
170 return "x$number";
173 # Add a new test to internal data structures and fill in the
174 # ulps, failures and exception information for the C line.
175 sub new_test {
176 my ($test, $exception) = @_;
177 my $rest;
179 # Add ulp, xfail
180 if (exists $results{$test}{'has_ulps'}) {
181 $rest = ", DELTA$count";
182 } else {
183 $rest = ', 0';
185 if (exists $results{$test}{'has_fails'}) {
186 $rest .= ", FAIL$count";
187 } else {
188 $rest .= ', 0';
190 if (defined $exception) {
191 $rest .= ", $exception";
192 } else {
193 $rest .= ', 0';
195 $rest .= ");\n";
196 # We must increment here to keep @tests and count in sync
197 push @tests, $test;
198 ++$count;
199 return $rest;
202 # Treat some functions especially.
203 # Currently only sincos needs extra treatment.
204 sub special_functions {
205 my ($file, $args) = @_;
206 my (@args, $str, $test, $cline);
208 @args = split /,\s*/, $args;
210 unless ($args[0] =~ /sincos/) {
211 die ("Don't know how to handle $args[0] extra.");
213 print $file " FUNC (sincos) ($args[1], &sin_res, &cos_res);\n";
215 $str = 'sincos (' . &beautify ($args[1]) . ', &sin_res, &cos_res)';
216 # handle sin
217 $test = $str . ' puts ' . &beautify ($args[2]) . ' in sin_res';
218 if ($#args == 4) {
219 $test .= " plus " . &beautify ($args[4]);
222 $cline = " check_float (\"$test\", sin_res, $args[2]";
223 $cline .= &new_test ($test, $args[4]);
224 print $file $cline;
226 # handle cos
227 $test = $str . ' puts ' . &beautify ($args[3]) . ' in cos_res';
228 $cline = " check_float (\"$test\", cos_res, $args[3]";
229 # only tests once for exception
230 $cline .= &new_test ($test, undef);
231 print $file $cline;
234 # Parse the arguments to TEST_x_y
235 sub parse_args {
236 my ($file, $descr, $fct, $args) = @_;
237 my (@args, $str, $descr_args, $descr_res, @descr);
238 my ($current_arg, $cline, $i);
239 my ($pre, $post, @special);
240 my ($extra_var, $call, $c_call);
242 if ($descr eq 'extra') {
243 &special_functions ($file, $args);
244 return;
246 ($descr_args, $descr_res) = split /_/,$descr, 2;
248 @args = split /,\s*/, $args;
250 $call = "$fct (";
252 # Generate first the string that's shown to the user
253 $current_arg = 1;
254 $extra_var = 0;
255 @descr = split //,$descr_args;
256 for ($i = 0; $i <= $#descr; $i++) {
257 if ($i >= 1) {
258 $call .= ', ';
260 # FLOAT, int, long int, long long int
261 if ($descr[$i] =~ /f|i|l|L/) {
262 $call .= &beautify ($args[$current_arg]);
263 ++$current_arg;
264 next;
266 # &FLOAT, &int - argument is added here
267 if ($descr[$i] =~ /F|I/) {
268 ++$extra_var;
269 $call .= '&' . &get_variable ($extra_var);
270 next;
272 # complex
273 if ($descr[$i] eq 'c') {
274 $call .= &build_complex_beautify ($args[$current_arg], $args[$current_arg+1]);
275 $current_arg += 2;
276 next;
279 die ("$descr[$i] is unknown");
281 $call .= ')';
282 $str = "$call == ";
284 # Result
285 @descr = split //,$descr_res;
286 foreach (@descr) {
287 if ($_ =~ /f|i|l|L/) {
288 $str .= &beautify ($args[$current_arg]);
289 ++$current_arg;
290 } elsif ($_ eq 'c') {
291 $str .= &build_complex_beautify ($args[$current_arg], $args[$current_arg+1]);
292 $current_arg += 2;
293 } elsif ($_ eq 'b') {
294 # boolean
295 $str .= ($args[$current_arg] == 0) ? "false" : "true";
296 ++$current_arg;
297 } elsif ($_ eq '1') {
298 ++$current_arg;
299 } else {
300 die ("$_ is unknown");
303 # consistency check
304 if ($current_arg == $#args) {
305 die ("wrong number of arguments")
306 unless ($args[$current_arg] =~ /EXCEPTION|IGNORE_ZERO_INF_SIGN/);
307 } elsif ($current_arg < $#args) {
308 die ("wrong number of arguments");
309 } elsif ($current_arg > ($#args+1)) {
310 die ("wrong number of arguments");
314 # check for exceptions
315 if ($current_arg <= $#args) {
316 $str .= " plus " . &beautify ($args[$current_arg]);
319 # Put the C program line together
320 # Reset some variables to start again
321 $current_arg = 1;
322 $extra_var = 0;
323 if (substr($descr_res,0,1) eq 'f') {
324 $cline = 'check_float'
325 } elsif (substr($descr_res,0,1) eq 'b') {
326 $cline = 'check_bool';
327 } elsif (substr($descr_res,0,1) eq 'c') {
328 $cline = 'check_complex';
329 } elsif (substr($descr_res,0,1) eq 'i') {
330 $cline = 'check_int';
331 } elsif (substr($descr_res,0,1) eq 'l') {
332 $cline = 'check_long';
333 } elsif (substr($descr_res,0,1) eq 'L') {
334 $cline = 'check_longlong';
336 # Special handling for some macros:
337 $cline .= " (\"$str\", ";
338 if ($args[0] =~ /fpclassify|isnormal|isfinite|signbit/) {
339 $c_call = "$args[0] (";
340 } else {
341 $c_call = " FUNC($args[0]) (";
343 @descr = split //,$descr_args;
344 for ($i=0; $i <= $#descr; $i++) {
345 if ($i >= 1) {
346 $c_call .= ', ';
348 # FLOAT, int, long int, long long int
349 if ($descr[$i] =~ /f|i|l|L/) {
350 $c_call .= $args[$current_arg];
351 $current_arg++;
352 next;
354 # &FLOAT, &int
355 if ($descr[$i] =~ /F|I/) {
356 ++$extra_var;
357 $c_call .= '&' . &get_variable ($extra_var);
358 next;
360 # complex
361 if ($descr[$i] eq 'c') {
362 $c_call .= "BUILD_COMPLEX ($args[$current_arg], $args[$current_arg+1])";
363 $current_arg += 2;
364 next;
367 $c_call .= ')';
368 $cline .= "$c_call, ";
370 @descr = split //,$descr_res;
371 foreach (@descr) {
372 if ($_ =~ /b|f|i|l|L/ ) {
373 $cline .= $args[$current_arg];
374 $current_arg++;
375 } elsif ($_ eq 'c') {
376 $cline .= "BUILD_COMPLEX ($args[$current_arg], $args[$current_arg+1])";
377 $current_arg += 2;
378 } elsif ($_ eq '1') {
379 push @special, $args[$current_arg];
380 ++$current_arg;
383 # Add ulp, xfail
384 $cline .= &new_test ($str, ($current_arg <= $#args) ? $args[$current_arg] : undef);
386 # special treatment for some functions
387 if ($args[0] eq 'frexp') {
388 if (defined $special[0] && $special[0] ne "IGNORE") {
389 my ($str) = "$call sets x to $special[0]";
390 $post = " check_int (\"$str\", x, $special[0]";
391 $post .= &new_test ($str, undef);
393 } elsif ($args[0] eq 'gamma' || $args[0] eq 'lgamma') {
394 $pre = " signgam = 0;\n";
395 if (defined $special[0] && $special[0] ne "IGNORE") {
396 my ($str) = "$call sets signgam to $special[0]";
397 $post = " check_int (\"$str\", signgam, $special[0]";
398 $post .= &new_test ($str, undef);
400 } elsif ($args[0] eq 'modf') {
401 if (defined $special[0] && $special[0] ne "IGNORE") {
402 my ($str) = "$call sets x to $special[0]";
403 $post = " check_float (\"$str\", x, $special[0]";
404 $post .= &new_test ($str, undef);
406 } elsif ($args[0] eq 'remquo') {
407 if (defined $special[0] && $special[0] ne "IGNORE") {
408 my ($str) = "$call sets x to $special[0]";
409 $post = " check_int (\"$str\", x, $special[0]";
410 $post .= &new_test ($str, undef);
414 print $file $pre if (defined $pre);
416 print $file " $cline";
418 print $file $post if (defined $post);
421 # Generate libm-test.c
422 sub generate_testfile {
423 my ($input, $output) = @_;
424 my ($lasttext);
425 my (@args, $i, $str, $thisfct);
427 open INPUT, $input or die ("Can't open $input: $!");
428 open OUTPUT, ">$output" or die ("Can't open $output: $!");
430 # Replace the special macros
431 while (<INPUT>) {
433 # TEST_...
434 if (/^\s*TEST_/) {
435 my ($descr, $args);
436 chop;
437 ($descr, $args) = ($_ =~ /TEST_(\w+)\s*\((.*)\)/);
438 &parse_args (\*OUTPUT, $descr, $thisfct, $args);
439 next;
441 # START (function)
442 if (/START/) {
443 ($thisfct) = ($_ =~ /START\s*\((.*)\)/);
444 print OUTPUT " init_max_error ();\n";
445 next;
447 # END (function)
448 if (/END/) {
449 my ($fct, $line, $type);
450 if (/complex/) {
451 s/,\s*complex\s*//;
452 $type = 'complex';
453 } else {
454 $type = 'normal';
456 ($fct) = ($_ =~ /END\s*\((.*)\)/);
457 if ($type eq 'complex') {
458 $line = " print_complex_max_error (\"$fct\", ";
459 } else {
460 $line = " print_max_error (\"$fct\", ";
462 if (exists $results{$fct}{'has_ulps'}) {
463 $line .= "DELTA$fct";
464 } else {
465 $line .= '0';
467 if (exists $results{$fct}{'has_fails'}) {
468 $line .= ", FAIL$fct";
469 } else {
470 $line .= ', 0';
472 $line .= ");\n";
473 print OUTPUT $line;
474 push @functions, $fct;
475 next;
477 print OUTPUT;
479 close INPUT;
480 close OUTPUT;
485 # Parse ulps file
486 sub parse_ulps {
487 my ($file) = @_;
488 my ($test, $type, $float, $eps, $kind);
490 # $type has the following values:
491 # "normal": No complex variable
492 # "real": Real part of complex result
493 # "imag": Imaginary part of complex result
494 open ULP, $file or die ("Can't open $file: $!");
495 while (<ULP>) {
496 chop;
497 # ignore comments and empty lines
498 next if /^#/;
499 next if /^\s*$/;
500 if (/^Test/) {
501 if (/Real part of:/) {
502 s/Real part of: //;
503 $type = 'real';
504 } elsif (/Imaginary part of:/) {
505 s/Imaginary part of: //;
506 $type = 'imag';
507 } else {
508 $type = 'normal';
510 s/^.+\"(.*)\".*$/$1/;
511 $test = $_;
512 $kind = 'test';
513 next;
515 if (/^Function: /) {
516 if (/Real part of/) {
517 s/Real part of //;
518 $type = 'real';
519 } elsif (/Imaginary part of/) {
520 s/Imaginary part of //;
521 $type = 'imag';
522 } else {
523 $type = 'normal';
525 ($test) = ($_ =~ /^Function:\s*\"([a-zA-Z0-9_]+)\"/);
526 $kind = 'fct';
527 next;
529 if (/^i?(float|double|ldouble):/) {
530 ($float, $eps) = split /\s*:\s*/,$_,2;
532 if ($eps eq 'fail') {
533 $results{$test}{$type}{'fail'}{$float} = 1;
534 $results{$test}{'has_fails'} = 1;
535 } elsif ($eps eq "0") {
536 # ignore
537 next;
538 } else {
539 $results{$test}{$type}{'ulp'}{$float} = $eps;
540 $results{$test}{'has_ulps'} = 1;
542 if ($type =~ /^real|imag$/) {
543 $results{$test}{'type'} = 'complex';
544 } elsif ($type eq 'normal') {
545 $results{$test}{'type'} = 'normal';
547 $results{$test}{'kind'} = $kind;
548 next;
550 print "Skipping unknown entry: `$_'\n";
552 close ULP;
556 # Clean up a floating point number
557 sub clean_up_number {
558 my ($number) = @_;
560 # Remove trailing zeros after the decimal point
561 if ($number =~ /\./) {
562 $number =~ s/0+$//;
563 $number =~ s/\.$//;
565 return $number;
568 # Output a file which can be read in as ulps file.
569 sub print_ulps_file {
570 my ($file) = @_;
571 my ($test, $type, $float, $eps, $fct, $last_fct);
573 $last_fct = '';
574 open NEWULP, ">$file" or die ("Can't open $file: $!");
575 print NEWULP "# Begin of automatic generation\n";
576 # first the function calls
577 foreach $test (sort keys %results) {
578 next if ($results{$test}{'kind'} ne 'test');
579 foreach $type ('real', 'imag', 'normal') {
580 if (exists $results{$test}{$type}) {
581 if (defined $results{$test}) {
582 ($fct) = ($test =~ /^(\w+)\s/);
583 if ($fct ne $last_fct) {
584 $last_fct = $fct;
585 print NEWULP "\n# $fct\n";
588 if ($type eq 'normal') {
589 print NEWULP "Test \"$test\":\n";
590 } elsif ($type eq 'real') {
591 print NEWULP "Test \"Real part of: $test\":\n";
592 } elsif ($type eq 'imag') {
593 print NEWULP "Test \"Imaginary part of: $test\":\n";
595 foreach $float (@all_floats) {
596 if (exists $results{$test}{$type}{'ulp'}{$float}) {
597 print NEWULP "$float: ",
598 &clean_up_number ($results{$test}{$type}{'ulp'}{$float}),
599 "\n";
601 if (exists $results{$test}{$type}{'fail'}{$float}) {
602 print NEWULP "$float: fail\n";
608 print NEWULP "\n# Maximal error of functions:\n";
610 foreach $fct (sort keys %results) {
611 next if ($results{$fct}{'kind'} ne 'fct');
612 foreach $type ('real', 'imag', 'normal') {
613 if (exists $results{$fct}{$type}) {
614 if ($type eq 'normal') {
615 print NEWULP "Function: \"$fct\":\n";
616 } elsif ($type eq 'real') {
617 print NEWULP "Function: Real part of \"$fct\":\n";
618 } elsif ($type eq 'imag') {
619 print NEWULP "Function: Imaginary part of \"$fct\":\n";
621 foreach $float (@all_floats) {
622 if (exists $results{$fct}{$type}{'ulp'}{$float}) {
623 print NEWULP "$float: ",
624 &clean_up_number ($results{$fct}{$type}{'ulp'}{$float}),
625 "\n";
627 if (exists $results{$fct}{$type}{'fail'}{$float}) {
628 print NEWULP "$float: fail\n";
631 print NEWULP "\n";
635 print NEWULP "# end of automatic generation\n";
636 close NEWULP;
639 sub get_ulps {
640 my ($test, $type, $float) = @_;
642 if ($type eq 'complex') {
643 my ($res);
644 # Return 0 instead of BUILD_COMPLEX (0,0)
645 if (!exists $results{$test}{'real'}{'ulp'}{$float} &&
646 !exists $results{$test}{'imag'}{'ulp'}{$float}) {
647 return "0";
649 $res = 'BUILD_COMPLEX (';
650 $res .= (exists $results{$test}{'real'}{'ulp'}{$float}
651 ? $results{$test}{'real'}{'ulp'}{$float} : "0");
652 $res .= ', ';
653 $res .= (exists $results{$test}{'imag'}{'ulp'}{$float}
654 ? $results{$test}{'imag'}{'ulp'}{$float} : "0");
655 $res .= ')';
656 return $res;
658 return (exists $results{$test}{'normal'}{'ulp'}{$float}
659 ? $results{$test}{'normal'}{'ulp'}{$float} : "0");
662 sub get_failure {
663 my ($test, $type, $float) = @_;
664 if ($type eq 'complex') {
665 # return x,y
666 my ($res);
667 # Return 0 instead of BUILD_COMPLEX_INT (0,0)
668 if (!exists $results{$test}{'real'}{'ulp'}{$float} &&
669 !exists $results{$test}{'imag'}{'ulp'}{$float}) {
670 return "0";
672 $res = 'BUILD_COMPLEX_INT (';
673 $res .= (exists $results{$test}{'real'}{'fail'}{$float}
674 ? $results{$test}{'real'}{'fail'}{$float} : "0");
675 $res .= ', ';
676 $res .= (exists $results{$test}{'imag'}{'fail'}{$float}
677 ? $results{$test}{'imag'}{'fail'}{$float} : "0");
678 $res .= ')';
679 return $res;
681 return (exists $results{$test}{'normal'}{'fail'}{$float}
682 ? $results{$test}{'normal'}{'fail'}{$float} : "0");
686 # Output the defines for a single test
687 sub output_test {
688 my ($file, $test, $name) = @_;
689 my ($ldouble, $double, $float, $ildouble, $idouble, $ifloat);
690 my ($type);
692 # Do we have ulps/failures?
693 if (!exists $results{$test}{'type'}) {
694 return;
696 $type = $results{$test}{'type'};
697 if (exists $results{$test}{'has_ulps'}) {
698 # XXX use all_floats (change order!)
699 $ldouble = &get_ulps ($test, $type, "ldouble");
700 $double = &get_ulps ($test, $type, "double");
701 $float = &get_ulps ($test, $type, "float");
702 $ildouble = &get_ulps ($test, $type, "ildouble");
703 $idouble = &get_ulps ($test, $type, "idouble");
704 $ifloat = &get_ulps ($test, $type, "ifloat");
705 print $file "#define DELTA$name CHOOSE($ldouble, $double, $float, $ildouble, $idouble, $ifloat)\t/* $test */\n";
708 if (exists $results{$test}{'has_fails'}) {
709 $ldouble = &get_failure ($test, "ldouble");
710 $double = &get_failure ($test, "double");
711 $float = &get_failure ($test, "float");
712 $ildouble = &get_failure ($test, "ildouble");
713 $idouble = &get_failure ($test, "idouble");
714 $ifloat = &get_failure ($test, "ifloat");
715 print $file "#define FAIL$name CHOOSE($ldouble, $double, $float $ildouble, $idouble, $ifloat)\t/* $test */\n";
719 # Print include file
720 sub output_ulps {
721 my ($file, $ulps_filename) = @_;
722 my ($i, $fct);
724 open ULP, ">$file" or die ("Can't open $file: $!");
726 print ULP "/* This file is automatically generated\n";
727 print ULP " from $ulps_filename with gen-libm-test.pl.\n";
728 print ULP " Don't change it - change instead the master files. */\n\n";
730 print ULP "\n/* Maximal error of functions. */\n";
731 foreach $fct (@functions) {
732 output_test (\*ULP, $fct, $fct);
735 print ULP "\n/* Error of single function calls. */\n";
736 for ($i = 0; $i < $count; $i++) {
737 output_test (\*ULP, $tests[$i], $i);
739 close ULP;