about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2015-02-13 21:54:44 +0000
committerJoseph Myers <joseph@codesourcery.com>2015-02-13 21:54:44 +0000
commitd9afe48d55a412e76b0dcb28335fd4b390fe07ae (patch)
treecebb0e3a23be3a2e930fef5b8ed43d0d83a2d265 /sysdeps
parent3846188b21eaae3fc57e399a9aead34847521bbb (diff)
downloadglibc-d9afe48d55a412e76b0dcb28335fd4b390fe07ae.tar.gz
glibc-d9afe48d55a412e76b0dcb28335fd4b390fe07ae.tar.xz
glibc-d9afe48d55a412e76b0dcb28335fd4b390fe07ae.zip
Fix dbl-64/wordsize-64 remquo (bug 17569).
The dbl-64/wordsize-64 remquo implementation follows similar logic to
various other implementations, but where that logic computes some
absolute values, it wrongly uses a previously computed bit-pattern for
the absolute value of the first argument, where actually it needs the
absolute value of the first argument mod 8 times the second.  This
patch fixes it to compute the correct absolute value.

The integer quotient result of remquo is only specified mod 8
(including its sign); architecture-specific versions may well vary in
what results they give for higher bits of that result (and indeed bug
17569 gives an example correct result from __builtin_remquo giving 9
for that result, where the particular glibc implementation used in
that bug report would give 1 after this fix).  Thus, this patch adapts
the tests of remquo to test that result only mod 8, to allow for such
variation when tests with higher quotient are included.

Tested for x86_64 and x86.

	[BZ #17569]
	* sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c (__remquo):
	Compute absolute value of x as modified by fmod, not original
	value of x.
	* math/libm-test.inc (RUN_TEST_ffI_f1): Rename to
	RUN_TEST_ffI_f1_mod8.  Check extra return value mod 8.
	(RUN_TEST_LOOP_ffI_f1): Rename to RUN_TEST_LOOP_ffI_f1_mod8.  Call
	RUN_TEST_ffI_f1_mod8.
	(remquo_test_data): Add more tests.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c
index 36fc37c134..5b7142576a 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c
@@ -55,7 +55,7 @@ __remquo (double x, double y, int *quo)
       return zero * x;
     }
 
-  INSERT_WORDS64 (x, hx);
+  x = fabs (x);
   INSERT_WORDS64 (y, hy);
   cquo = 0;