diff options
Diffstat (limited to 'math')
-rw-r--r-- | math/Makefile | 3 | ||||
-rw-r--r-- | math/Versions | 1 | ||||
-rw-r--r-- | math/bits/mathcalls.h | 3 | ||||
-rwxr-xr-x | math/gen-libm-test.pl | 8 | ||||
-rw-r--r-- | math/libm-test.inc | 85 |
5 files changed, 96 insertions, 4 deletions
diff --git a/math/Makefile b/math/Makefile index 7c378fc5c3..2aa6a344e5 100644 --- a/math/Makefile +++ b/math/Makefile @@ -72,7 +72,8 @@ libm-calls = \ s_fmaF s_lrintF s_llrintF s_lroundF s_llroundF e_exp10F w_log2F \ s_issignalingF $(calls:s_%=m_%) x2y2m1F \ gamma_productF lgamma_negF lgamma_productF \ - s_nextupF s_totalorderF s_totalordermagF $(gen-libm-calls) + s_nextupF s_totalorderF s_totalordermagF s_getpayloadF \ + $(gen-libm-calls) libm-compat-calls-ldouble-yes = w_lgamma_compatl k_standardl libm-compat-calls = w_lgamma_compatf w_lgamma_compat k_standard k_standardf \ diff --git a/math/Versions b/math/Versions index 67e826a40e..a2e0d900ad 100644 --- a/math/Versions +++ b/math/Versions @@ -219,5 +219,6 @@ libm { __iscanonicall; __iseqsigf; __iseqsig; __iseqsigl; totalorder; totalorderf; totalorderl; totalordermag; totalordermagf; totalordermagl; + getpayload; getpayloadf; getpayloadl; } } diff --git a/math/bits/mathcalls.h b/math/bits/mathcalls.h index 030130656c..c5853a325f 100644 --- a/math/bits/mathcalls.h +++ b/math/bits/mathcalls.h @@ -394,6 +394,9 @@ __MATHDECL_1 (int, totalorder,, (_Mdouble_ __x, _Mdouble_ __y)) /* Total order operation on absolute values. */ __MATHDECL_1 (int, totalordermag,, (_Mdouble_ __x, _Mdouble_ __y)) __attribute__ ((__const__)); + +/* Get NaN payload. */ +__MATHCALL (getpayload,, (const _Mdouble_ *__x)); #endif #if defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \ diff --git a/math/gen-libm-test.pl b/math/gen-libm-test.pl index 4d02873c6f..25e69a8998 100755 --- a/math/gen-libm-test.pl +++ b/math/gen-libm-test.pl @@ -229,6 +229,10 @@ sub parse_args { ++$current_arg; next; } + # Argument passed via pointer. + if ($descr[$i] =~ /p/) { + next; + } # &FLOAT, &int - simplify call by not showing argument. if ($descr[$i] =~ /F|I/) { next; @@ -294,8 +298,8 @@ sub parse_args { $current_arg++; next; } - # &FLOAT, &int - if ($descr[$i] =~ /F|I/) { + # &FLOAT, &int, argument passed via pointer + if ($descr[$i] =~ /F|I|p/) { next; } # complex diff --git a/math/libm-test.inc b/math/libm-test.inc index 91451bfa99..89e0e59638 100644 --- a/math/libm-test.inc +++ b/math/libm-test.inc @@ -45,7 +45,7 @@ acos, acosh, asin, asinh, atan, atan2, atanh, cbrt, ceil, copysign, cos, cosh, drem, erf, erfc, exp, exp10, exp2, expm1, fabs, fdim, finite, floor, fma, fmax, fmin, fmod, fpclassify, - frexp, gamma, hypot, + frexp, gamma, getpayload, hypot, ilogb, iscanonical, isfinite, isinf, isnan, isnormal, issignaling, issubnormal, iszero, iseqsig, isless, islessequal, isgreater, isgreaterequal, islessgreater, isunordered, j0, j1, jn, @@ -131,6 +131,7 @@ #include <tininess.h> #include <math-tests.h> #include <math-tests-arch.h> +#include <nan-high-order-bit.h> /* This header defines func_ulps, func_real_ulps and func_imag_ulps arrays. */ @@ -1075,6 +1076,7 @@ enable_test (int exceptions) } /* Structures for each kind of test. */ +/* Used for both RUN_TEST_LOOP_f_f and RUN_TEST_LOOP_fp_f. */ struct test_f_f_data { const char *arg_str; @@ -1352,6 +1354,24 @@ struct test_fFF_11_data (ARRAY)[i].RM_##ROUNDING_MODE.expected, \ (ARRAY)[i].RM_##ROUNDING_MODE.exceptions); \ ROUND_RESTORE_ ## ROUNDING_MODE +#define RUN_TEST_fp_f(ARG_STR, FUNC_NAME, ARG, EXPECTED, \ + EXCEPTIONS) \ + do \ + if (enable_test (EXCEPTIONS)) \ + { \ + COMMON_TEST_SETUP (ARG_STR); \ + check_float (test_name, FUNC_TEST (FUNC_NAME) (&(ARG)), \ + EXPECTED, EXCEPTIONS); \ + COMMON_TEST_CLEANUP; \ + } \ + while (0) +#define RUN_TEST_LOOP_fp_f(FUNC_NAME, ARRAY, ROUNDING_MODE) \ + IF_ROUND_INIT_ ## ROUNDING_MODE \ + for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \ + RUN_TEST_fp_f ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg, \ + (ARRAY)[i].RM_##ROUNDING_MODE.expected, \ + (ARRAY)[i].RM_##ROUNDING_MODE.exceptions); \ + ROUND_RESTORE_ ## ROUNDING_MODE #define RUN_TEST_2_f(ARG_STR, FUNC_NAME, ARG1, ARG2, EXPECTED, \ EXCEPTIONS) \ do \ @@ -8046,6 +8066,66 @@ frexp_test (void) ALL_RM_TEST (frexp, 1, frexp_test_data, RUN_TEST_LOOP_fI_f1, END, x); } + +static const struct test_f_f_data getpayload_test_data[] = + { + TEST_fp_f (getpayload, plus_infty, IGNORE, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, minus_infty, IGNORE, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, plus_zero, IGNORE, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, minus_zero, IGNORE, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, 1000, IGNORE, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, max_value, IGNORE, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, -max_value, IGNORE, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, min_value, IGNORE, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, -min_value, IGNORE, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, min_subnorm_value, IGNORE, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, -min_subnorm_value, IGNORE, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), +#if HIGH_ORDER_BIT_IS_SET_FOR_SNAN + TEST_fp_f (getpayload, snan_value_pl ("0x0"), plus_zero, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, -snan_value_pl ("0x0"), plus_zero, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), +#else + TEST_fp_f (getpayload, qnan_value_pl ("0x0"), plus_zero, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, -qnan_value_pl ("0x0"), plus_zero, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), +#endif + TEST_fp_f (getpayload, qnan_value_pl ("0x1"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, -qnan_value_pl ("0x1"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, snan_value_pl ("0x1"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, -snan_value_pl ("0x1"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, qnan_value_pl ("0x2"), 2, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, -qnan_value_pl ("0x2"), 2, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, snan_value_pl ("0x2"), 2, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, -snan_value_pl ("0x2"), 2, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, qnan_value_pl ("0x3fffff"), 0x3fffff, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, -qnan_value_pl ("0x3fffff"), 0x3fffff, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, snan_value_pl ("0x3fffff"), 0x3fffff, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, -snan_value_pl ("0x3fffff"), 0x3fffff, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), +#if PAYLOAD_DIG >= 51 + TEST_fp_f (getpayload, qnan_value_pl ("0x7ffffffffffff"), 0x7ffffffffffffp0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, -qnan_value_pl ("0x7ffffffffffff"), 0x7ffffffffffffp0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, snan_value_pl ("0x7ffffffffffff"), 0x7ffffffffffffp0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, -snan_value_pl ("0x7ffffffffffff"), 0x7ffffffffffffp0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), +#endif +#if PAYLOAD_DIG >= 62 + TEST_fp_f (getpayload, qnan_value_pl ("0x3fffffffffffffff"), 0x3fffffffffffffffp0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, -qnan_value_pl ("0x3fffffffffffffff"), 0x3fffffffffffffffp0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, snan_value_pl ("0x3fffffffffffffff"), 0x3fffffffffffffffp0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, -snan_value_pl ("0x3fffffffffffffff"), 0x3fffffffffffffffp0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), +#endif +#if PAYLOAD_DIG >= 111 + TEST_fp_f (getpayload, qnan_value_pl ("0x7fffffffffffffffffffffffffff"), 0x7fffffffffffffffffffffffffffp0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, -qnan_value_pl ("0x7fffffffffffffffffffffffffff"), 0x7fffffffffffffffffffffffffffp0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, snan_value_pl ("0x7fffffffffffffffffffffffffff"), 0x7fffffffffffffffffffffffffffp0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_fp_f (getpayload, -snan_value_pl ("0x7fffffffffffffffffffffffffff"), 0x7fffffffffffffffffffffffffffp0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), +#endif + }; + +static void +getpayload_test (void) +{ + ALL_RM_TEST (getpayload, 1, getpayload_test_data, RUN_TEST_LOOP_fp_f, END); +} + + static const struct test_ff_f_data hypot_test_data[] = { TEST_ff_f (hypot, plus_infty, 1, plus_infty, ERRNO_UNCHANGED), @@ -13431,6 +13511,9 @@ main (int argc, char **argv) totalorder_test (); totalordermag_test (); + /* NaN functions: */ + getpayload_test (); + /* Complex functions: */ cabs_test (); cacos_test (); |