Define __ASSUME_ST_INO_64_BIT on all platforms.
[glibc.git] / manual / libm-err-tab.pl
blob3ea62c549e883c5b846f9e0450988ccd927a1ee7
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", "fmin", "fmod", "frexp", "gamma", "hypot",
61 "ilogb", "j0", "j1", "jn", "lgamma", "lrint",
62 "llrint", "log", "log10", "log1p", "log2", "logb", "lround",
63 "llround", "modf", "nearbyint", "nextafter", "nextdown", "nexttoward",
64 "nextup", "pow", "remainder", "remquo", "rint", "round", "scalb",
65 "scalbn", "sin", "sincos", "sinh", "sqrt", "tan", "tanh", "tgamma",
66 "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, totalorder, totalordermag
71 # are not tabulated.
73 if ($#ARGV == 0) {
74 $sources = $ARGV[0];
75 } else {
76 $sources = '/usr/src/cvs/libc';
79 find (\&find_files, $sources);
81 @platforms = sort by_platforms @platforms;
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 my ($file, $name);
90 $file = "${File::Find::name}-name";
91 open NAME, $file or die ("Can't open $file: $!");
92 $name = <NAME>;
93 chomp $name;
94 close NAME;
95 $pplatforms{$File::Find::dir} = $name;
96 &parse_ulps ($File::Find::name, $File::Find::dir);
100 # Parse ulps file
101 sub parse_ulps {
102 my ($file, $platform) = @_;
103 my ($test, $type, $float, $eps);
105 # $type has the following values:
106 # "normal": No complex variable
107 # "real": Real part of complex result
108 # "imag": Imaginary part of complex result
109 open ULP, $file or die ("Can't open $file: $!");
110 while (<ULP>) {
111 chop;
112 # ignore comments and empty lines
113 next if /^#/;
114 next if /^\s*$/;
115 if (/^Function: /) {
116 if (/Real part of/) {
117 s/Real part of //;
118 $type = 'real';
119 } elsif (/Imaginary part of/) {
120 s/Imaginary part of //;
121 $type = 'imag';
122 } else {
123 $type = 'normal';
125 ($test) = ($_ =~ /^Function:\s*\"([a-zA-Z0-9_]+)\"/);
126 next;
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 print_platforms {
159 my (@p) = @_;
160 my ($fct, $platform, $float, $first, $i, $platform_no, $platform_total);
162 print '@multitable {nexttowardf} ';
163 foreach (@p) {
164 print ' {1000 + i 1000}';
166 print "\n";
168 print '@item Function ';
169 foreach (@p) {
170 print ' @tab ';
171 print $pplatforms{$_};
173 print "\n";
176 foreach $fct (@all_functions) {
177 foreach $float (@all_floats) {
178 print "\@item $fct$suffices{$float} ";
179 foreach $platform (@p) {
180 print ' @tab ';
181 if (exists $results{$fct}{$platform}{'normal'}{$float}
182 || exists $results{$fct}{$platform}{'real'}{$float}
183 || exists $results{$fct}{$platform}{'imag'}{$float}) {
184 if ($results{$fct}{'type'} eq 'complex') {
185 print &get_value ($fct, $platform, 'real', $float),
186 ' + i ', &get_value ($fct, $platform, 'imag', $float);
187 } else {
188 print $results{$fct}{$platform}{'normal'}{$float};
190 } else {
191 print '-';
194 print "\n";
198 print "\@end multitable\n";
201 sub print_all {
202 my ($i, $max);
204 my ($columns) = 5;
206 # Print only 5 platforms at a time.
207 for ($i=0; $i < $#platforms; $i+=$columns) {
208 $max = $i+$columns-1 > $#platforms ? $#platforms : $i+$columns-1;
209 print_platforms (@platforms[$i .. $max]);
213 sub by_platforms {
214 return $pplatforms{$a} cmp $pplatforms{$b};