Add getpayload, getpayloadf, getpayloadl.

TS 18661-1 defines functions for manipulating the payloads of NaNs.
This patch implements the getpayload functions for glibc; these
extract the NaN payload (from an argument passed as a pointer, for
which corresponding libm-test support is added) and return it in the
same floating-point type.  The return value of these functions is
unspecified for non-NaN arguments; the patch does the simplest thing
to implement, which is that the functions do not check whether the
argument is a NaN and just treat the relevant bits of the
representation as a payload regardless.  A conversion from integer to
floating-point is used to produce the required return value, except in
the ldbl-128 case; as 128-bit integers are not supported for all
configurations using ldbl-128, the code constructs the required
floating-point representation of the return value directly instead.

Tested for x86_64, x86, mips64 and powerpc.

	* math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
	(getpayload): New declaration.
	* math/Versions (getpayload): New libm symbol at version
	GLIBC_2.25.
	(getpayloadf): Likewise.
	(getpayloadl): Likewise.
	* math/Makefile (libm-calls): Add s_getpayloadF.
	* math/libm-test.inc: Include <nan-high-order-bit.h>.
	(struct test_f_f_data): Add comment.
	(RUN_TEST_fp_f): New macro.
	(RUN_TEST_LOOP_fp_f): Likewise.
	(getpayload_test_data): New array.
	(getpayload_test): New function.
	(main): Call getpayload_test.
	* math/gen-libm-test.pl (parse_args): Handle 'p' in argument
	descriptor.
	* manual/arith.texi (FP Bit Twiddling): Document getpayload,
	getpayloadf and getpayloadl.
	* manual/libm-err-tab.pl: Update comment on interfaces without
	ulps tabulated.
	* sysdeps/ieee754/dbl-64/s_getpayload.c: New file.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_getpayload.c: Likewise.
	* sysdeps/ieee754/flt-32/s_getpayloadf.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_getpayloadl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_getpayloadl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_getpayloadl.c: Likewise.
	* sysdeps/nacl/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
This commit is contained in:
Joseph Myers 2016-10-19 01:49:09 +00:00
parent a9bfffe593
commit f8e8b8ed9f
42 changed files with 491 additions and 7 deletions

View File

@ -1,3 +1,65 @@
2016-10-19 Joseph Myers <joseph@codesourcery.com>
* math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(getpayload): New declaration.
* math/Versions (getpayload): New libm symbol at version
GLIBC_2.25.
(getpayloadf): Likewise.
(getpayloadl): Likewise.
* math/Makefile (libm-calls): Add s_getpayloadF.
* math/libm-test.inc: Include <nan-high-order-bit.h>.
(struct test_f_f_data): Add comment.
(RUN_TEST_fp_f): New macro.
(RUN_TEST_LOOP_fp_f): Likewise.
(getpayload_test_data): New array.
(getpayload_test): New function.
(main): Call getpayload_test.
* math/gen-libm-test.pl (parse_args): Handle 'p' in argument
descriptor.
* manual/arith.texi (FP Bit Twiddling): Document getpayload,
getpayloadf and getpayloadl.
* manual/libm-err-tab.pl: Update comment on interfaces without
ulps tabulated.
* sysdeps/ieee754/dbl-64/s_getpayload.c: New file.
* sysdeps/ieee754/dbl-64/wordsize-64/s_getpayload.c: Likewise.
* sysdeps/ieee754/flt-32/s_getpayloadf.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_getpayloadl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_getpayloadl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_getpayloadl.c: Likewise.
* sysdeps/nacl/libm.abilist: Update.
* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
2016-10-18 Adhemerval Zanella <adhemerval.zanella@linaro.org>
* sysdeps/unix/sysv/linux/Makefile [$(subdir) = math] (tests): Move

2
NEWS
View File

@ -58,6 +58,8 @@ Version 2.25
- Total order functions: totalorder, totalorderf, totalorderl,
totalordermag, totalordermagf, totalordermagl.
- NaN functions: getpayload, getpayloadf, getpayloadl.
* The <sys/quota.h> header now includes the <linux/quota.h> header. Support
for the Linux quota interface which predates kernel version 2.4.22 has
been removed.

View File

@ -1854,6 +1854,26 @@ The argument @var{tagp} is used in an unspecified manner. On @w{IEEE
selects one. On other systems it may do nothing.
@end deftypefun
@comment math.h
@comment ISO
@deftypefun double getpayload (const double *@var{x})
@comment math.h
@comment ISO
@deftypefunx float getpayloadf (const float *@var{x})
@comment math.h
@comment ISO
@deftypefunx {long double} getpayloadl (const long double *@var{x})
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
IEEE 754 defines the @dfn{payload} of a NaN to be an integer value
encoded in the representation of the NaN. Payloads are typically
propagated from NaN inputs to the result of a floating-point
operation. These functions, defined by TS 18661-1:2014, return the
payload of the NaN pointed to by @var{x} (returned as a positive
integer, or positive zero, represented as a floating-point number); if
@var{x} is not a NaN, they return an unspecified value. They raise no
floating-point exceptions even for signaling NaNs.
@end deftypefun
@node FP Comparison Functions
@subsection Floating-Point Comparison Functions
@cindex unordered comparison

View File

@ -77,9 +77,10 @@ use vars qw (%results @all_floats %suffices @all_functions);
"nextup", "pow", "remainder", "remquo", "rint", "round", "scalb",
"scalbn", "sin", "sincos", "sinh", "sqrt", "tan", "tanh", "tgamma",
"trunc", "y0", "y1", "yn" );
# fpclassify, iscanonical, isnormal, isfinite, isinf, isnan, issignaling,
# issubnormal, iszero, signbit, iseqsig, isgreater, isgreaterequal, isless,
# islessequal, islessgreater, isunordered, totalorder, totalordermag
# fpclassify, getpayload, iscanonical, isnormal, isfinite, isinf, isnan,
# issignaling, issubnormal, iszero, signbit, iseqsig, isgreater,
# isgreaterequal, isless, islessequal, islessgreater, isunordered,
# totalorder, totalordermag
# are not tabulated.
if ($#ARGV == 0) {

View File

@ -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 \

View File

@ -219,5 +219,6 @@ libm {
__iscanonicall; __iseqsigf; __iseqsig; __iseqsigl;
totalorder; totalorderf; totalorderl;
totalordermag; totalordermagf; totalordermagl;
getpayload; getpayloadf; getpayloadl;
}
}

View File

@ -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 \

View File

@ -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

View File

@ -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 ();

View File

@ -0,0 +1,37 @@
/* Get NaN payload. dbl-64 version.
Copyright (C) 2016 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 <fix-int-fp-convert-zero.h>
#include <math.h>
#include <math_private.h>
#include <stdint.h>
double
getpayload (const double *x)
{
uint32_t hx, lx;
EXTRACT_WORDS (hx, lx, *x);
hx &= 0x7ffff;
uint64_t ix = ((uint64_t) hx << 32) | lx;
if (FIX_INT_FP_CONVERT_ZERO && ix == 0)
return 0.0f;
return (double) ix;
}
#ifdef NO_LONG_DOUBLE
weak_alias (getpayload, getpayloadl)
#endif

View File

@ -0,0 +1,33 @@
/* Get NaN payload. dbl-64/wordsize-64 version.
Copyright (C) 2016 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 <math.h>
#include <math_private.h>
#include <stdint.h>
double
getpayload (const double *x)
{
uint64_t ix;
EXTRACT_WORDS64 (ix, *x);
ix &= 0x7ffffffffffffULL;
return (double) ix;
}
#ifdef NO_LONG_DOUBLE
weak_alias (getpayload, getpayloadl)
#endif

View File

@ -0,0 +1,33 @@
/* Get NaN payload. flt-32 version.
Copyright (C) 2016 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 <fix-int-fp-convert-zero.h>
#include <math.h>
#include <math_private.h>
#include <stdint.h>
float
getpayloadf (const float *x)
{
uint32_t ix;
GET_FLOAT_WORD (ix, *x);
ix &= 0x3fffff;
if (FIX_INT_FP_CONVERT_ZERO && ix == 0)
return 0.0f;
return (float) ix;
}

View File

@ -0,0 +1,57 @@
/* Get NaN payload. ldbl-128 version.
Copyright (C) 2016 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 <math.h>
#include <math_private.h>
#include <stdint.h>
long double
getpayloadl (const long double *x)
{
uint64_t hx, lx;
GET_LDOUBLE_WORDS64 (hx, lx, *x);
hx &= 0x7fffffffffffULL;
/* Construct the representation of the return value directly, since
128-bit integers may not be available. */
int lz;
if (hx == 0)
{
if (lx == 0)
return 0.0L;
else
lz = __builtin_clzll (lx) + 64;
}
else
lz = __builtin_clzll (hx);
int shift = lz - 15;
if (shift >= 64)
{
hx = lx << (shift - 64);
lx = 0;
}
else
{
/* 2 <= SHIFT <= 63. */
hx = (hx << shift) | (lx >> (64 - shift));
lx <<= shift;
}
hx = (hx & 0xffffffffffffULL) | ((0x3fffULL + 127 - lz) << 48);
long double ret;
SET_LDOUBLE_WORDS64 (ret, hx, lx);
return ret;
}

View File

@ -0,0 +1,34 @@
/* Get NaN payload. ldbl-128ibm version.
Copyright (C) 2016 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 <fix-int-fp-convert-zero.h>
#include <math.h>
#include <math_private.h>
#include <stdint.h>
long double
getpayloadl (const long double *x)
{
double xhi = ldbl_high (*x);
uint64_t ix;
EXTRACT_WORDS64 (ix, xhi);
ix &= 0x7ffffffffffffULL;
if (FIX_INT_FP_CONVERT_ZERO && ix == 0)
return 0.0L;
return (long double) ix;
}

View File

@ -0,0 +1,32 @@
/* Get NaN payload. ldbl-96 version.
Copyright (C) 2016 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 <math.h>
#include <math_private.h>
#include <stdint.h>
long double
getpayloadl (const long double *x)
{
uint16_t se __attribute__ ((unused));
uint32_t hx, lx;
GET_LDOUBLE_WORDS (se, hx, lx, *x);
hx &= 0x3fffffff;
uint64_t ix = ((uint64_t) hx << 32) | lx;
return (long double) ix;
}

View File

@ -386,6 +386,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -418,6 +418,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -428,6 +428,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -75,6 +75,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -387,6 +387,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -431,6 +431,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -360,6 +360,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -75,6 +75,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -429,6 +429,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -386,6 +386,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -388,6 +388,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -420,6 +420,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -386,6 +386,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -431,6 +431,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -430,6 +430,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -425,6 +425,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -106,6 +106,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -418,6 +418,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -416,6 +416,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -387,6 +387,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -421,6 +421,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -419,6 +419,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -387,6 +387,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -387,6 +387,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -387,6 +387,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -420,6 +420,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F

View File

@ -419,6 +419,9 @@ GLIBC_2.25 fegetmode F
GLIBC_2.25 fesetexcept F
GLIBC_2.25 fesetmode F
GLIBC_2.25 fetestexceptflag F
GLIBC_2.25 getpayload F
GLIBC_2.25 getpayloadf F
GLIBC_2.25 getpayloadl F
GLIBC_2.25 totalorder F
GLIBC_2.25 totalorderf F
GLIBC_2.25 totalorderl F