From patchwork Wed Jun 28 16:45:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 781774 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 3wyTFB1g5Yz9s2G for ; Thu, 29 Jun 2017 02:45:50 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="dHXD2zFx"; dkim-atps=neutral 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:subject:message-id:mime-version :content-type; q=dns; s=default; b=G62s/XHTvfSdbLEt7nJWRk9fJJGg9 WPZ7X23AaMHPlFI51jiEcfU2O1N2arKDwbrRiiFe2XB2pVcGfclJB/r4X9rQDa8Y ZaQTOwDSnGlQmDPVyXHOt9YzwWmwjUqAv1ktZw66KyE/rnZxyujnVohUI2ZtK4Lz q8LMpu/DiCqCy0= 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:subject:message-id:mime-version :content-type; s=default; bh=Tyf2hNDnXViypwI7Hx5Ode6LXEU=; b=dHX D2zFxNNIRlIMhjzLoHXc9ADLSPq7PDmUPX6FG6gqT5UY7VTkW+/W9AxvPyM8RBOe B6qWC12QKVbfda8Nym7071GUvVeE/D0kWaroMbWIYzrRLYN+jfbdhJXBEuFVFpWi 4axuUzuDmi9PwwzlRZXVz5W/pggCPjnrwQ5qAL2s= Received: (qmail 37649 invoked by alias); 28 Jun 2017 16:45:38 -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 36629 invoked by uid 89); 28 Jun 2017 16:45:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=Hx-languages-length:2241 X-HELO: relay1.mentorg.com Date: Wed, 28 Jun 2017 16:45:04 +0000 From: Joseph Myers To: Subject: Use clog10 not __clog10 in tgmath.h log10 macro [committed] Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) As a GNU extension, for _GNU_SOURCE glibc's complex.h provides a clog10 function and tgmath.h supports complex arguments to the log10 macro. However, tgmath.h uses __clog10 not clog10 in defining the macro. There is no namespace reason (ignoring the block-scope namespace issues that would apply equally to *every* function called by tgmath.h macros) for using __clog10 here, since this is only for _GNU_SOURCE so clog10 is always visible when this macro definition is used. Furthermore, __clog10f128 is not exported, so supporting _Float128 in tgmath.h implies using clog10 not __clog10 there. (__clog10 and clog10 aren't used in libstdc++ either, although that library would have a good case for using the __clog10 reserved-namespace export: the standard C++ library includes log10 of a complex number.) This patch duly changes the header to use clog10, and enables tests of the macro for complex arguments. Tested for x86_64. Committed. 2017-06-28 Joseph Myers * math/tgmath.h [__USE_GNU] (log10): Use clog10 not __clog10. * math/gen-tgmath-tests.py (Tests.add_all_tests): Test log10 for complex arguments. diff --git a/math/gen-tgmath-tests.py b/math/gen-tgmath-tests.py index db6553e..31a3bd2 100755 --- a/math/gen-tgmath-tests.py +++ b/math/gen-tgmath-tests.py @@ -497,7 +497,9 @@ class Tests(object): self.add_tests('lgamma', 'r', ['r']) self.add_tests('llrint', 'long long int', ['r']) self.add_tests('llround', 'long long int', ['r']) - self.add_tests('log10', 'r', ['r']) + # log10 is real-only in ISO C, but supports complex arguments + # as a GNU extension. + self.add_tests('log10', 'g', ['g']) self.add_tests('log1p', 'r', ['r']) self.add_tests('log2', 'r', ['r']) self.add_tests('logb', 'r', ['r']) diff --git a/math/tgmath.h b/math/tgmath.h index a0da104..7afe41e 100644 --- a/math/tgmath.h +++ b/math/tgmath.h @@ -319,7 +319,7 @@ /* Base-ten logarithm of X. */ #ifdef __USE_GNU -# define log10(Val) __TGMATH_UNARY_REAL_IMAG (Val, log10, __clog10) +# define log10(Val) __TGMATH_UNARY_REAL_IMAG (Val, log10, clog10) #else # define log10(Val) __TGMATH_UNARY_REAL_ONLY (Val, log10) #endif