about summary refs log tree commit diff
path: root/math/bits
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2015-11-05 21:23:07 +0000
committerJoseph Myers <joseph@codesourcery.com>2015-11-05 21:23:07 +0000
commit939fdd1c36dde8884543bc9c3b8506e76c9ff0e4 (patch)
treef2a5ec7b8209beb361b21fe0de8aede38549ec6c /math/bits
parentf248238cf43bd751db29e6f151d6da7645337ff5 (diff)
downloadglibc-939fdd1c36dde8884543bc9c3b8506e76c9ff0e4.tar.gz
glibc-939fdd1c36dde8884543bc9c3b8506e76c9ff0e4.tar.xz
glibc-939fdd1c36dde8884543bc9c3b8506e76c9ff0e4.zip
Fix finite-math-only lgamma functions signgam setting (bug 19211).
The lgamma inline functions in bits/math-finite.h do not set signgam
if __USE_ISOC99, even when other feature test macros mean a standard
such as XSI POSIX is selected for which it should be set.  (This is
essentially the opposite issue to bug 15421, the out-of-line versions
setting signgam even when they shouldn't.)

This patch fixes those functions to use __USE_MISC || __USE_XOPEN as
the condition for when to set signgam, since it's the condition for
when math.h declares signgam.  The legacy gamma* names are only
declared at all if __USE_MISC || __USE_XOPEN, so they just set signgam
unconditionally.

Tests for certain standards or not using _GNU_SOURCE cannot use
test-skeleton.c (this is a known issue noted on the wiki todo list).
Thus, the new tests that signgam remains not set in ISO C modes do not
use test-skeleton.c.  They also define _ISOMAC to avoid running into
declarations in the internal include/ headers that only work in
_GNU_SOURCE mode.

Tested for x86_64 and x86.

	[BZ #19211]
	* math/bits/math-finite.h (lgamma): Set signgam if [__USE_MISC ||
	__USE_XOPEN], not if [!__USE_ISOC99].
	(lgammaf): Likewise.
	(lgammal): Likewise.
	(gamma): Set signgam unconditionally, not if [!__USE_ISOC99].
	(gammaf): Likewise.
	(gammal): Likewise.
	* math/test-signgam-finite-c11.c: New file.
	* math/test-signgam-finite-c99.c: Likewise.
	* math/test-signgam-finite.c: Likewise.
	* math/Makefile (tests): Add test-signgam-finite,
	test-signgam-finite-c99 and test-signgam-finite-c11.
	(CFLAGS-test-signgam-finite.c): New variable.
	(CFLAGS-test-signgam-finite-c99.c): Likewise.
	(CFLAGS-test-signgam-finite-c11.c): Likewise.
Diffstat (limited to 'math/bits')
-rw-r--r--math/bits/math-finite.h33
1 files changed, 9 insertions, 24 deletions
diff --git a/math/bits/math-finite.h b/math/bits/math-finite.h
index 5dd8406588..e3f93bd239 100644
--- a/math/bits/math-finite.h
+++ b/math/bits/math-finite.h
@@ -307,32 +307,32 @@ extern long double __lgammal_r_finite (long double, int *);
 /* lgamma.  */
 __extern_always_inline double __NTH (lgamma (double __d))
 {
-# ifdef __USE_ISOC99
+# if defined __USE_MISC || defined __USE_XOPEN
+  return __lgamma_r_finite (__d, &signgam);
+# else
   int __local_signgam = 0;
   return __lgamma_r_finite (__d, &__local_signgam);
-# else
-  return __lgamma_r_finite (__d, &signgam);
 # endif
 }
 #endif
 #if defined __USE_ISOC99 && defined __extern_always_inline
 __extern_always_inline float __NTH (lgammaf (float __d))
 {
-# ifdef __USE_ISOC99
+# if defined __USE_MISC || defined __USE_XOPEN
+  return __lgammaf_r_finite (__d, &signgam);
+# else
   int __local_signgam = 0;
   return __lgammaf_r_finite (__d, &__local_signgam);
-# else
-  return __lgammaf_r_finite (__d, &signgam);
 # endif
 }
 # ifdef __MATH_DECLARE_LDOUBLE
 __extern_always_inline long double __NTH (lgammal (long double __d))
 {
-# ifdef __USE_ISOC99
+# if defined __USE_MISC || defined __USE_XOPEN
+  return __lgammal_r_finite (__d, &signgam);
+# else
   int __local_signgam = 0;
   return __lgammal_r_finite (__d, &__local_signgam);
-# else
-  return __lgammal_r_finite (__d, &signgam);
 # endif
 }
 # endif
@@ -343,32 +343,17 @@ __extern_always_inline long double __NTH (lgammal (long double __d))
 /* gamma.  */
 __extern_always_inline double __NTH (gamma (double __d))
 {
-# ifdef __USE_ISOC99
-  int __local_signgam = 0;
-  return __lgamma_r_finite (__d, &__local_signgam);
-# else
   return __lgamma_r_finite (__d, &signgam);
-# endif
 }
 # ifdef __USE_ISOC99
 __extern_always_inline float __NTH (gammaf (float __d))
 {
-#  ifdef __USE_ISOC99
-  int __local_signgam = 0;
-  return __lgammaf_r_finite (__d, &__local_signgam);
-#  else
   return __lgammaf_r_finite (__d, &signgam);
-#  endif
 }
 #  ifdef __MATH_DECLARE_LDOUBLE
 __extern_always_inline long double __NTH (gammal (long double __d))
 {
-#   ifdef __USE_ISOC99
-  int __local_signgam = 0;
-  return __lgammal_r_finite (__d, &__local_signgam);
-#   else
   return __lgammal_r_finite (__d, &signgam);
-#   endif
 }
 #  endif
 # endif