about summary refs log tree commit diff
path: root/manual
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2016-10-19 01:49:09 +0000
committerJoseph Myers <joseph@codesourcery.com>2016-10-19 01:49:09 +0000
commitf8e8b8ed9f266097b42a77359445372d82365916 (patch)
treec8193dce446027347491ba1828af41d875708636 /manual
parenta9bfffe59333fdc6785f3cc903188d1ead36539d (diff)
downloadglibc-f8e8b8ed9f266097b42a77359445372d82365916.tar.gz
glibc-f8e8b8ed9f266097b42a77359445372d82365916.tar.xz
glibc-f8e8b8ed9f266097b42a77359445372d82365916.zip
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.
Diffstat (limited to 'manual')
-rw-r--r--manual/arith.texi20
-rwxr-xr-xmanual/libm-err-tab.pl7
2 files changed, 24 insertions, 3 deletions
diff --git a/manual/arith.texi b/manual/arith.texi
index 282ca45e08..e53988a083 100644
--- a/manual/arith.texi
+++ b/manual/arith.texi
@@ -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
diff --git a/manual/libm-err-tab.pl b/manual/libm-err-tab.pl
index 102ff7b03a..59c53720b3 100755
--- a/manual/libm-err-tab.pl
+++ b/manual/libm-err-tab.pl
@@ -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) {