about summary refs log tree commit diff
path: root/math/bits
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2016-11-19 00:16:28 +0000
committerJoseph Myers <joseph@codesourcery.com>2016-11-19 00:16:28 +0000
commiteb3c12c78420ce51778ab36ab1d4b37dcdaf7bd0 (patch)
treeaa868e51ca299bf499cac8a74ba99b5b3cfeccc3 /math/bits
parente92bd6e362470aa0a79cfb19a512944f0761184b (diff)
downloadglibc-eb3c12c78420ce51778ab36ab1d4b37dcdaf7bd0.tar.gz
glibc-eb3c12c78420ce51778ab36ab1d4b37dcdaf7bd0.tar.xz
glibc-eb3c12c78420ce51778ab36ab1d4b37dcdaf7bd0.zip
Add setpayload, setpayloadf, setpayloadl.
TS 18661-1 defines functions for manipulating the payloads of NaNs.
This patch implements the setpayload functions for glibc; these set a
number (pointed to by a function argument) to a quiet NaN with the
given payload, or to +0 if the given payload is not valid.  The
implementations are structured to allow the substance of the
implementation to be shared with the setpayloadsig functions when
those are added.

The semantics in the TS are not entirely clear in the case where the
payload passed to the function is zero (see discussion on the WG14
reflector last month).  This patch implements what seems the most
sensible interpretation, that -0 is never valid to give as the
payload, but +0 is valid in the case where the kind of NaN being
generated has its high mantissa bit set so payload 0 is actually
possible in such a NaN.

Tested for x86_64, x86, mips64 and powerpc.

	* math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
	(setpayload): New declaration.
	* math/Versions (setpayload): New libm symbol at version
	GLIBC_2.25.
	(setpayloadf): Likewise.
	(setpayloadl): Likewise.
	* math/Makefile (libm-calls): Add s_setpayloadF.
	* math/libm-test.inc (struct test_Ffp_b1_data): Rename to struct
	test_Ff_b1_data.
	(RUN_TEST_Ff_b1): New macro.
	(RUN_TEST_LOOP_Ff_b1): Likewise.
	(canonicalize_test_data): Update type.
	(setpayload_test_data): New array.
	(setpayload_test): New function.
	(main): Call setpayload_test.
	* manual/arith.texi (FP Bit Twiddling): Document setpayload,
	setpayloadf and setpayloadl.
	* manual/libm-err-tab.pl: Update comment on interfaces without
	ulps tabulated.
	* sysdeps/ieee754/dbl-64/s_setpayload.c: New file.
	* sysdeps/ieee754/dbl-64/s_setpayload_main.c: Likewise.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_setpayload_main.c:
	Likewise.
	* sysdeps/ieee754/flt-32/s_setpayloadf.c: Likewise.
	* sysdeps/ieee754/flt-32/s_setpayloadf_main.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_setpayloadl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_setpayloadl_main.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_setpayloadl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_setpayloadl_main.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_setpayloadl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_setpayloadl_main.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/nldbl-setpayload.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add
	setpayload.
	(CFLAGS-nldbl-setpayload.c): New variable.
	* 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 'math/bits')
-rw-r--r--math/bits/mathcalls.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/math/bits/mathcalls.h b/math/bits/mathcalls.h
index 2fd1d289da..0f4e625928 100644
--- a/math/bits/mathcalls.h
+++ b/math/bits/mathcalls.h
@@ -400,6 +400,9 @@ __MATHDECL_1 (int, canonicalize,, (_Mdouble_ *__cx, const _Mdouble_ *__x));
 
 /* Get NaN payload.  */
 __MATHCALL (getpayload,, (const _Mdouble_ *__x));
+
+/* Set quiet NaN payload.  */
+__MATHDECL_1 (int, setpayload,, (_Mdouble_ *__x, _Mdouble_ __payload));
 #endif
 
 #if defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \