Update.
[glibc.git] / manual / libm-err-tab.pl
blob448bf801ab8b41f1702f3ce3ab6c32353d3ed321
1 #!/usr/bin/perl -w
3 # Copyright (C) 1999 Free Software Foundation, Inc.
4 # This file is part of the GNU C Library.
5 # Contributed by Andreas Jaeger <aj@suse.de>, 1999.
7 # The GNU C Library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Library General Public License as
9 # published by the Free Software Foundation; either version 2 of the
10 # License, or (at your option) any later version.
12 # The GNU C Library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Library General Public License for more details.
17 # You should have received a copy of the GNU Library General Public
18 # License along with the GNU C Library; see the file COPYING.LIB. If not,
19 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 # Boston, MA 02111-1307, USA.
22 # Information about tests are stored in: %results
23 # $results{$test}{"type"} is the result type, e.g. normal or complex.
24 # In the following description $platform, $type and $float are:
25 # - $platform is the used platform
26 # - $type is either "normal", "real" (for the real part of a complex number)
27 # or "imag" (for the imaginary part # of a complex number).
28 # - $float is either of float, ifloat, double, idouble, ldouble, ildouble;
29 # It represents the underlying floating point type (float, double or long
30 # double) and if inline functions (the leading i stands for inline)
31 # are used.
32 # $results{$test}{$platform}{$type}{$float} is defined and has a delta
33 # or 'fail' as value.
35 use File::Find;
37 use strict;
39 use vars qw ($sources @platforms %pplatforms);
40 use vars qw (%results @all_floats %suffices @all_functions);
43 # all_floats is in output order and contains all recognised float types that
44 # we're going to output
45 @all_floats = ('float', 'double', 'ldouble');
46 %suffices =
47 ( 'float' => 'f',
48 'double' => '',
49 'ldouble' => 'l'
52 # Pretty description of platform
53 %pplatforms =
54 ( "i386/fpu" => "ix86",
55 "generic" => "Generic",
56 "alpha" => "Alpha"
59 @all_functions =
60 ( "acos", "acosh", "asin", "asinh", "atan", "atanh",
61 "atan2", "cabs", "cacos", "cacosh", "carg", "casin", "casinh",
62 "catan", "catanh", "cbrt", "ccos", "ccosh", "ceil", "cexp", "cimag",
63 "clog", "clog10", "conj", "copysign", "cos", "cosh", "cpow", "cproj",
64 "creal", "csin", "csinh", "csqrt", "ctan", "ctanh", "erf", "erfc",
65 "exp", "exp10", "exp2", "expm1", "fabs", "fdim", "floor", "fma",
66 "fmax", "fmin", "fmod", "frexp", "gamma", "hypot",
67 "ilogb", "j0", "j1", "jn", "lgamma", "lrint",
68 "llrint", "log", "log10", "log1p", "log2", "logb", "lround",
69 "llround", "modf", "nearbyint", "nextafter", "nexttoward", "pow",
70 "remainder", "remquo", "rint", "round", "scalb", "scalbn", "scalbln",
71 "sin", "sincos", "sinh", "sqrt", "tan", "tanh", "tgamma",
72 "trunc", "y0", "y1", "yn" );
73 # "fpclassify", "isfinite", "isnormal", "signbit" are not tabulated
75 if ($#ARGV == 0) {
76 $sources = $ARGV[0];
77 } else {
78 $sources = '/usr/src/cvs/libc';
81 find (\&find_files, $sources);
83 &print_all;
85 sub find_files {
86 if ($_ eq 'libm-test-ulps') {
87 # print "Parsing $File::Find::name\n";
88 push @platforms, $File::Find::dir;
89 &parse_ulps ($File::Find::name, $File::Find::dir);
93 # Parse ulps file
94 sub parse_ulps {
95 my ($file, $platform) = @_;
96 my ($test, $type, $float, $eps, $kind);
98 # $type has the following values:
99 # "normal": No complex variable
100 # "real": Real part of complex result
101 # "imag": Imaginary part of complex result
102 open ULP, $file or die ("Can't open $file: $!");
103 while (<ULP>) {
104 chop;
105 # ignore comments and empty lines
106 next if /^#/;
107 next if /^\s*$/;
108 if (/^Test/) {
109 $kind = 'test';
110 next;
112 if (/^Function: /) {
113 if (/\Real part of/) {
114 s/Real part of //;
115 $type = 'real';
116 } elsif (/Imaginary part of/) {
117 s/Imaginary part of //;
118 $type = 'imag';
119 } else {
120 $type = 'normal';
122 ($test) = ($_ =~ /^Function:\s*\"([a-zA-Z0-9_]+)\"/);
123 $kind = 'fct';
124 next;
126 # Only handle maximal errors of functions
127 next if ($kind eq 'test');
128 if (/^i?(float|double|ldouble):/) {
129 ($float, $eps) = split /\s*:\s*/,$_,2;
130 if ($eps eq 'fail') {
131 $results{$test}{$platform}{$type}{$float} = 'fail';
132 } elsif ($eps eq "0") {
133 # ignore
134 next;
135 } elsif (!exists $results{$test}{$platform}{$type}{$float}
136 || $results{$test}{$platform}{$type}{$float} ne 'fail') {
137 $results{$test}{$platform}{$type}{$float} = $eps;
139 if ($type =~ /^real|imag$/) {
140 $results{$test}{'type'} = 'complex';
141 } elsif ($type eq 'normal') {
142 $results{$test}{'type'} = 'normal';
144 next;
146 print "Skipping unknown entry: `$_'\n";
148 close ULP;
151 sub get_value {
152 my ($fct, $platform, $type, $float) = @_;
154 return (exists $results{$fct}{$platform}{$type}{$float}
155 ? $results{$fct}{$platform}{$type}{$float} : "0");
158 sub canonicalize_platform {
159 my ($platform) = @_;
161 $platform =~ s|^(.*/sysdeps/)||;
164 return exists $pplatforms{$platform} ? $pplatforms{$platform} : $platform;
167 sub print_all {
168 my ($fct, $platform, $float, $first, $i);
170 print '@multitable {nexttowardf} ';
171 foreach (@platforms) {
172 print ' {1000 + i 1000}';
174 print "\n";
176 print '@item Function ';
177 foreach (@platforms) {
178 print ' @tab ';
179 print &canonicalize_platform ($_);
181 print "\n";
184 foreach $fct (@all_functions) {
185 foreach $float (@all_floats) {
186 print "\@item $fct$suffices{$float} ";
187 foreach $platform (@platforms) {
188 print ' @tab ';
189 if (exists $results{$fct}{$platform}{'normal'}{$float}
190 || exists $results{$fct}{$platform}{'real'}{$float}
191 || exists $results{$fct}{$platform}{'imag'}{$float}) {
192 if ($results{$fct}{'type'} eq 'complex') {
193 print &get_value ($fct, $platform, 'real', $float),
194 ' + i ', &get_value ($fct, $platform, 'imag', $float);
195 } else {
196 print $results{$fct}{$platform}{'normal'}{$float};
198 } else {
199 print '-';
202 print "\n";
206 print "\@end multitable\n";