public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "Gabriel F. T. Gomes" <gftg@linux.vnet.ibm.com>
To: libc-alpha@sourceware.org
Subject: [PATCH 6/6] float128: Add test-{float128,ifloat128,float128-finite}
Date: Fri, 26 May 2017 12:57:00 -0000	[thread overview]
Message-ID: <1495803396-14558-7-git-send-email-gftg@linux.vnet.ibm.com> (raw)
In-Reply-To: <1495803396-14558-1-git-send-email-gftg@linux.vnet.ibm.com>

From: "Paul E. Murphy" <murphyp@linux.vnet.ibm.com>

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

	* math/Makefile
	(CFLAGS-test-float128.c): Add appropriate test flags.
	(CFLAGS-test-float128-finite.c): Likewise
	(CPPFLAGS-test-ifloat128.c): Likewise

	* math/test-support.h (CFLOAT): New macro to compensate for older
	compilers not supporting _Complex __float128.
	* math/libm-test-support.c (check_complex): Use CFLOAT instead
	of __complex__ FLOAT.

	* math/test-float128-finite.c: New file.
	* math/test-float128.c: New file.
	* math/test-float128.h: New file.
	* math/test-ifloat128.c: New file.
	* math/test-math-floatn.h: New file.

	* math/gen-libm-test.pl (all_floats): Add float128 variants.
	(all_floats_pfx): Add float128 mapping.

	* math/gen-libm-have-vector-test.sh: Add support for float128.
---
 math/gen-libm-test.pl          |  4 ++-
 math/libm-test-exp10.inc       |  2 ++
 math/libm-test-lgamma.inc      |  2 ++
 math/libm-test-nexttoward.inc  |  4 +++
 math/libm-test-remainder.inc   |  2 ++
 math/libm-test-scalb.inc       |  4 +++
 math/libm-test-significand.inc |  4 +++
 math/libm-test-support.c       |  4 +--
 math/libm-test-support.h       | 10 ++++++-
 math/test-float128.h           | 63 ++++++++++++++++++++++++++++++++++++++++++
 math/test-math-floatn.h        | 21 ++++++++++++++
 11 files changed, 116 insertions(+), 4 deletions(-)
 create mode 100644 math/test-float128.h
 create mode 100644 math/test-math-floatn.h

diff --git a/math/gen-libm-test.pl b/math/gen-libm-test.pl
index a931bc5..e82b2ac 100755
--- a/math/gen-libm-test.pl
+++ b/math/gen-libm-test.pl
@@ -45,13 +45,15 @@ use vars qw (%auto_tests);
 
 # all_floats is sorted and contains all recognised float types
 @all_floats = ('double', 'float', 'idouble',
-	       'ifloat', 'ildouble', 'ldouble');
+	       'ifloat', 'ildouble', 'ldouble',
+	       'ifloat128', 'float128');
 
 # all_floats_pfx maps C types to their C like prefix for macros.
 %all_floats_pfx =
   ( "double" => "DBL",
     "ldouble" => "LDBL",
     "float" => "FLT",
+    "float128" => "FLT128",
   );
 
 %beautify =
diff --git a/math/libm-test-exp10.inc b/math/libm-test-exp10.inc
index 92c81ad..374d12a 100644
--- a/math/libm-test-exp10.inc
+++ b/math/libm-test-exp10.inc
@@ -39,8 +39,10 @@ exp10_test (void)
 static void
 pow10_test (void)
 {
+#if !TEST_FLOATN
   /* pow10 uses the same test data as exp10.  */
   ALL_RM_TEST (pow10, 0, exp10_test_data, RUN_TEST_LOOP_f_f, END);
+#endif
 }
 
 static void
diff --git a/math/libm-test-lgamma.inc b/math/libm-test-lgamma.inc
index 9799aa9..0927dd0 100644
--- a/math/libm-test-lgamma.inc
+++ b/math/libm-test-lgamma.inc
@@ -45,8 +45,10 @@ lgamma_test (void)
 static void
 gamma_test (void)
 {
+#if !TEST_FLOATN
   /* gamma uses the same test data as lgamma.  */
   ALL_RM_TEST (gamma, 0, lgamma_test_data, RUN_TEST_LOOP_f_f1, END, signgam);
+#endif
 }
 
 static void
diff --git a/math/libm-test-nexttoward.inc b/math/libm-test-nexttoward.inc
index f05cf5f..37a9338 100644
--- a/math/libm-test-nexttoward.inc
+++ b/math/libm-test-nexttoward.inc
@@ -20,6 +20,7 @@
 
 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, minus_zero, 0, 0, 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, 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),
+#endif
 
 #if TEST_COND_binary32
     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
 nexttoward_test (void)
 {
+#if !TEST_FLOATN
   ALL_RM_TEST (nexttoward, 1, nexttoward_test_data, RUN_TEST_LOOP_fj_f, END);
+#endif
 }
 
 static void
diff --git a/math/libm-test-remainder.inc b/math/libm-test-remainder.inc
index ddeba66..65503c7 100644
--- a/math/libm-test-remainder.inc
+++ b/math/libm-test-remainder.inc
@@ -184,8 +184,10 @@ remainder_test (void)
 static void
 drem_test (void)
 {
+#if !TEST_FLOATN
   /* drem uses the same test data as remainder.  */
   ALL_RM_TEST (drem, 1, remainder_test_data, RUN_TEST_LOOP_ff_f, END);
+#endif
 }
 
 static void
diff --git a/math/libm-test-scalb.inc b/math/libm-test-scalb.inc
index 228a93d..b96f767 100644
--- a/math/libm-test-scalb.inc
+++ b/math/libm-test-scalb.inc
@@ -20,6 +20,7 @@
 
 static const struct test_ff_f_data scalb_test_data[] =
   {
+#if !TEST_FLOATN
     /* Results in this case are unspecified by POSIX, so, for an
        otherwise fully-determined function, spurious "inexact"
        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.854375L, 5, -27.34L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#endif
   };
 
 static void
 scalb_test (void)
 {
+#if !TEST_FLOATN
   ALL_RM_TEST (scalb, 1, scalb_test_data, RUN_TEST_LOOP_ff_f, END);
+#endif
 }
 
 static void
diff --git a/math/libm-test-significand.inc b/math/libm-test-significand.inc
index 372c076..5797e97 100644
--- a/math/libm-test-significand.inc
+++ b/math/libm-test-significand.inc
@@ -20,6 +20,7 @@
 
 static const struct test_f_f_data significand_test_data[] =
   {
+#if !TEST_FLOATN
     /* significand returns the mantissa of the exponential
        representation.  Tests for infinities, zero and NaNs reflect
        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, 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
 significand_test (void)
 {
+#if !TEST_FLOATN
   ALL_RM_TEST (significand, 1, significand_test_data, RUN_TEST_LOOP_f_f, END);
+#endif
 }
 
 static void
diff --git a/math/libm-test-support.c b/math/libm-test-support.c
index 07b8f25..7612d39 100644
--- a/math/libm-test-support.c
+++ b/math/libm-test-support.c
@@ -732,8 +732,8 @@ check_float (const char *test_name, FLOAT computed, FLOAT expected,
 
 
 void
-check_complex (const char *test_name, __complex__ FLOAT computed,
-	       __complex__ FLOAT expected,
+check_complex (const char *test_name, CFLOAT computed,
+	       CFLOAT expected,
 	       int exception)
 {
   FLOAT part_comp, part_exp;
diff --git a/math/libm-test-support.h b/math/libm-test-support.h
index 0e78144..a57a8b3 100644
--- a/math/libm-test-support.h
+++ b/math/libm-test-support.h
@@ -138,12 +138,20 @@ extern const char doc[];
 #define TEST_COND_before_rounding	(!TININESS_AFTER_ROUNDING)
 #define TEST_COND_after_rounding	TININESS_AFTER_ROUNDING
 
+#ifndef TEST_FLOATN
+# define TEST_FLOATN 0
+#endif
+
+#ifndef CFLOAT
+# define CFLOAT __complex__ FLOAT
+#endif
+
 int enable_test (int);
 void init_max_error (const char *, int);
 void print_max_error (const char *);
 void print_complex_max_error (const char *);
 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_long (const char *, long int, long int, int);
 void check_bool (const char *, int, int, int);
diff --git a/math/test-float128.h b/math/test-float128.h
new file mode 100644
index 0000000..177c10c
--- /dev/null
+++ b/math/test-float128.h
@@ -0,0 +1,63 @@
+/* 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/>.  */
+
+#define FUNC(function) function ## f128
+#define PRINTF_EXPR "e"
+#define PRINTF_XEXPR "a"
+#define PRINTF_NEXPR "f"
+#define BUILD_COMPLEX(real, imag) (CMPLXF128 ((real), (imag)))
+#define PREFIX FLT128
+#define TYPE_STR "float128"
+#define LITM(x) x ## f128
+#define FTOSTR strfromf128
+#define snan_value_MACRO SNANF128
+
+/* Fixup builtins and constants for older compilers.  */
+#include <features.h>
+#if !__GNUC_PREREQ (7, 0)
+# define LIT(x) (x ## Q)
+# define FLOAT __float128
+# define CFLOAT __CFLOAT128
+/* The following macros are only provided since GCC 7.0.  */
+# define FLT128_MANT_DIG	113
+# define FLT128_DECIMAL_DIG	36
+# define FLT128_DIG		33
+# define FLT128_MIN_EXP		(-16381)
+# define FLT128_MIN_10_EXP	(-4931)
+# define FLT128_MAX_EXP		16384
+# define FLT128_MAX_10_EXP	4932
+# define FLT128_MAX		1.18973149535723176508575932662800702e+4932Q
+# define FLT128_EPSILON		1.92592994438723585305597794258492732e-34Q
+# define FLT128_MIN		3.36210314311209350626267781732175260e-4932Q
+# define FLT128_TRUE_MIN	6.47517511943802511092443895822764655e-4966Q
+#else
+# define LIT(x) (x ## f128)
+# define FLOAT _Float128
+#endif
+
+#include "test-math-floatn.h"
+
+/* Similarly, finitef128 is not API */
+extern int __finitef128 (FLOAT);
+
+static inline int
+finitef128(FLOAT f)
+{
+  return __finitef128 (f);
+}
diff --git a/math/test-math-floatn.h b/math/test-math-floatn.h
new file mode 100644
index 0000000..a5e2eee
--- /dev/null
+++ b/math/test-math-floatn.h
@@ -0,0 +1,21 @@
+/* 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_BFP_EXT__
+#define __STDC_WANT_IEC_60559_TYPES_EXT__
-- 
2.4.11

  parent reply	other threads:[~2017-05-26 12:57 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-26 12:57 [PATCH 0/6] Add string functions and libm tests for _Float128 Gabriel F. T. Gomes
2017-05-26 12:57 ` [PATCH 4/6] float128: Add strtof128, wcstof128, and related functions Gabriel F. T. Gomes
2017-05-26 16:07   ` Joseph Myers
2017-05-26 12:57 ` [PATCH 2/6] float128: Add conversion from float128 to mpn Gabriel F. T. Gomes
2017-05-26 15:35   ` Joseph Myers
2017-05-30  2:31     ` Gabriel F. T. Gomes
2017-06-01 13:23       ` Joseph Myers
2017-06-01 23:52         ` Gabriel F. T. Gomes
2017-05-26 12:57 ` Gabriel F. T. Gomes [this message]
2017-05-26 16:26   ` [PATCH 6/6] float128: Add test-{float128,ifloat128,float128-finite} Joseph Myers
2017-05-26 12:57 ` [PATCH 5/6] float128: Add strfromf128, strtof128, and wcstof128 to the manual Gabriel F. T. Gomes
2017-05-26 13:29   ` Florian Weimer
2017-05-26 16:17   ` Joseph Myers
2017-05-26 12:57 ` [PATCH 3/6] float128: Add strfromf128 Gabriel F. T. Gomes
2017-05-26 15:56   ` Joseph Myers
2017-05-30  2:32     ` Gabriel F. T. Gomes
2017-06-02 16:31       ` Joseph Myers
2017-06-02 23:27         ` Gabriel F. T. Gomes
2017-05-26 12:57 ` [PATCH 1/6] float128: Extend the power of ten tables Gabriel F. T. Gomes
2017-05-26 15:30   ` Joseph Myers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1495803396-14558-7-git-send-email-gftg@linux.vnet.ibm.com \
    --to=gftg@linux.vnet.ibm.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).