S/390: Fix uc_link == NULL handling for makecontext
[platform/upstream/glibc.git] / math / gen-libm-test.pl
1 #!/usr/bin/perl -w
2 # Copyright (C) 1999-2012 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}{"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
39
40
41 use Getopt::Std;
42
43 use strict;
44
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);
51
52 # all_floats is sorted and contains all recognised float types
53 @all_floats = ('double', 'float', 'idouble',
54                'ifloat', 'ildouble', 'ldouble');
55
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   );
80
81
82 # get Options
83 # Options:
84 # u: ulps-file
85 # h: help
86 # o: output-directory
87 # n: generate new ulps file
88 use vars qw($opt_u $opt_h $opt_o $opt_n);
89 getopts('u:o:nh');
90
91 $ulps_file = 'libm-test-ulps';
92 $output_dir = '';
93
94 if ($opt_h) {
95   print "Usage: gen-libm-test.pl [OPTIONS]\n";
96   print " -h         print this help, then exit\n";
97   print " -o DIR     directory where generated files will be placed\n";
98   print " -n         only generate sorted file NewUlps from libm-test-ulps\n";
99   print " -u FILE    input file with ulps\n";
100   exit 0;
101 }
102
103 $ulps_file = $opt_u if ($opt_u);
104 $output_dir = $opt_o if ($opt_o);
105
106 $input = "libm-test.inc";
107 $output = "${output_dir}libm-test.c";
108
109 $count = 0;
110
111 &parse_ulps ($ulps_file);
112 &generate_testfile ($input, $output) unless ($opt_n);
113 &output_ulps ("${output_dir}libm-test-ulps.h", $ulps_file) unless ($opt_n);
114 &print_ulps_file ("${output_dir}NewUlps") if ($opt_n);
115
116 # Return a nicer representation
117 sub beautify {
118   my ($arg) = @_;
119   my ($tmp);
120
121   if (exists $beautify{$arg}) {
122     return $beautify{$arg};
123   }
124   if ($arg =~ /^-/) {
125     $tmp = $arg;
126     $tmp =~ s/^-//;
127     if (exists $beautify{$tmp}) {
128       return '-' . $beautify{$tmp};
129     }
130   }
131   if ($arg =~ /[0-9]L$/) {
132     $arg =~ s/L$//;
133   }
134   return $arg;
135 }
136
137 # Return a nicer representation of a complex number
138 sub build_complex_beautify {
139   my ($r, $i) = @_;
140   my ($str1, $str2);
141
142   $str1 = &beautify ($r);
143   $str2 = &beautify ($i);
144   if ($str2 =~ /^-/) {
145     $str2 =~ s/^-//;
146     $str1 .= ' - ' . $str2;
147   } else {
148     $str1 .= ' + ' . $str2;
149   }
150   $str1 .= ' i';
151   return $str1;
152 }
153
154 # Return name of a variable
155 sub get_variable {
156   my ($number) = @_;
157
158   return "x" if ($number == 1);
159   return "y" if ($number == 2);
160   return "z" if ($number == 3);
161   # return x1,x2,...
162   $number =-3;
163   return "x$number";
164 }
165
166 # Add a new test to internal data structures and fill in the
167 # ulps, failures and exception information for the C line.
168 sub new_test {
169   my ($test, $exception) = @_;
170   my $rest;
171
172   # Add ulp, xfail
173   if (exists $results{$test}{'has_ulps'}) {
174     $rest = ", DELTA$count";
175   } else {
176     $rest = ', 0';
177   }
178   if (exists $results{$test}{'has_fails'}) {
179     $rest .= ", FAIL$count";
180   } else {
181     $rest .= ', 0';
182   }
183   if (defined $exception) {
184     $rest .= ", $exception";
185   } else {
186     $rest .= ', 0';
187   }
188   $rest .= ");\n";
189   # We must increment here to keep @tests and count in sync
190   push @tests, $test;
191   ++$count;
192   return $rest;
193 }
194
195 # Treat some functions especially.
196 # Currently only sincos needs extra treatment.
197 sub special_functions {
198   my ($file, $args) = @_;
199   my (@args, $str, $test, $cline);
200
201   @args = split /,\s*/, $args;
202
203   unless ($args[0] =~ /sincos/) {
204     die ("Don't know how to handle $args[0] extra.");
205   }
206   print $file "  FUNC (sincos) ($args[1], &sin_res, &cos_res);\n";
207
208   $str = 'sincos (' . &beautify ($args[1]) . ', &sin_res, &cos_res)';
209   # handle sin
210   $test = $str . ' puts ' . &beautify ($args[2]) . ' in sin_res';
211
212   $cline = "  check_float (\"$test\", sin_res, $args[2]";
213   $cline .= &new_test ($test, $args[4]);
214   print $file $cline;
215
216   # handle cos
217   $test = $str . ' puts ' . &beautify ($args[3]) . ' in cos_res';
218   $cline = "  check_float (\"$test\", cos_res, $args[3]";
219   # only tests once for exception
220   $cline .= &new_test ($test, undef);
221   print $file $cline;
222 }
223
224 # Parse the arguments to TEST_x_y
225 sub parse_args {
226   my ($file, $descr, $fct, $args) = @_;
227   my (@args, $str, $descr_args, $descr_res, @descr);
228   my ($current_arg, $cline, $i);
229   my ($pre, $post, @special);
230   my ($extra_var, $call, $c_call);
231
232   if ($descr eq 'extra') {
233     &special_functions ($file, $args);
234     return;
235   }
236   ($descr_args, $descr_res) = split /_/,$descr, 2;
237
238   @args = split /,\s*/, $args;
239
240   $call = "$fct (";
241
242   # Generate first the string that's shown to the user
243   $current_arg = 1;
244   $extra_var = 0;
245   @descr = split //,$descr_args;
246   for ($i = 0; $i <= $#descr; $i++) {
247     if ($i >= 1) {
248       $call .= ', ';
249     }
250     # FLOAT, int, long int, long long int
251     if ($descr[$i] =~ /f|i|l|L/) {
252       $call .= &beautify ($args[$current_arg]);
253       ++$current_arg;
254       next;
255     }
256     # &FLOAT, &int - argument is added here
257     if ($descr[$i] =~ /F|I/) {
258       ++$extra_var;
259       $call .= '&' . &get_variable ($extra_var);
260       next;
261     }
262     # complex
263     if ($descr[$i] eq 'c') {
264       $call .= &build_complex_beautify ($args[$current_arg], $args[$current_arg+1]);
265       $current_arg += 2;
266       next;
267     }
268
269     die ("$descr[$i] is unknown");
270   }
271   $call .= ')';
272   $str = "$call == ";
273
274   # Result
275   @descr = split //,$descr_res;
276   foreach (@descr) {
277     if ($_ =~ /f|i|l|L/) {
278       $str .= &beautify ($args[$current_arg]);
279       ++$current_arg;
280     } elsif ($_ eq 'c') {
281       $str .= &build_complex_beautify ($args[$current_arg], $args[$current_arg+1]);
282       $current_arg += 2;
283     } elsif ($_ eq 'b') {
284       # boolean
285       $str .= ($args[$current_arg] == 0) ? "false" : "true";
286       ++$current_arg;
287     } elsif ($_ eq '1') {
288       ++$current_arg;
289     } else {
290       die ("$_ is unknown");
291     }
292   }
293   # consistency check
294   if ($current_arg == $#args) {
295     die ("wrong number of arguments")
296       unless ($args[$current_arg] =~ /EXCEPTION|IGNORE_ZERO_INF_SIGN/);
297   } elsif ($current_arg < $#args) {
298     die ("wrong number of arguments");
299   } elsif ($current_arg > ($#args+1)) {
300     die ("wrong number of arguments");
301   }
302
303
304   # Put the C program line together
305   # Reset some variables to start again
306   $current_arg = 1;
307   $extra_var = 0;
308   if (substr($descr_res,0,1) eq 'f') {
309     $cline = 'check_float'
310   } elsif (substr($descr_res,0,1) eq 'b') {
311     $cline = 'check_bool';
312   } elsif (substr($descr_res,0,1) eq 'c') {
313     $cline = 'check_complex';
314   } elsif (substr($descr_res,0,1) eq 'i') {
315     $cline = 'check_int';
316   } elsif (substr($descr_res,0,1) eq 'l') {
317     $cline = 'check_long';
318   } elsif (substr($descr_res,0,1) eq 'L') {
319     $cline = 'check_longlong';
320   }
321   # Special handling for some macros:
322   $cline .= " (\"$str\", ";
323   if ($args[0] =~ /fpclassify|isnormal|isfinite|signbit/) {
324     $c_call = "$args[0] (";
325   } else {
326     $c_call = " FUNC($args[0]) (";
327   }
328   @descr = split //,$descr_args;
329   for ($i=0; $i <= $#descr; $i++) {
330     if ($i >= 1) {
331       $c_call .= ', ';
332     }
333     # FLOAT, int, long int, long long int
334     if ($descr[$i] =~ /f|i|l|L/) {
335       $c_call .= $args[$current_arg];
336       $current_arg++;
337       next;
338     }
339     # &FLOAT, &int
340     if ($descr[$i] =~ /F|I/) {
341       ++$extra_var;
342       $c_call .= '&' . &get_variable ($extra_var);
343       next;
344     }
345     # complex
346     if ($descr[$i] eq 'c') {
347       $c_call .= "BUILD_COMPLEX ($args[$current_arg], $args[$current_arg+1])";
348       $current_arg += 2;
349       next;
350     }
351   }
352   $c_call .= ')';
353   $cline .= "$c_call, ";
354
355   @descr = split //,$descr_res;
356   foreach (@descr) {
357     if ($_ =~ /b|f|i|l|L/ ) {
358       $cline .= $args[$current_arg];
359       $current_arg++;
360     } elsif ($_ eq 'c') {
361       $cline .= "BUILD_COMPLEX ($args[$current_arg], $args[$current_arg+1])";
362       $current_arg += 2;
363     } elsif ($_ eq '1') {
364       push @special, $args[$current_arg];
365       ++$current_arg;
366     }
367   }
368   # Add ulp, xfail
369   $cline .= &new_test ($str, ($current_arg <= $#args) ? $args[$current_arg] : undef);
370
371   # special treatment for some functions
372   if ($args[0] eq 'frexp') {
373     if (defined $special[0] && $special[0] ne "IGNORE") {
374       my ($str) = "$call sets x to $special[0]";
375       $post = "  check_int (\"$str\", x, $special[0]";
376       $post .= &new_test ($str, undef);
377     }
378   } elsif ($args[0] eq 'gamma' || $args[0] eq 'lgamma') {
379     $pre = "  signgam = 0;\n";
380     if (defined $special[0] && $special[0] ne "IGNORE") {
381       my ($str) = "$call sets signgam to $special[0]";
382       $post = "  check_int (\"$str\", signgam, $special[0]";
383       $post .= &new_test ($str, undef);
384     }
385   } elsif ($args[0] eq 'modf') {
386     if (defined $special[0] && $special[0] ne "IGNORE") {
387       my ($str) = "$call sets x to $special[0]";
388       $post = "  check_float (\"$str\", x, $special[0]";
389       $post .= &new_test ($str, undef);
390     }
391   } elsif ($args[0] eq 'remquo') {
392     if (defined $special[0] && $special[0] ne "IGNORE") {
393       my ($str) = "$call sets x to $special[0]";
394       $post = "  check_int (\"$str\", x, $special[0]";
395       $post .= &new_test ($str, undef);
396     }
397   }
398
399   print $file $pre if (defined $pre);
400
401   print $file "  $cline";
402
403   print $file $post if (defined $post);
404 }
405
406 # Generate libm-test.c
407 sub generate_testfile {
408   my ($input, $output) = @_;
409   my ($lasttext);
410   my (@args, $i, $str, $thisfct);
411
412   open INPUT, $input or die ("Can't open $input: $!");
413   open OUTPUT, ">$output" or die ("Can't open $output: $!");
414
415   # Replace the special macros
416   while (<INPUT>) {
417
418     # TEST_...
419     if (/^\s*TEST_/) {
420       my ($descr, $args);
421       chop;
422       ($descr, $args) = ($_ =~ /TEST_(\w+)\s*\((.*)\)/);
423       &parse_args (\*OUTPUT, $descr, $thisfct, $args);
424       next;
425     }
426     # START (function)
427     if (/START/) {
428       ($thisfct) = ($_ =~ /START\s*\((.*)\)/);
429       print OUTPUT "  init_max_error ();\n";
430       next;
431     }
432     # END (function)
433     if (/END/) {
434       my ($fct, $line, $type);
435       if (/complex/) {
436         s/,\s*complex\s*//;
437         $type = 'complex';
438       } else {
439         $type = 'normal';
440       }
441       ($fct) = ($_ =~ /END\s*\((.*)\)/);
442       if ($type eq 'complex') {
443         $line = "  print_complex_max_error (\"$fct\", ";
444       } else {
445         $line = "  print_max_error (\"$fct\", ";
446       }
447       if (exists $results{$fct}{'has_ulps'}) {
448         $line .= "DELTA$fct";
449       } else {
450         $line .= '0';
451       }
452       if (exists $results{$fct}{'has_fails'}) {
453         $line .= ", FAIL$fct";
454       } else {
455         $line .= ', 0';
456       }
457       $line .= ");\n";
458       print OUTPUT $line;
459       push @functions, $fct;
460       next;
461     }
462     print OUTPUT;
463   }
464   close INPUT;
465   close OUTPUT;
466 }
467
468
469
470 # Parse ulps file
471 sub parse_ulps {
472   my ($file) = @_;
473   my ($test, $type, $float, $eps, $kind);
474
475   # $type has the following values:
476   # "normal": No complex variable
477   # "real": Real part of complex result
478   # "imag": Imaginary part of complex result
479   open ULP, $file  or die ("Can't open $file: $!");
480   while (<ULP>) {
481     chop;
482     # ignore comments and empty lines
483     next if /^#/;
484     next if /^\s*$/;
485     if (/^Test/) {
486       if (/Real part of:/) {
487         s/Real part of: //;
488         $type = 'real';
489       } elsif (/Imaginary part of:/) {
490         s/Imaginary part of: //;
491         $type = 'imag';
492       } else {
493         $type = 'normal';
494       }
495       s/^.+\"(.*)\".*$/$1/;
496       $test = $_;
497       $kind = 'test';
498       next;
499     }
500     if (/^Function: /) {
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';
509       }
510       ($test) = ($_ =~ /^Function:\s*\"([a-zA-Z0-9_]+)\"/);
511       $kind = 'fct';
512       next;
513     }
514     if (/^i?(float|double|ldouble):/) {
515       ($float, $eps) = split /\s*:\s*/,$_,2;
516
517       if ($eps eq 'fail') {
518         $results{$test}{$type}{'fail'}{$float} = 1;
519         $results{$test}{'has_fails'} = 1;
520       } elsif ($eps eq "0") {
521         # ignore
522         next;
523       } else {
524         $results{$test}{$type}{'ulp'}{$float} = $eps;
525         $results{$test}{'has_ulps'} = 1;
526       }
527       if ($type =~ /^real|imag$/) {
528         $results{$test}{'type'} = 'complex';
529       } elsif ($type eq 'normal') {
530         $results{$test}{'type'} = 'normal';
531       }
532       $results{$test}{'kind'} = $kind;
533       next;
534     }
535     print "Skipping unknown entry: `$_'\n";
536   }
537   close ULP;
538 }
539
540
541 # Clean up a floating point number
542 sub clean_up_number {
543   my ($number) = @_;
544
545   # Remove trailing zeros after the decimal point
546   if ($number =~ /\./) {
547     $number =~ s/0+$//;
548     $number =~ s/\.$//;
549   }
550   return $number;
551 }
552
553 # Output a file which can be read in as ulps file.
554 sub print_ulps_file {
555   my ($file) = @_;
556   my ($test, $type, $float, $eps, $fct, $last_fct);
557
558   $last_fct = '';
559   open NEWULP, ">$file" or die ("Can't open $file: $!");
560   print NEWULP "# Begin of automatic generation\n";
561   # first the function calls
562   foreach $test (sort keys %results) {
563     next if ($results{$test}{'kind'} ne 'test');
564     foreach $type ('real', 'imag', 'normal') {
565       if (exists $results{$test}{$type}) {
566         if (defined $results{$test}) {
567           ($fct) = ($test =~ /^(\w+)\s/);
568           if ($fct ne $last_fct) {
569             $last_fct = $fct;
570             print NEWULP "\n# $fct\n";
571           }
572         }
573         if ($type eq 'normal') {
574           print NEWULP "Test \"$test\":\n";
575         } elsif ($type eq 'real') {
576           print NEWULP "Test \"Real part of: $test\":\n";
577         } elsif ($type eq 'imag') {
578           print NEWULP "Test \"Imaginary part of: $test\":\n";
579         }
580         foreach $float (@all_floats) {
581           if (exists $results{$test}{$type}{'ulp'}{$float}) {
582             print NEWULP "$float: ",
583             &clean_up_number ($results{$test}{$type}{'ulp'}{$float}),
584             "\n";
585           }
586           if (exists $results{$test}{$type}{'fail'}{$float}) {
587             print NEWULP "$float: fail\n";
588           }
589         }
590       }
591     }
592   }
593   print NEWULP "\n# Maximal error of functions:\n";
594
595   foreach $fct (sort keys %results) {
596     next if ($results{$fct}{'kind'} ne 'fct');
597     foreach $type ('real', 'imag', 'normal') {
598       if (exists $results{$fct}{$type}) {
599         if ($type eq 'normal') {
600           print NEWULP "Function: \"$fct\":\n";
601         } elsif ($type eq 'real') {
602           print NEWULP "Function: Real part of \"$fct\":\n";
603         } elsif ($type eq 'imag') {
604           print NEWULP "Function: Imaginary part of \"$fct\":\n";
605         }
606         foreach $float (@all_floats) {
607           if (exists $results{$fct}{$type}{'ulp'}{$float}) {
608             print NEWULP "$float: ",
609             &clean_up_number ($results{$fct}{$type}{'ulp'}{$float}),
610             "\n";
611           }
612           if (exists $results{$fct}{$type}{'fail'}{$float}) {
613             print NEWULP "$float: fail\n";
614           }
615         }
616         print NEWULP "\n";
617       }
618     }
619   }
620   print NEWULP "# end of automatic generation\n";
621   close NEWULP;
622 }
623
624 sub get_ulps {
625   my ($test, $type, $float) = @_;
626
627   if ($type eq 'complex') {
628     my ($res);
629     # Return 0 instead of BUILD_COMPLEX (0,0)
630     if (!exists $results{$test}{'real'}{'ulp'}{$float} &&
631         !exists $results{$test}{'imag'}{'ulp'}{$float}) {
632       return "0";
633     }
634     $res = 'BUILD_COMPLEX (';
635     $res .= (exists $results{$test}{'real'}{'ulp'}{$float}
636              ? $results{$test}{'real'}{'ulp'}{$float} : "0");
637     $res .= ', ';
638     $res .= (exists $results{$test}{'imag'}{'ulp'}{$float}
639              ? $results{$test}{'imag'}{'ulp'}{$float} : "0");
640     $res .= ')';
641     return $res;
642   }
643   return (exists $results{$test}{'normal'}{'ulp'}{$float}
644           ? $results{$test}{'normal'}{'ulp'}{$float} : "0");
645 }
646
647 sub get_failure {
648   my ($test, $type, $float) = @_;
649   if ($type eq 'complex') {
650     # return x,y
651     my ($res);
652     # Return 0 instead of BUILD_COMPLEX_INT (0,0)
653     if (!exists $results{$test}{'real'}{'ulp'}{$float} &&
654         !exists $results{$test}{'imag'}{'ulp'}{$float}) {
655       return "0";
656     }
657     $res = 'BUILD_COMPLEX_INT (';
658     $res .= (exists $results{$test}{'real'}{'fail'}{$float}
659              ? $results{$test}{'real'}{'fail'}{$float} : "0");
660     $res .= ', ';
661     $res .= (exists $results{$test}{'imag'}{'fail'}{$float}
662              ? $results{$test}{'imag'}{'fail'}{$float} : "0");
663     $res .= ')';
664     return $res;
665   }
666   return (exists $results{$test}{'normal'}{'fail'}{$float}
667           ? $results{$test}{'normal'}{'fail'}{$float} : "0");
668
669 }
670
671 # Output the defines for a single test
672 sub output_test {
673   my ($file, $test, $name) = @_;
674   my ($ldouble, $double, $float, $ildouble, $idouble, $ifloat);
675   my ($type);
676
677   # Do we have ulps/failures?
678   if (!exists $results{$test}{'type'}) {
679     return;
680   }
681   $type = $results{$test}{'type'};
682   if (exists $results{$test}{'has_ulps'}) {
683     # XXX use all_floats (change order!)
684     $ldouble = &get_ulps ($test, $type, "ldouble");
685     $double = &get_ulps ($test, $type, "double");
686     $float = &get_ulps ($test, $type, "float");
687     $ildouble = &get_ulps ($test, $type, "ildouble");
688     $idouble = &get_ulps ($test, $type, "idouble");
689     $ifloat = &get_ulps ($test, $type, "ifloat");
690     print $file "#define DELTA$name CHOOSE($ldouble, $double, $float, $ildouble, $idouble, $ifloat)\t/* $test  */\n";
691   }
692
693   if (exists $results{$test}{'has_fails'}) {
694     $ldouble = &get_failure ($test, "ldouble");
695     $double = &get_failure ($test, "double");
696     $float = &get_failure ($test, "float");
697     $ildouble = &get_failure ($test, "ildouble");
698     $idouble = &get_failure ($test, "idouble");
699     $ifloat = &get_failure ($test, "ifloat");
700     print $file "#define FAIL$name CHOOSE($ldouble, $double, $float $ildouble, $idouble, $ifloat)\t/* $test  */\n";
701   }
702 }
703
704 # Print include file
705 sub output_ulps {
706   my ($file, $ulps_filename) = @_;
707   my ($i, $fct);
708
709   open ULP, ">$file" or die ("Can't open $file: $!");
710
711   print ULP "/* This file is automatically generated\n";
712   print ULP "   from $ulps_filename with gen-libm-test.pl.\n";
713   print ULP "   Don't change it - change instead the master files.  */\n\n";
714
715   print ULP "\n/* Maximal error of functions.  */\n";
716   foreach $fct (@functions) {
717     output_test (\*ULP, $fct, $fct);
718   }
719
720   print ULP "\n/* Error of single function calls.  */\n";
721   for ($i = 0; $i < $count; $i++) {
722     output_test (\*ULP, $tests[$i], $i);
723   }
724   close ULP;
725 }