From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.0.0.0/16 X-Spam-Status: No, score=-2.7 required=3.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM,SPF_FAIL shortcircuit=no autolearn=no autolearn_force=no version=3.4.0 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1c6QMa-0000Um-0s for mharc-bug-gnulib@gnu.org; Mon, 14 Nov 2016 18:08:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49385) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6QMX-0000Uf-OF for bug-gnulib@gnu.org; Mon, 14 Nov 2016 18:08:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c6QMS-0004du-PT for bug-gnulib@gnu.org; Mon, 14 Nov 2016 18:08:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55346) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c6QMS-0004dn-Io for bug-gnulib@gnu.org; Mon, 14 Nov 2016 18:08:24 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9B378C04B321; Mon, 14 Nov 2016 23:08:23 +0000 (UTC) Received: from [127.0.0.1] (ovpn03.gateway.prod.ext.phx2.redhat.com [10.5.9.3]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uAEN8Lsc014783; Mon, 14 Nov 2016 18:08:22 -0500 Subject: Re: [PATCH] Fix real-floating argument functions in C++ mode To: Pedro Alves , Paul Eggert , bug-gnulib@gnu.org References: <1478967774-14453-2-git-send-email-palves@redhat.com> <580cb4e1-3787-077b-3eb3-b75ff69eb96c@cs.ucla.edu> From: Pedro Alves Message-ID: Date: Mon, 14 Nov 2016 23:08:21 +0000 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: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 14 Nov 2016 23:08:23 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Nov 2016 23:08:30 -0000 On 11/14/2016 09:19 PM, Pedro Alves wrote: > Let me try that and send a new patch. Here's an simpler implementation, IMO. I went ahead and added the _GL_BEGIN_NAMESPACE/_GL_END_NAMESPACE macros to c++defs.h as I'm fairly sure they'll end up being useful in more places. Passes same testing as before, with all tests now green. >>From cf4f33cb8f8185f1c7d7ee6dd6da45e7153ab7d2 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Mon, 14 Nov 2016 22:49:33 +0000 Subject: [PATCH] Fix real-floating argument functions in C++ mode ChangeLog: 2016-11-14 Pedro Alves Fix real-floating argument functions in C++ mode. Define isfinite, isinf, isnan, signbit in the gnulib namespace instead of in the global namespace. * build-aux/snippet/c++defs.h (_GL_BEGIN_NAMESPACE) (_GL_END_NAMESPACE): New. * lib/math.in.h (_GL_MATH_CXX_REAL_FLOATING_DECL_2): Use them. (isfinite, isinf, isnan, signbit) [__cplusplus && GNULIB_NAMESPACE]: Define them in the GNULIB_NAMESPACE namespace instead of in the global namespace. * tests/test-math-c++.cc: Check that the isfinite, isinf, isnan, signbit overloads exist in the GNULIB_NAMESPACE namespace, instead of in the global namespace. --- build-aux/snippet/c++defs.h | 9 +++++++++ lib/math.in.h | 12 +++++++----- tests/test-math-c++.cc | 5 +++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/build-aux/snippet/c++defs.h b/build-aux/snippet/c++defs.h index 8fc95e3..b19a0be 100644 --- a/build-aux/snippet/c++defs.h +++ b/build-aux/snippet/c++defs.h @@ -17,6 +17,15 @@ #ifndef _GL_CXXDEFS_H #define _GL_CXXDEFS_H +/* Begin/end the GNULIB_NAMESPACE namespace. */ +#if defined __cplusplus && defined GNULIB_NAMESPACE +# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE { +# define _GL_END_NAMESPACE } +#else +# define _GL_BEGIN_NAMESPACE +# define _GL_END_NAMESPACE +#endif + /* The three most frequent use cases of these macros are: * For providing a substitute for a function that is missing on some diff --git a/lib/math.in.h b/lib/math.in.h index 9a194cb..e1dc970 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -63,6 +63,7 @@ _gl_cxx_ ## func ## l (long double l) \ return func (l); \ } # define _GL_MATH_CXX_REAL_FLOATING_DECL_2(func) \ +_GL_BEGIN_NAMESPACE \ inline int \ func (float f) \ { \ @@ -77,7 +78,8 @@ inline int \ func (long double l) \ { \ return _gl_cxx_ ## func ## l (l); \ -} +} \ +_GL_END_NAMESPACE #endif /* Helper macros to define a portability warning for the @@ -2044,7 +2046,7 @@ _GL_EXTERN_C int gl_isfinitel (long double x); gl_isfinitef (x)) # endif # ifdef __cplusplus -# ifdef isfinite +# if defined isfinite || defined GNULIB_NAMESPACE _GL_MATH_CXX_REAL_FLOATING_DECL_1 (isfinite) # undef isfinite _GL_MATH_CXX_REAL_FLOATING_DECL_2 (isfinite) @@ -2071,7 +2073,7 @@ _GL_EXTERN_C int gl_isinfl (long double x); gl_isinff (x)) # endif # ifdef __cplusplus -# ifdef isinf +# if defined isinf || defined GNULIB_NAMESPACE _GL_MATH_CXX_REAL_FLOATING_DECL_1 (isinf) # undef isinf _GL_MATH_CXX_REAL_FLOATING_DECL_2 (isinf) @@ -2189,7 +2191,7 @@ _GL_EXTERN_C int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST; __builtin_isnanf ((float)(x))) # endif # ifdef __cplusplus -# ifdef isnan +# if defined isnan || defined GNULIB_NAMESPACE _GL_MATH_CXX_REAL_FLOATING_DECL_1 (isnan) # undef isnan _GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan) @@ -2264,7 +2266,7 @@ _GL_EXTERN_C int gl_signbitl (long double arg); gl_signbitf (x)) # endif # ifdef __cplusplus -# ifdef signbit +# if defined signbit || defined GNULIB_NAMESPACE _GL_MATH_CXX_REAL_FLOATING_DECL_1 (signbit) # undef signbit _GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit) diff --git a/tests/test-math-c++.cc b/tests/test-math-c++.cc index f0f1448..cc7378c 100644 --- a/tests/test-math-c++.cc +++ b/tests/test-math-c++.cc @@ -24,7 +24,8 @@ #include "signature.h" /* Signature check for a function that takes a real-floating argument. - Check that each overloaded function with the specified signature exists. */ + Check that each overloaded function with the specified signature + exists in the GNULIB_NAMESPACE namespace. */ #define REAL_FLOATING_CHECK(func,\ rettype1, parameters1,\ rettype2, parameters2,\ @@ -34,7 +35,7 @@ OVERLOADED_CHECK (func, rettype3, parameters3, _3) #define OVERLOADED_CHECK(func, rettype, parameters, suffix) \ static rettype (* _GL_UNUSED signature_check_ ## func ## suffix) parameters \ - = static_cast(func) + = static_cast(GNULIB_NAMESPACE::func) /* Keep these checks in the same order as math.in.h! */ -- 2.5.5