From patchwork Tue Sep 16 10:20:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 390028 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9FF0B140096 for ; Tue, 16 Sep 2014 20:20:41 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id :mime-version:content-type; q=dns; s=default; b=rVWNPos50rAWM/r9 eYVonq09JyOYLqhDIssqG78E7YjUplQ8ZvQ/Q6m0B34a4+mOtq0qM34skluEW9LL f1KwreBxmt3QrJBtjjiImbTXfk/gmZQWlFXSSQ3Fg6aiQH7vXawyq88CFBtkuc81 vK3XMEyrkU80le1CuK0Z8oBLpKw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id :mime-version:content-type; s=default; bh=PQDMEQAMYBx+IIdTNIEqbN sZNF0=; b=PxqA1ttALXSjE4hPZPrMsmECUNkE2PMP1sgd4ur1c3ip25gYZjH63a 4z3yECpRr/t1dda4SApQlwjNoP7r19SQHrMldqTfofjtCbPQ8j3t4ZEdljv34//v 3HPEMVOyVKKEODVRK3Kwz/UTeEgYOdZ5H7bDBtk28IWcRUQHXPLas= Received: (qmail 31830 invoked by alias); 16 Sep 2014 10:20:33 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 31799 invoked by uid 89); 16 Sep 2014 10:20:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Date: Tue, 16 Sep 2014 15:50:16 +0530 From: Siddhesh Poyarekar To: libc-alpha@sourceware.org Cc: David Sommerseth , jakub@redhat.com, carlos@redhat.com, allan@archlinux.org Subject: [PATCH] Make __extern_always_inline usable on clang++ again Message-ID: <20140916102016.GM6586@spoyarek.pnq.redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.22.1-rc1 (2013-10-16) Hi, 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. I have kept this test separate from the earlier macro tests on purpose to keep the conditions simple and readable. Tested with a simple program that builds with __extern_always_inline with the patch and fails compilation without it. #include #include 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 (); } Is this OK for master and 2.20? Siddhesh [1] https://sourceware.org/ml/libc-alpha/2012-12/msg00306.html [BZ #17266] * misc/sys/cdefs.h [!defined __extern_always_inline && defined __clang__]: Define __extern_always_inline and __extern_inline for clang++. diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h index d8ee73c..20b2483 100644 --- a/misc/sys/cdefs.h +++ b/misc/sys/cdefs.h @@ -330,6 +330,20 @@ # endif #endif +/* 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 __extern_always_inline && defined __clang__ +# if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__ +# define __extern_inline extern __inline __attribute__ ((__gnu_inline__)) +# define __extern_always_inline \ + extern __always_inline __attribute__ ((__gnu_inline__)) +# else +# define __extern_inline extern __inline +# define __extern_always_inline extern __always_inline +# endif +#endif + #ifdef __extern_always_inline # define __fortify_function __extern_always_inline __attribute_artificial__ #endif