]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - math/libm-test-support.h
math: Remove the error handling wrapper from fmod and fmodf
[thirdparty/glibc.git] / math / libm-test-support.h
index 0e781442aa3107238f1939162061d09ede3a1b62..de9d62e96cb21c38c997187f3cd9d06f275b9d4c 100644 (file)
@@ -1,5 +1,5 @@
 /* Support code for testing libm functions (common declarations).
-   Copyright (C) 1997-2017 Free Software Foundation, Inc.
+   Copyright (C) 1997-2023 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
@@ -14,7 +14,7 @@
 
    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/>.  */
+   <https://www.gnu.org/licenses/>.  */
 
 #ifndef LIBM_TEST_SUPPORT_H
 #define LIBM_TEST_SUPPORT_H 1
@@ -34,9 +34,8 @@
 
 extern const int flag_test_errno;
 extern const int flag_test_exceptions;
-extern const int flag_test_finite;
-extern const int flag_test_inline;
 extern const int flag_test_mathvec;
+extern const int snan_tests_arg;
 extern const char test_msg[];
 extern const char qtype_str[];
 extern const char doc[];
@@ -60,15 +59,13 @@ extern const char doc[];
 #define IGNORE_ZERO_INF_SIGN           0x400
 #define TEST_NAN_SIGN                  0x800
 #define TEST_NAN_PAYLOAD               0x1000
-#define NO_TEST_INLINE                 0x2000
 #define XFAIL_TEST                     0x4000
 /* Indicate errno settings required or disallowed.  */
 #define ERRNO_UNCHANGED                        0x8000
 #define ERRNO_EDOM                     0x10000
 #define ERRNO_ERANGE                   0x20000
-/* Flags generated by gen-libm-test.pl, not entered here manually.  */
+/* Flags generated by gen-libm-test.py, not entered here manually.  */
 #define IGNORE_RESULT                  0x40000
-#define NON_FINITE                     0x80000
 #define TEST_SNAN                      0x100000
 #define NO_TEST_MATHVEC                        0x200000
 
@@ -81,6 +78,13 @@ extern const char doc[];
 #define MAX_EXP __CONCATX (PREFIX, _MAX_EXP)
 #define MANT_DIG __CONCATX (PREFIX, _MANT_DIG)
 
+#define ARG_TYPE_MIN __CONCATX (ARG_PREFIX, _MIN)
+#define ARG_TYPE_TRUE_MIN __CONCATX (ARG_PREFIX, _TRUE_MIN)
+#define ARG_TYPE_MAX __CONCATX (ARG_PREFIX, _MAX)
+#define ARG_MIN_EXP __CONCATX (ARG_PREFIX, _MIN_EXP)
+#define ARG_MAX_EXP __CONCATX (ARG_PREFIX, _MAX_EXP)
+#define ARG_MANT_DIG __CONCATX (ARG_PREFIX, _MANT_DIG)
+
 /* Format specific test macros.  */
 #define TEST_COND_binary32 (MANT_DIG == 24     \
                            && MIN_EXP == -125  \
@@ -96,6 +100,8 @@ extern const char doc[];
 
 #define TEST_COND_ibm128 (MANT_DIG == 106)
 
+#define TEST_COND_arg_ibm128 (ARG_MANT_DIG == 106)
+
 #define TEST_COND_intel96 (MANT_DIG == 64      \
                           && MIN_EXP == -16381 \
                           && MAX_EXP == 16384)
@@ -108,13 +114,27 @@ extern const char doc[];
    where in principle the glibc code is OK but the tests fail because
    of limitations of the libgcc support for that format (e.g. GCC bug
    59666, in non-default rounding modes).  */
-#define TEST_COND_ibm128_libgcc TEST_COND_ibm128
+#ifdef ARG_FLOAT
+# define TEST_COND_ibm128_libgcc (TEST_COND_ibm128 || TEST_COND_arg_ibm128)
+#else
+# define TEST_COND_ibm128_libgcc TEST_COND_ibm128
+#endif
 
 /* Mark a test as expected to fail for ibm128-libgcc.  This is used
-   via XFAIL_ROUNDING_IBM128_LIBGCC, which gen-libm-test.pl transforms
+   via XFAIL_ROUNDING_IBM128_LIBGCC, which gen-libm-test.py transforms
    appropriately for each rounding mode.  */
 #define XFAIL_IBM128_LIBGCC (TEST_COND_ibm128_libgcc ? XFAIL_TEST : 0)
 
+/* On some architectures, glibc can be built with compilers that do
+   not have suitable built-in functions for setting the payload of a
+   _Float128 NaN.  */
+#if ((defined __x86_64__ || defined __i386__ || defined __ia64__)      \
+     && !__GNUC_PREREQ (7, 0))
+# define XFAIL_FLOAT128_PAYLOAD (TEST_COND_binary128 ? XFAIL_TEST : 0)
+#else
+# define XFAIL_FLOAT128_PAYLOAD 0
+#endif
+
 /* Number of bits in NaN payload.  */
 #if TEST_COND_ibm128
 # define PAYLOAD_DIG (DBL_MANT_DIG - 2)
@@ -122,6 +142,16 @@ extern const char doc[];
 # define PAYLOAD_DIG (MANT_DIG - 2)
 #endif
 
+/* For narrowing functions, whether the argument format can represent
+   all the given argument values.  */
+#define TEST_COND_arg_fmt(MAX_EXP, NUM_ONES, MIN_EXP, MAX_PREC) \
+  (((MAX_EXP) < ARG_MAX_EXP)                                   \
+   && (!TEST_COND_arg_ibm128                                   \
+       || (MAX_EXP) < ARG_MAX_EXP - 1                          \
+       || (NUM_ONES) <= 53)                                    \
+   && (MIN_EXP) >= ARG_MIN_EXP - ARG_MANT_DIG                  \
+   && (MAX_PREC) <= ARG_MANT_DIG)
+
 /* Values underflowing on architectures detecting tininess before
    rounding, but not on those detecting tininess after rounding.  */
 #define UNDERFLOW_EXCEPTION_BEFORE_ROUNDING    (TININESS_AFTER_ROUNDING \
@@ -139,11 +169,11 @@ extern const char doc[];
 #define TEST_COND_after_rounding       TININESS_AFTER_ROUNDING
 
 int enable_test (int);
-void init_max_error (const char *, int);
+void init_max_error (const char *, int, 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);