mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-30 13:13:43 +08:00
7ec903e028
C23 adds various <math.h> function families originally defined in TS 18661-4. Add the exp2m1 and exp10m1 functions (exp2(x)-1 and exp10(x)-1, like expm1). As with other such functions, these use type-generic templates that could be replaced with faster and more accurate type-specific implementations in future. Test inputs are copied from those for expm1, plus some additions close to the overflow threshold (copied from exp2 and exp10) and also some near the underflow threshold. exp2m1 has the unusual property of having an input (M_MAX_EXP) where whether the function overflows (under IEEE semantics) depends on the rounding mode. Although these could reasonably be XFAILed in the testsuite (as we do in some cases for arguments very close to a function's overflow threshold when an error of a few ulps in the implementation can result in the implementation not agreeing with an ideal one on whether overflow takes place - the testsuite isn't smart enough to handle this automatically), since these functions aren't required to be correctly rounding, I made the implementation check for and handle this case specially. The Makefile ordering expected by lint-makefiles for the new functions is a bit peculiar, but I implemented it in this patch so that the test passes; I don't know why log2 also needed moving in one Makefile variable setting when it didn't in my previous patches, but the failure showed a different place was expected for that function as well. The powerpc64le IFUNC setup seems not to be as self-contained as one might hope; it shouldn't be necessary to add IFUNCs for new functions such as these simply to get them building, but without setting up IFUNCs for the new functions, there were undefined references to __GI___expm1f128 (that IFUNC machinery results in no such function being defined, but doesn't stop include/math.h from doing the redirection resulting in the exp2m1f128 and exp10m1f128 implementations expecting to call it). Tested for x86_64 and x86, and with build-many-glibcs.py.
50 lines
1.5 KiB
C++
50 lines
1.5 KiB
C++
/* Test exp2m1.
|
|
Copyright (C) 2024 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
|
|
<https://www.gnu.org/licenses/>. */
|
|
|
|
#include "libm-test-driver.c"
|
|
|
|
static const struct test_f_f_data exp2m1_test_data[] =
|
|
{
|
|
TEST_f_f (exp2m1, plus_infty, plus_infty, ERRNO_UNCHANGED),
|
|
TEST_f_f (exp2m1, minus_infty, -1, ERRNO_UNCHANGED),
|
|
TEST_f_f (exp2m1, qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
|
|
TEST_f_f (exp2m1, -qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
|
|
TEST_f_f (exp2m1, snan_value, qnan_value, INVALID_EXCEPTION),
|
|
TEST_f_f (exp2m1, -snan_value, qnan_value, INVALID_EXCEPTION),
|
|
|
|
AUTO_TESTS_f_f (exp2m1),
|
|
};
|
|
|
|
static void
|
|
exp2m1_test (void)
|
|
{
|
|
ALL_RM_TEST (exp2m1, 0, exp2m1_test_data, RUN_TEST_LOOP_f_f, END);
|
|
}
|
|
|
|
static void
|
|
do_test (void)
|
|
{
|
|
exp2m1_test ();
|
|
}
|
|
|
|
/*
|
|
* Local Variables:
|
|
* mode:c
|
|
* End:
|
|
*/
|