about summary refs log tree commit diff
path: root/math/bits/math-finite.h
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@redhat.com>2014-09-16 14:08:48 +0530
committerSiddhesh Poyarekar <siddhesh@redhat.com>2014-09-16 14:08:48 +0530
commit884ddc5081278f488ef8cd49951f41cfdbb480ce (patch)
treec039a8fca0fc5c54bab91c381466ce0158af7bfb /math/bits/math-finite.h
parenta7b872687073decdcc7effc2289877d69058aca9 (diff)
downloadglibc-884ddc5081278f488ef8cd49951f41cfdbb480ce.tar.gz
glibc-884ddc5081278f488ef8cd49951f41cfdbb480ce.tar.xz
glibc-884ddc5081278f488ef8cd49951f41cfdbb480ce.zip
Revert to defining __extern_inline only for gcc-4.3+ (BZ #17266)
The check for only __GNUC_STDC_INLINE__ and __GNUC_GNU_INLINE__ may
not be sufficient since those flags were added during initial support
for C99 inlining semantics.  There is also a problem with always
defining __extern_inline and __extern_always_inline, since it enables
inline wrapper functions even when GNU inlining semantics are not
guaranteed.  This, along with the possibility of such wrappers using
redirection (btowc for example) could result in compiler generating an
infinitely recusrive call to the function.

In fact it was such a recursion that led to this code being written
the way it was; see:

https://bugzilla.redhat.com/show_bug.cgi?id=186410

The initial change was to fix bugs 14530 and 13741, but they can be
resolved by checking if __fortify_function and/or
__extern_always_inline are defined, as it has been done in this patch.
In addition, I have audited uses of __extern_always_inline to make
sure that none of the uses result in compilation errors.

There is however a regression in this patch for llvm, since it reverts
the llvm expectation that __GNUC_STDC_INLINE__ or __GNUC_GNU_INLINE__
definition imply proper extern inline semantics.

2014-09-16  Siddhesh Poyarekar  <siddhesh@redhat.com>
	    Jakub Jelinek  <jakub@redhat.com>

	[BZ #17266]
	* libio/stdio.h: Check definition of __fortify_function
	instead of __extern_always_inline to include bits/stdio2.h.
	* math/bits/math-finite.h [__USE_XOPEN || __USE_ISOC99]: Also
	check if __extern_always_inline is defined.
	[__USE_MISC || __USE_XOPEN]: Likewise.
	[__USE_ISOC99] Likewise.
	* misc/sys/cdefs.h (__fortify_function): Define only if
	__extern_always_inline is defined.
	[!__cplusplus || __GNUC_PREREQ (4,3)]: Revert to defining
	__extern_always_inline and __extern_inline only for g++-4.3
	and newer or a compatible gcc.
Diffstat (limited to 'math/bits/math-finite.h')
-rw-r--r--math/bits/math-finite.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/math/bits/math-finite.h b/math/bits/math-finite.h
index aa755de2e6..0656645cc6 100644
--- a/math/bits/math-finite.h
+++ b/math/bits/math-finite.h
@@ -251,7 +251,8 @@ extern long double __REDIRECT_NTH (lgammal_r, (long double, int *),
 # endif
 #endif
 
-#if defined __USE_XOPEN || defined __USE_ISOC99
+#if ((defined __USE_XOPEN || defined __USE_ISOC99) \
+     && defined __extern_always_inline)
 /* lgamma.  */
 __extern_always_inline double __NTH (lgamma (double __d))
 {
@@ -284,7 +285,8 @@ __extern_always_inline long double __NTH (lgammal (long double __d))
 # endif
 #endif
 
-#if defined __USE_MISC || defined __USE_XOPEN
+#if ((defined __USE_MISC || defined __USE_XOPEN) \
+     && defined __extern_always_inline)
 /* gamma.  */
 __extern_always_inline double __NTH (gamma (double __d))
 {
@@ -422,7 +424,7 @@ extern long double __REDIRECT_NTH (sqrtl, (long double), __sqrtl_finite);
 # endif
 #endif
 
-#ifdef __USE_ISOC99
+#if defined __USE_ISOC99 && defined __extern_always_inline
 /* tgamma.  */
 extern double __gamma_r_finite (double, int *);
 __extern_always_inline double __NTH (tgamma (double __d))