Add missing libc_hidden_weak to stub if_nameindex, if_freenameindex.
[platform/upstream/glibc.git] / manual / libm-err-tab.pl
1 #!/usr/bin/perl -w
2 # Copyright (C) 1999-2015 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 # 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.
32
33 use File::Find;
34
35 use strict;
36
37 use vars qw ($sources @platforms %pplatforms);
38 use vars qw (%results @all_floats %suffices @all_functions);
39
40
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'
48   );
49
50 # Pretty description of platform
51 %pplatforms =
52   ( "i386/fpu" => "ix86",
53     "generic" => "Generic",
54     "alpha/fpu" => "Alpha",
55     "ia64/fpu" => "IA64",
56     "m68k/fpu" => "M68k",
57     "mips/fpu" => "MIPS",
58     "powerpc/fpu" => "PowerPC",
59     "sparc/sparc32/fpu" => "Sparc 32-bit",
60     "sparc/sparc64/fpu" => "Sparc 64-bit",
61     "sh/sh4/fpu" => "SH4",
62     "s390/fpu" => "S/390",
63     "arm" => "ARM"
64   );
65
66 @all_functions =
67   ( "acos", "acosh", "asin", "asinh", "atan", "atanh",
68     "atan2", "cabs", "cacos", "cacosh", "carg", "casin", "casinh",
69     "catan", "catanh", "cbrt", "ccos", "ccosh", "ceil", "cexp", "cimag",
70     "clog", "clog10", "conj", "copysign", "cos", "cosh", "cpow", "cproj",
71     "creal", "csin", "csinh", "csqrt", "ctan", "ctanh", "erf", "erfc",
72     "exp", "exp10", "exp2", "expm1", "fabs", "fdim", "floor", "fma",
73     "fmax", "fmin", "fmod", "frexp", "gamma", "hypot",
74     "ilogb", "j0", "j1", "jn", "lgamma", "lrint",
75     "llrint", "log", "log10", "log1p", "log2", "logb", "lround",
76     "llround", "modf", "nearbyint", "nextafter", "nexttoward", "pow",
77     "remainder", "remquo", "rint", "round", "scalb", "scalbn", "scalbln",
78     "sin", "sincos", "sinh", "sqrt", "tan", "tanh", "tgamma",
79     "trunc", "y0", "y1", "yn" );
80 # fpclassify, isnormal, isfinite, isinf, isnan, issignaling, signbit,
81 # isgreater, isgreaterequal, isless, islessequal, islessgreater, isunordered
82 # are not tabulated.
83
84 if ($#ARGV == 0) {
85   $sources = $ARGV[0];
86 } else {
87   $sources = '/usr/src/cvs/libc';
88 }
89
90 find (\&find_files, $sources);
91
92 @platforms = sort by_platforms @platforms;
93
94 &print_all;
95
96 sub find_files {
97   if ($_ eq 'libm-test-ulps') {
98     # print "Parsing $File::Find::name\n";
99     push @platforms, $File::Find::dir;
100     &parse_ulps ($File::Find::name, $File::Find::dir);
101   }
102 }
103
104 # Parse ulps file
105 sub parse_ulps {
106   my ($file, $platform) = @_;
107   my ($test, $type, $float, $eps);
108
109   # $type has the following values:
110   # "normal": No complex variable
111   # "real": Real part of complex result
112   # "imag": Imaginary part of complex result
113   open ULP, $file  or die ("Can't open $file: $!");
114   while (<ULP>) {
115     chop;
116     # ignore comments and empty lines
117     next if /^#/;
118     next if /^\s*$/;
119     if (/^Function: /) {
120       if (/Real part of/) {
121         s/Real part of //;
122         $type = 'real';
123       } elsif (/Imaginary part of/) {
124         s/Imaginary part of //;
125         $type = 'imag';
126       } else {
127         $type = 'normal';
128       }
129       ($test) = ($_ =~ /^Function:\s*\"([a-zA-Z0-9_]+)\"/);
130       next;
131     }
132     if (/^i?(float|double|ldouble):/) {
133       ($float, $eps) = split /\s*:\s*/,$_,2;
134       if ($eps eq 'fail') {
135         $results{$test}{$platform}{$type}{$float} = 'fail';
136       } elsif ($eps eq "0") {
137         # ignore
138         next;
139       } elsif (!exists $results{$test}{$platform}{$type}{$float}
140             || $results{$test}{$platform}{$type}{$float} ne 'fail') {
141         $results{$test}{$platform}{$type}{$float} = $eps;
142       }
143       if ($type =~ /^real|imag$/) {
144         $results{$test}{'type'} = 'complex';
145       } elsif ($type eq 'normal') {
146         $results{$test}{'type'} = 'normal';
147       }
148       next;
149     }
150     print "Skipping unknown entry: `$_'\n";
151   }
152   close ULP;
153 }
154
155 sub get_value {
156   my ($fct, $platform, $type, $float) = @_;
157
158   return (exists $results{$fct}{$platform}{$type}{$float}
159           ? $results{$fct}{$platform}{$type}{$float} : "0");
160 }
161
162 sub canonicalize_platform {
163   my ($platform) = @_;
164
165   $platform =~ s|^(.*/sysdeps/)||;
166
167
168   return exists $pplatforms{$platform} ? $pplatforms{$platform} : $platform;
169 }
170
171 sub print_platforms {
172   my (@p) = @_;
173   my ($fct, $platform, $float, $first, $i, $platform_no, $platform_total);
174
175   print '@multitable {nexttowardf} ';
176   foreach (@p) {
177     print ' {1000 + i 1000}';
178   }
179   print "\n";
180
181   print '@item Function ';
182   foreach (@p) {
183     print ' @tab ';
184     print &canonicalize_platform ($_);
185   }
186   print "\n";
187
188
189   foreach $fct (@all_functions) {
190     foreach $float (@all_floats) {
191       print "\@item $fct$suffices{$float} ";
192       foreach $platform (@p) {
193         print ' @tab ';
194         if (exists $results{$fct}{$platform}{'normal'}{$float}
195             || exists $results{$fct}{$platform}{'real'}{$float}
196             || exists $results{$fct}{$platform}{'imag'}{$float}) {
197           if ($results{$fct}{'type'} eq 'complex') {
198             print &get_value ($fct, $platform, 'real', $float),
199             ' + i ', &get_value ($fct, $platform, 'imag', $float);
200           } else {
201             print $results{$fct}{$platform}{'normal'}{$float};
202           }
203         } else {
204           print '-';
205         }
206       }
207       print "\n";
208     }
209   }
210
211   print "\@end multitable\n";
212 }
213
214 sub print_all {
215   my ($i, $max);
216
217   my ($columns) = 5;
218
219   # Print only 5 platforms at a time.
220   for ($i=0; $i < $#platforms; $i+=$columns) {
221     $max = $i+$columns-1 > $#platforms ? $#platforms : $i+$columns-1;
222     print_platforms (@platforms[$i .. $max]);
223   }
224 }
225
226 sub by_platforms {
227   my ($pa, $pb);
228
229   $pa = $pplatforms{$a} ? $pplatforms{$a} : $a;
230   $pb = $pplatforms{$b} ? $pplatforms{$b} : $b;
231
232   return $pa cmp $pb;
233 }