about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@redhat.com>2014-11-24 17:25:56 +0530
committerSiddhesh Poyarekar <siddhesh@redhat.com>2014-11-24 17:25:56 +0530
commitd73ac1bb436cf1adb62335f53b4fc91a02f40a3b (patch)
treea7e87be4d6db2a3e0a6ed32c94d48247c2204edf
parent33ceaf6187b31ea15284ac65131749e1cb68d2ae (diff)
downloadglibc-d73ac1bb436cf1adb62335f53b4fc91a02f40a3b.tar.gz
glibc-d73ac1bb436cf1adb62335f53b4fc91a02f40a3b.tar.xz
glibc-d73ac1bb436cf1adb62335f53b4fc91a02f40a3b.zip
Make __extern_always_inline usable on clang++ again
The fix for BZ #17266 (884ddc5081278f488ef8cd49951f41cfdbb480ce)
removed changes that had gone into cdefs.h to make
__extern_always_inline usable with clang++.  This patch adds back
support for clang to detect if GNU inlining semantics are available,
this time without breaking the gcc use case.  The check put here is
based on the earlier patch and assertion[1] that checking if
__GNUC_STDC_INLINE__ or __GNUC_GNU_INLINE__ is defined is sufficient
to determine that clang++ suports GNU inlining semantics.

Tested with a simple program that builds with __extern_always_inline
with the patch and fails compilation without it.

 #include <stdio.h>
 #include <sys/cdefs.h>

extern void foo_alias (void) __asm ("foo");

__extern_always_inline void
foo (void)
{
  puts ("hi oh world!");
  return foo_alias ();
}

void
foo_alias (void)
{
  puts ("hell oh world");
}

int
main ()
{
  foo ();
}

[1] https://sourceware.org/ml/libc-alpha/2012-12/msg00306.html

	[BZ #17266]
	* misc/sys/cdefs.h: Define __extern_always_inline for clang
	4.2 and newer.

(cherry picked from commit 602f80ec8b966cfad3b61914cbe14ee606cedf6e)
-rw-r--r--ChangeLog6
-rw-r--r--misc/sys/cdefs.h10
2 files changed, 14 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index f9f3407f88..ac7d980d88 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-11-24  Siddhesh Poyarekar  <siddhesh@redhat.com>
+
+	[BZ #17266]
+	* misc/sys/cdefs.h: Define __extern_always_inline for clang
+	4.2 and newer.
+
 2014-11-19  Carlos O'Donell  <carlos@redhat.com>
 	    Florian Weimer  <fweimer@redhat.com>
 	    Joseph Myers  <joseph@codesourcery.com>
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 01e81ba9f1..711ac1d912 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -321,8 +321,14 @@
    inline semantics, unless -fgnu89-inline is used.  Using __GNUC_STDC_INLINE__
    or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions
    older than 4.3 may define these macros and still not guarantee GNU inlining
-   semantics.  */
-#if !defined __cplusplus || __GNUC_PREREQ (4,3)
+   semantics.
+
+   clang++ identifies itself as gcc-4.2, but has support for GNU inlining
+   semantics, that can be checked fot by using the __GNUC_STDC_INLINE_ and
+   __GNUC_GNU_INLINE__ macro definitions.  */
+#if (!defined __cplusplus || __GNUC_PREREQ (4,3) \
+     || (defined __clang__ && (defined __GNUC_STDC_INLINE__ \
+			       || defined __GNUC_GNU_INLINE__)))
 # if defined __GNUC_STDC_INLINE__ || defined __cplusplus
 #  define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
 #  define __extern_always_inline \