[git commit master 1/1] lgamma: fix sign handling
Bernhard Reutner-Fischer
rep.dot.nop at gmail.com
Thu Jun 10 20:26:29 UTC 2010
commit: http://git.uclibc.org/uClibc/commit/?id=0f0cf7ec49719ab3c357813689bf1095234d6533
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master
add testcase from
http://sourceware.org/bugzilla/show_bug.cgi?id=4407
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
libm/e_lgamma_r.c | 6 +++++-
test/.gitignore | 1 +
test/math/Makefile.in | 3 ++-
test/math/signgam.c | 18 ++++++++++++++++++
4 files changed, 26 insertions(+), 2 deletions(-)
create mode 100644 test/math/signgam.c
diff --git a/libm/e_lgamma_r.c b/libm/e_lgamma_r.c
index 2b1fde7..23c96d8 100644
--- a/libm/e_lgamma_r.c
+++ b/libm/e_lgamma_r.c
@@ -208,7 +208,11 @@ double attribute_hidden __ieee754_lgamma_r(double x, int *signgamp)
*signgamp = 1;
ix = hx&0x7fffffff;
if(ix>=0x7ff00000) return x*x;
- if((ix|lx)==0) return one/zero;
+ if((ix|lx)==0) {
+ if (__signbitl(x))
+ *signgamp = -1;
+ return one/zero;
+ }
if(ix<0x3b900000) { /* |x|<2**-70, return -log(|x|) */
if(hx<0) {
*signgamp = -1;
diff --git a/test/.gitignore b/test/.gitignore
index 464130d..2070168 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -119,6 +119,7 @@ math/compile_test
math/libm-test-ulps.h
math/libm-test.c
math/rint
+math/signgam
math/test-double
math/test-ildoubl
math/test-ldouble
diff --git a/test/math/Makefile.in b/test/math/Makefile.in
index b160c87..8a46e77 100644
--- a/test/math/Makefile.in
+++ b/test/math/Makefile.in
@@ -1,7 +1,7 @@
# uClibc math tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-TESTS := basic-test rint tst-definitions test-fpucw test-float test-ifloat test-double test-idouble
+TESTS := basic-test rint signgam tst-definitions test-fpucw test-float test-ifloat test-double test-idouble
ifeq ($(UCLIBC_HAS_LONG_DOUBLE_MATH),y)
TESTS += test-ldouble test-ildoubl compile_test
else
@@ -9,6 +9,7 @@ CFLAGS_basic-test := -DNO_LONG_DOUBLE
endif
DODIFF_rint := 1
+DODIFF_signgam := 1
# NOTE: For basic-test we must disable the floating point optimization.
# Only for sh architecture because in the other architecture are disabled.
diff --git a/test/math/signgam.c b/test/math/signgam.c
new file mode 100644
index 0000000..c60375a
--- /dev/null
+++ b/test/math/signgam.c
@@ -0,0 +1,18 @@
+#define _XOPEN_SOURCE 600
+#include <math.h>
+#include <stdio.h>
+
+double zero = 0.0;
+double mzero;
+
+int
+main (void)
+{
+ double d;
+ mzero = copysign (zero, -1.0);
+ d = lgamma (zero);
+ printf ("%g %d\n", d, signgam);
+ d = lgamma (mzero);
+ printf ("%g %d\n", d, signgam);
+ return 0;
+}
--
1.7.1
More information about the uClibc-cvs
mailing list