From patchwork Sat Oct 22 15:34:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 78799 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp1819139qge; Sat, 22 Oct 2016 08:35:11 -0700 (PDT) X-Received: by 10.99.171.3 with SMTP id p3mr10118049pgf.119.1477150511195; Sat, 22 Oct 2016 08:35:11 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id w189si7412792pgd.115.2016.10.22.08.35.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 22 Oct 2016 08:35:11 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-74016-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of libc-alpha-return-74016-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-74016-patch=linaro.org@sourceware.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:cc:from:message-id:date :mime-version:in-reply-to:content-type; q=dns; s=default; b=C1OD 9pbhq0LSHRDou2ZwKBWJavdFK5E1bnqqRhHNItvt4ADk//ZjB0eqFTb4+Wb1Wm6W itHyDkDvH13h1W8m61/X1+/rt40xxMCfnovQ6jVq9sPTUtdjwOKGkc77SrfXq+qZ +OR23bGXdVJ2uHiVMopeIaoj0XlBUwn1DdlMD9w= 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:subject:to:references:cc:from:message-id:date :mime-version:in-reply-to:content-type; s=default; bh=z9cg6KSRj5 stb3z0TQ2KzFgtH/U=; b=qJPCgsaPB10/Crt468cwOP/qh8fbIWOH7go3yV62oL H1Lk/FEqslN4BfHsKXm2HpDUe2l61FOw/MUAILgVyKYlF64IdTqZ0KbBv7zJRq3J 8bkvE6onzR2t91G4asliXC3mTIwjUH1IaQVZRgwkJ+B0D/a95+uQ2XI2/DVxDWon M= Received: (qmail 126576 invoked by alias); 22 Oct 2016 15:35:02 -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 126539 invoked by uid 89); 22 Oct 2016 15:35:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Wrap X-HELO: mx1.redhat.com Subject: Re: [PATCH] Define iszero as a function template for C++ [BZ #20715] To: Joseph Myers References: <2b2fa3c4-5bd6-4025-717f-fe2e2ee19555@redhat.com> Cc: GNU C Library From: Florian Weimer Message-ID: Date: Sat, 22 Oct 2016 17:34:56 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: On 10/21/2016 06:31 PM, Florian Weimer wrote: > On 10/21/2016 06:23 PM, Joseph Myers wrote: >> On Fri, 21 Oct 2016, Florian Weimer wrote: >> >>> On 10/21/2016 06:12 PM, Joseph Myers wrote: >>>> On Fri, 21 Oct 2016, Florian Weimer wrote: >>>> >>>>> Tested on x86_64, ppc64, ppc64le, s390x, aarch64. >>>>> >>>>> I'm not sure if the new test is particularly meaningful, but at >>>>> least it >>>>> catches syntax errors in . >>>> >>>> This seems fine to me (with negative zero included in the testcase), >>> >>> Oh. How do I get a negative zero? Would T{-0.0} be sufficient? Or >>> should I >> >> Yes, T{-0.0} or -T{0} should suffice. > > Thanks. Here is what I've committed. Everything is optimized away > anyway (but I deliberately introduced a bug to make sure the test still > tests something). I had to commit the attached follow-on fix to make extern "C" { #include } work again. Florian math.h: Wrap C++ bits in extern "C++" It is still common to include system header files in an extern "C" block. This means that exiting 's own extern "C" block is not sufficient to get back to C++ mode. Use an extern "C++" wrapper instead. 2016-10-22 Florian Weimer * math/math.h [__cplusplus] (iszero): Wrap C++ bits in extern "C++", to override a potential extern "C" directive around the header file inclusion. diff --git a/math/math.h b/math/math.h index 0220d08..7c0c709 100644 --- a/math/math.h +++ b/math/math.h @@ -342,7 +342,7 @@ enum # define iszero(x) (((__typeof (x)) (x)) == 0) # endif # else /* __cplusplus */ -__END_DECLS +extern "C++" { template inline bool iszero (__T __val) { @@ -352,7 +352,7 @@ iszero (__T __val) return __val == 0; # endif } -__BEGIN_DECLS +} /* extern C++ */ # endif /* __cplusplus */ #endif /* Use IEC_60559_BFP_EXT. */