1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-07 06:43:00 +03:00

float128: Add test-{float128,ifloat128,float128-finite}

This adds test support for float128, and lays some groundwork for future
_FloatN types.

	* math/gen-libm-test.pl (@all_floats): Add ifloat128 and float128.
	(%all_floats_pfx): Add macro prefix for float128 (FLT128).
	* math/libm-test-exp10.inc (pow10_test): Do not test for _FloatN,
	* math/libm-test-isfinite.inc (finite_test): Likewise.
	* math/libm-test-lgamma.inc (gamma_test): Likewise.
	* math/libm-test-nexttoward.inc (nexttoward_test): Likewise.
	(nexttoward_test_data}: Likewise.
	* math/libm-test-remainder.inc (drem_test): Likewise.
	* math/libm-test-scalb.inc (scalb_test): Likewise.
	(scalb_test_data): Likewise.
	* math/libm-test-significand.inc (significand_test): Likewise.
	(significand_test_data): Likewise.
	* math/libm-test-support.c (check_complex): Replace __complex__
	FLOAT with CFLOAT to get the support for old compiler.
	* math/libm-test-support.h (check_complex): Likewise.
	* math/test-double.h (CFLOAT, TEST_FLOATN): New macros.
	* math/test-float.h (CFLOAT, TEST_FLOATN): Likewise.
	* math/test-ldouble.h (CFLOAT, TEST_FLOATN): Likewise.
	* math/test-float128.h: New file.
	* math/test-math-floatn.h: New file.
This commit is contained in:
Paul E. Murphy
2016-07-15 14:29:51 -05:00
committed by Gabriel F. T. Gomes
parent 8fd3101431
commit 3c023dbf57
16 changed files with 112 additions and 5 deletions

View File

@@ -1,3 +1,28 @@
2017-06-12 Paul E. Murphy <murphyp@linux.vnet.ibm.com>
Gabriel F. T. Gomes <gftg@linux.vnet.ibm.com>
Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
* math/gen-libm-test.pl (@all_floats): Add ifloat128 and float128.
(%all_floats_pfx): Add macro prefix for float128 (FLT128).
* math/libm-test-exp10.inc (pow10_test): Do not test for _FloatN,
* math/libm-test-isfinite.inc (finite_test): Likewise.
* math/libm-test-lgamma.inc (gamma_test): Likewise.
* math/libm-test-nexttoward.inc (nexttoward_test): Likewise.
(nexttoward_test_data}: Likewise.
* math/libm-test-remainder.inc (drem_test): Likewise.
* math/libm-test-scalb.inc (scalb_test): Likewise.
(scalb_test_data): Likewise.
* math/libm-test-significand.inc (significand_test): Likewise.
(significand_test_data): Likewise.
* math/libm-test-support.c (check_complex): Replace __complex__
FLOAT with CFLOAT to get the support for old compiler.
* math/libm-test-support.h (check_complex): Likewise.
* math/test-double.h (CFLOAT, TEST_FLOATN): New macros.
* math/test-float.h (CFLOAT, TEST_FLOATN): Likewise.
* math/test-ldouble.h (CFLOAT, TEST_FLOATN): Likewise.
* math/test-float128.h: New file.
* math/test-math-floatn.h: New file.
2017-06-12 Gabriel F. T. Gomes <gftg@linux.vnet.ibm.com> 2017-06-12 Gabriel F. T. Gomes <gftg@linux.vnet.ibm.com>
* include/float.h: Allow the definition of macros prefixed with * include/float.h: Allow the definition of macros prefixed with

View File

@@ -44,14 +44,15 @@ use vars qw ($ulps_file);
use vars qw (%auto_tests); use vars qw (%auto_tests);
# all_floats is sorted and contains all recognised float types # all_floats is sorted and contains all recognised float types
@all_floats = ('double', 'float', 'idouble', @all_floats = ('double', 'float', 'float128', 'idouble',
'ifloat', 'ildouble', 'ldouble'); 'ifloat', 'ifloat128', 'ildouble', 'ldouble');
# all_floats_pfx maps C types to their C like prefix for macros. # all_floats_pfx maps C types to their C like prefix for macros.
%all_floats_pfx = %all_floats_pfx =
( "double" => "DBL", ( "double" => "DBL",
"ldouble" => "LDBL", "ldouble" => "LDBL",
"float" => "FLT", "float" => "FLT",
"float128" => "FLT128",
); );
%beautify = %beautify =

View File

@@ -39,8 +39,10 @@ exp10_test (void)
static void static void
pow10_test (void) pow10_test (void)
{ {
#if !TEST_FLOATN
/* pow10 uses the same test data as exp10. */ /* pow10 uses the same test data as exp10. */
ALL_RM_TEST (pow10, 0, exp10_test_data, RUN_TEST_LOOP_f_f, END); ALL_RM_TEST (pow10, 0, exp10_test_data, RUN_TEST_LOOP_f_f, END);
#endif
} }
static void static void

View File

@@ -47,7 +47,9 @@ static void
finite_test (void) finite_test (void)
{ {
/* finite uses the same test data as isfinite. */ /* finite uses the same test data as isfinite. */
#if !TEST_FLOATN
ALL_RM_TEST (finite, 1, isfinite_test_data, RUN_TEST_LOOP_f_b, END); ALL_RM_TEST (finite, 1, isfinite_test_data, RUN_TEST_LOOP_f_b, END);
#endif
} }
static void static void

View File

@@ -45,8 +45,10 @@ lgamma_test (void)
static void static void
gamma_test (void) gamma_test (void)
{ {
#if !TEST_FLOATN
/* gamma uses the same test data as lgamma. */ /* gamma uses the same test data as lgamma. */
ALL_RM_TEST (gamma, 0, lgamma_test_data, RUN_TEST_LOOP_f_f1, END, signgam); ALL_RM_TEST (gamma, 0, lgamma_test_data, RUN_TEST_LOOP_f_f1, END, signgam);
#endif
} }
static void static void

View File

@@ -20,6 +20,7 @@
static const struct test_fj_f_data nexttoward_test_data[] = static const struct test_fj_f_data nexttoward_test_data[] =
{ {
#if !TEST_FLOATN
TEST_fj_f (nexttoward, 0, 0, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), TEST_fj_f (nexttoward, 0, 0, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_fj_f (nexttoward, minus_zero, 0, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), TEST_fj_f (nexttoward, minus_zero, 0, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_fj_f (nexttoward, 0, minus_zero, minus_zero, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), TEST_fj_f (nexttoward, 0, minus_zero, minus_zero, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
@@ -80,6 +81,7 @@ static const struct test_fj_f_data nexttoward_test_data[] =
TEST_fj_f (nexttoward, min_subnorm_value, minus_zero, 0, INEXACT_EXCEPTION|UNDERFLOW_EXCEPTION|ERRNO_ERANGE), TEST_fj_f (nexttoward, min_subnorm_value, minus_zero, 0, INEXACT_EXCEPTION|UNDERFLOW_EXCEPTION|ERRNO_ERANGE),
TEST_fj_f (nexttoward, -min_subnorm_value, 0, minus_zero, INEXACT_EXCEPTION|UNDERFLOW_EXCEPTION|ERRNO_ERANGE), TEST_fj_f (nexttoward, -min_subnorm_value, 0, minus_zero, INEXACT_EXCEPTION|UNDERFLOW_EXCEPTION|ERRNO_ERANGE),
TEST_fj_f (nexttoward, -min_subnorm_value, minus_zero, minus_zero, INEXACT_EXCEPTION|UNDERFLOW_EXCEPTION|ERRNO_ERANGE), TEST_fj_f (nexttoward, -min_subnorm_value, minus_zero, minus_zero, INEXACT_EXCEPTION|UNDERFLOW_EXCEPTION|ERRNO_ERANGE),
#endif
#if TEST_COND_binary32 #if TEST_COND_binary32
TEST_fj_f (nexttoward, 1.0, 1.1L, 0x1.000002p0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), TEST_fj_f (nexttoward, 1.0, 1.1L, 0x1.000002p0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
@@ -153,7 +155,9 @@ static const struct test_fj_f_data nexttoward_test_data[] =
static void static void
nexttoward_test (void) nexttoward_test (void)
{ {
#if !TEST_FLOATN
ALL_RM_TEST (nexttoward, 1, nexttoward_test_data, RUN_TEST_LOOP_fj_f, END); ALL_RM_TEST (nexttoward, 1, nexttoward_test_data, RUN_TEST_LOOP_fj_f, END);
#endif
} }
static void static void

View File

@@ -184,8 +184,10 @@ remainder_test (void)
static void static void
drem_test (void) drem_test (void)
{ {
#if !TEST_FLOATN
/* drem uses the same test data as remainder. */ /* drem uses the same test data as remainder. */
ALL_RM_TEST (drem, 1, remainder_test_data, RUN_TEST_LOOP_ff_f, END); ALL_RM_TEST (drem, 1, remainder_test_data, RUN_TEST_LOOP_ff_f, END);
#endif
} }
static void static void

View File

@@ -20,6 +20,7 @@
static const struct test_ff_f_data scalb_test_data[] = static const struct test_ff_f_data scalb_test_data[] =
{ {
#if !TEST_FLOATN
/* Results in this case are unspecified by POSIX, so, for an /* Results in this case are unspecified by POSIX, so, for an
otherwise fully-determined function, spurious "inexact" otherwise fully-determined function, spurious "inexact"
exceptions are OK. */ exceptions are OK. */
@@ -144,12 +145,15 @@ static const struct test_ff_f_data scalb_test_data[] =
TEST_ff_f (scalb, 0.8L, 4, 12.8L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), TEST_ff_f (scalb, 0.8L, 4, 12.8L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_ff_f (scalb, -0.854375L, 5, -27.34L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), TEST_ff_f (scalb, -0.854375L, 5, -27.34L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
#endif
}; };
static void static void
scalb_test (void) scalb_test (void)
{ {
#if !TEST_FLOATN
ALL_RM_TEST (scalb, 1, scalb_test_data, RUN_TEST_LOOP_ff_f, END); ALL_RM_TEST (scalb, 1, scalb_test_data, RUN_TEST_LOOP_ff_f, END);
#endif
} }
static void static void

View File

@@ -20,6 +20,7 @@
static const struct test_f_f_data significand_test_data[] = static const struct test_f_f_data significand_test_data[] =
{ {
#if !TEST_FLOATN
/* significand returns the mantissa of the exponential /* significand returns the mantissa of the exponential
representation. Tests for infinities, zero and NaNs reflect representation. Tests for infinities, zero and NaNs reflect
the implementation (including possibility of "inexact" and the implementation (including possibility of "inexact" and
@@ -45,12 +46,15 @@ static const struct test_f_f_data significand_test_data[] =
TEST_f_f (significand, -6.0, -1.5, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), TEST_f_f (significand, -6.0, -1.5, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_f (significand, 8.0, 1.0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), TEST_f_f (significand, 8.0, 1.0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_f (significand, -8.0, -1.0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), TEST_f_f (significand, -8.0, -1.0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
#endif
}; };
static void static void
significand_test (void) significand_test (void)
{ {
#if !TEST_FLOATN
ALL_RM_TEST (significand, 1, significand_test_data, RUN_TEST_LOOP_f_f, END); ALL_RM_TEST (significand, 1, significand_test_data, RUN_TEST_LOOP_f_f, END);
#endif
} }
static void static void

View File

@@ -732,8 +732,8 @@ check_float (const char *test_name, FLOAT computed, FLOAT expected,
void void
check_complex (const char *test_name, __complex__ FLOAT computed, check_complex (const char *test_name, CFLOAT computed,
__complex__ FLOAT expected, CFLOAT expected,
int exception) int exception)
{ {
FLOAT part_comp, part_exp; FLOAT part_comp, part_exp;

View File

@@ -143,7 +143,7 @@ void init_max_error (const char *, int);
void print_max_error (const char *); void print_max_error (const char *);
void print_complex_max_error (const char *); void print_complex_max_error (const char *);
void check_float (const char *, FLOAT, FLOAT, int); void check_float (const char *, FLOAT, FLOAT, int);
void check_complex (const char *, __complex__ FLOAT, __complex__ FLOAT, int); void check_complex (const char *, CFLOAT, CFLOAT, int);
void check_int (const char *, int, int, int); void check_int (const char *, int, int, int);
void check_long (const char *, long int, long int, int); void check_long (const char *, long int, long int, int);
void check_bool (const char *, int, int, int); void check_bool (const char *, int, int, int);

View File

@@ -18,6 +18,7 @@
#define FUNC(function) function #define FUNC(function) function
#define FLOAT double #define FLOAT double
#define CFLOAT __complex__ double
#define BUILD_COMPLEX(real, imag) (CMPLX ((real), (imag))) #define BUILD_COMPLEX(real, imag) (CMPLX ((real), (imag)))
#define PREFIX DBL #define PREFIX DBL
#define LIT(x) (x) #define LIT(x) (x)
@@ -25,3 +26,4 @@
#define LITM(x) x #define LITM(x) x
#define FTOSTR strfromd #define FTOSTR strfromd
#define snan_value_MACRO SNAN #define snan_value_MACRO SNAN
#define TEST_FLOATN 0

View File

@@ -18,6 +18,7 @@
#define FUNC(function) function ## f #define FUNC(function) function ## f
#define FLOAT float #define FLOAT float
#define CFLOAT __complex__ float
#define BUILD_COMPLEX(real, imag) (CMPLXF ((real), (imag))) #define BUILD_COMPLEX(real, imag) (CMPLXF ((real), (imag)))
#define PREFIX FLT #define PREFIX FLT
#define TYPE_STR "float" #define TYPE_STR "float"
@@ -26,3 +27,4 @@
#define LITM(x) x #define LITM(x) x
#define FTOSTR strfromf #define FTOSTR strfromf
#define snan_value_MACRO SNANF #define snan_value_MACRO SNANF
#define TEST_FLOATN 0

35
math/test-float128.h Normal file
View File

@@ -0,0 +1,35 @@
/* Common definitions for libm tests for _Float128.
Copyright (C) 2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
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/>. */
#include "test-math-floatn.h"
/* Fixup builtins and constants for older compilers. */
#include <bits/floatn.h>
#include <float.h>
#define FUNC(function) function ## f128
#define FLOAT _Float128
#define CFLOAT __CFLOAT128
#define BUILD_COMPLEX(real, imag) (CMPLXF128 ((real), (imag)))
#define PREFIX FLT128
#define TYPE_STR "float128"
#define LIT(x) __f128 (x)
#define LITM(x) x ## f128
#define FTOSTR strfromf128
#define snan_value_MACRO SNANF128

View File

@@ -18,6 +18,7 @@
#define FUNC(function) function##l #define FUNC(function) function##l
#define FLOAT long double #define FLOAT long double
#define CFLOAT __complex__ long double
#define BUILD_COMPLEX(real, imag) (CMPLXL ((real), (imag))) #define BUILD_COMPLEX(real, imag) (CMPLXL ((real), (imag)))
#define PREFIX LDBL #define PREFIX LDBL
#define TYPE_STR "ldouble" #define TYPE_STR "ldouble"
@@ -25,3 +26,4 @@
#define LITM(x) x ## l #define LITM(x) x ## l
#define FTOSTR strfroml #define FTOSTR strfroml
#define snan_value_MACRO SNANL #define snan_value_MACRO SNANL
#define TEST_FLOATN 0

20
math/test-math-floatn.h Normal file
View File

@@ -0,0 +1,20 @@
/* Common definitions for libm tests for TS 18661-3 derived types.
Copyright (C) 2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
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/>. */
#define TEST_FLOATN 1
#define __STDC_WANT_IEC_60559_TYPES_EXT__