Add roundeven, roundevenf, roundevenl.
[glibc.git] / manual / libm-err-tab.pl
blob9b8aa664ae3fc04c2e7c2a00843ad8bdc2f1b06b
1 #!/usr/bin/perl -w
2 # Copyright (C) 1999-2016 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 # Information about tests are stored in: %results
21 # $results{$test}{"type"} is the result type, e.g. normal or complex.
22 # In the following description $platform, $type and $float are:
23 # - $platform is the used platform
24 # - $type is either "normal", "real" (for the real part of a complex number)
25 # or "imag" (for the imaginary part # of a complex number).
26 # - $float is either of float, ifloat, double, idouble, ldouble, ildouble;
27 # It represents the underlying floating point type (float, double or long
28 # double) and if inline functions (the leading i stands for inline)
29 # are used.
30 # $results{$test}{$platform}{$type}{$float} is defined and has a delta
31 # or 'fail' as value.
33 use File::Find;
35 use strict;
37 use vars qw ($sources @platforms %pplatforms);
38 use vars qw (%results @all_floats %suffices @all_functions);
41 # all_floats is in output order and contains all recognised float types that
42 # we're going to output
43 @all_floats = ('float', 'double', 'ldouble');
44 %suffices =
45 ( 'float' => 'f',
46 'double' => '',
47 'ldouble' => 'l'
50 # Pretty description of platform
51 %pplatforms = ();
53 @all_functions =
54 ( "acos", "acosh", "asin", "asinh", "atan", "atanh",
55 "atan2", "cabs", "cacos", "cacosh", "carg", "casin", "casinh",
56 "catan", "catanh", "cbrt", "ccos", "ccosh", "ceil", "cexp", "cimag",
57 "clog", "clog10", "conj", "copysign", "cos", "cosh", "cpow", "cproj",
58 "creal", "csin", "csinh", "csqrt", "ctan", "ctanh", "erf", "erfc",
59 "exp", "exp10", "exp2", "expm1", "fabs", "fdim", "floor", "fma",
60 "fmax", "fmaxmag", "fmin", "fminmag", "fmod", "frexp", "gamma", "hypot",
61 "ilogb", "j0", "j1", "jn", "lgamma", "llogb", "lrint",
62 "llrint", "log", "log10", "log1p", "log2", "logb", "lround",
63 "llround", "modf", "nearbyint", "nextafter", "nextdown", "nexttoward",
64 "nextup", "pow", "remainder", "remquo", "rint", "round", "roundeven",
65 "scalb", "scalbn", "sin", "sincos", "sinh", "sqrt", "tan", "tanh",
66 "tgamma", "trunc", "y0", "y1", "yn" );
67 # canonicalize, fpclassify, getpayload, iscanonical, isnormal,
68 # isfinite, isinf, isnan, issignaling, issubnormal, iszero, signbit,
69 # iseqsig, isgreater, isgreaterequal, isless, islessequal,
70 # islessgreater, isunordered, setpayload, setpayloadsig,
71 # totalorder, totalordermag
72 # are not tabulated.
74 if ($#ARGV == 0) {
75 $sources = $ARGV[0];
76 } else {
77 $sources = '/usr/src/cvs/libc';
80 find (\&find_files, $sources);
82 @platforms = sort by_platforms @platforms;
84 &print_all;
86 sub find_files {
87 if ($_ eq 'libm-test-ulps') {
88 # print "Parsing $File::Find::name\n";
89 push @platforms, $File::Find::dir;
90 my ($file, $name);
91 $file = "${File::Find::name}-name";
92 open NAME, $file or die ("Can't open $file: $!");
93 $name = <NAME>;
94 chomp $name;
95 close NAME;
96 $pplatforms{$File::Find::dir} = $name;
97 &parse_ulps ($File::Find::name, $File::Find::dir);
101 # Parse ulps file
102 sub parse_ulps {
103 my ($file, $platform) = @_;
104 my ($test, $type, $float, $eps);
106 # $type has the following values:
107 # "normal": No complex variable
108 # "real": Real part of complex result
109 # "imag": Imaginary part of complex result
110 open ULP, $file or die ("Can't open $file: $!");
111 while (<ULP>) {
112 chop;
113 # ignore comments and empty lines
114 next if /^#/;
115 next if /^\s*$/;
116 if (/^Function: /) {
117 if (/Real part of/) {
118 s/Real part of //;
119 $type = 'real';
120 } elsif (/Imaginary part of/) {
121 s/Imaginary part of //;
122 $type = 'imag';
123 } else {
124 $type = 'normal';
126 ($test) = ($_ =~ /^Function:\s*\"([a-zA-Z0-9_]+)\"/);
127 next;
129 if (/^i?(float|double|ldouble):/) {
130 ($float, $eps) = split /\s*:\s*/,$_,2;
131 if ($eps eq 'fail') {
132 $results{$test}{$platform}{$type}{$float} = 'fail';
133 } elsif ($eps eq "0") {
134 # ignore
135 next;
136 } elsif (!exists $results{$test}{$platform}{$type}{$float}
137 || $results{$test}{$platform}{$type}{$float} ne 'fail') {
138 $results{$test}{$platform}{$type}{$float} = $eps;
140 if ($type =~ /^real|imag$/) {
141 $results{$test}{'type'} = 'complex';
142 } elsif ($type eq 'normal') {
143 $results{$test}{'type'} = 'normal';
145 next;
147 print "Skipping unknown entry: `$_'\n";
149 close ULP;
152 sub get_value {
153 my ($fct, $platform, $type, $float) = @_;
155 return (exists $results{$fct}{$platform}{$type}{$float}
156 ? $results{$fct}{$platform}{$type}{$float} : "0");
159 sub print_platforms {
160 my (@p) = @_;
161 my ($fct, $platform, $float, $first, $i, $platform_no, $platform_total);
163 print '@multitable {nexttowardf} ';
164 foreach (@p) {
165 print ' {1000 + i 1000}';
167 print "\n";
169 print '@item Function ';
170 foreach (@p) {
171 print ' @tab ';
172 print $pplatforms{$_};
174 print "\n";
177 foreach $fct (@all_functions) {
178 foreach $float (@all_floats) {
179 print "\@item $fct$suffices{$float} ";
180 foreach $platform (@p) {
181 print ' @tab ';
182 if (exists $results{$fct}{$platform}{'normal'}{$float}
183 || exists $results{$fct}{$platform}{'real'}{$float}
184 || exists $results{$fct}{$platform}{'imag'}{$float}) {
185 if ($results{$fct}{'type'} eq 'complex') {
186 print &get_value ($fct, $platform, 'real', $float),
187 ' + i ', &get_value ($fct, $platform, 'imag', $float);
188 } else {
189 print $results{$fct}{$platform}{'normal'}{$float};
191 } else {
192 print '-';
195 print "\n";
199 print "\@end multitable\n";
202 sub print_all {
203 my ($i, $max);
205 my ($columns) = 5;
207 # Print only 5 platforms at a time.
208 for ($i=0; $i < $#platforms; $i+=$columns) {
209 $max = $i+$columns-1 > $#platforms ? $#platforms : $i+$columns-1;
210 print_platforms (@platforms[$i .. $max]);
214 sub by_platforms {
215 return $pplatforms{$a} cmp $pplatforms{$b};