#!/usr/bin/perl -w
# Copyright (C) 1999-2017 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# Contributed by Andreas Jaeger <aj@suse.de>, 1999.
# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# The GNU C Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with the GNU C Library; if not, see
# <http://www.gnu.org/licenses/>.
# This file needs to be tidied up
# Note that functions and tests share the same namespace.
# Information about tests are stored in: %results
# $results{$test}{"type"} is the result type, e.g. normal or complex.
# $results{$test}{"has_ulps"} is set if deltas exist.
# In the following description $type and $float are:
# - $type is either "normal", "real" (for the real part of a complex number)
# or "imag" (for the imaginary part # of a complex number).
# - $float is either of float, ifloat, double, idouble, ldouble, ildouble;
# It represents the underlying floating point type (float, double or long
# double) and if inline functions (the leading i stands for inline)
# are used.
# $results{$test}{$type}{"ulp"}{$float} is defined and has a delta as value
use Getopt::Std;
use strict;
use vars qw ($input $output $auto_input);
use vars qw (%results);
use vars qw (%beautify @all_floats %all_floats_pfx);
use vars qw ($ulps_file);
use vars qw (%auto_tests);
# all_floats is sorted and contains all recognised float types
@all_floats = ('double', 'float', 'idouble',
'ifloat', 'ildouble', 'ldouble');
# all_floats_pfx maps C types to their C like prefix for macros.
%all_floats_pfx =
( "double" => "DBL",
"ldouble" => "LDBL",
"float" => "FLT",
);
%beautify =
( "minus_zero" => "-0",
"plus_zero" => "+0",
"-0x0p+0f" => "-0",
"-0x0p+0" => "-0",
"-0x0p+0L" => "-0",
"0x0p+0f" => "+0",
"0x0p+0" => "+0",
"0x0p+0L" => "+0",
"minus_infty" => "-inf",
"plus_infty" => "inf",
"qnan_value" => "qNaN",
"snan_value" => "sNaN",
"snan_value_ld" => "sNaN",
);
# get Options
# Options:
# a: auto-libm-test-out input file
# c: .inc input file
# u: ulps-file
# n: new ulps file
# C: libm-test.c output file
# H: libm-test-ulps.h output file
# h: help
use vars qw($opt_a $opt_c $opt_u $opt_n $opt_C $opt_H $opt_h);
getopts('a:c:u:n:C:H:h');
$ulps_file = 'libm-test-ulps';