(linenum→info "unix/slp.c:2238")

glibc/2.7/manual/libm-err-tab.pl

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