changeset 38186:6411d24d4390

snippet/c++defs: fix real-floating arg functions in C++ mode Also, 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.
author Pedro Alves <palves@redhat.com>
date Mon, 14 Nov 2016 23:08:21 +0000
parents 22d91e8b29e5
children f9db91b91fbc
files ChangeLog build-aux/snippet/c++defs.h lib/math.in.h tests/test-math-c++.cc
diffstat 4 files changed, 34 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Nov 13 18:15:36 2016 -0800
+++ b/ChangeLog	Mon Nov 14 23:08:21 2016 +0000
@@ -1,3 +1,18 @@
+2016-11-14  Pedro Alves  <palves@redhat.com>
+
+	snippet/c++defs: fix real-floating arg functions in C++ mode
+	Also, 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.
+
 2016-11-13  Jim Meyering  <meyering@fb.com>
 
 	strftime: don't use __THROW
--- a/build-aux/snippet/c++defs.h	Sun Nov 13 18:15:36 2016 -0800
+++ b/build-aux/snippet/c++defs.h	Mon Nov 14 23:08:21 2016 +0000
@@ -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
--- a/lib/math.in.h	Sun Nov 13 18:15:36 2016 -0800
+++ b/lib/math.in.h	Mon Nov 14 23:08:21 2016 +0000
@@ -63,6 +63,7 @@
   return func (l);                                                  \
 }
 # define _GL_MATH_CXX_REAL_FLOATING_DECL_2(func) \
+_GL_BEGIN_NAMESPACE                                                 \
 inline int                                                          \
 func (float f)                                                      \
 {                                                                   \
@@ -77,7 +78,8 @@
 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_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_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 @@
     __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_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)
--- a/tests/test-math-c++.cc	Sun Nov 13 18:15:36 2016 -0800
+++ b/tests/test-math-c++.cc	Mon Nov 14 23:08:21 2016 +0000
@@ -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<rettype(*)parameters>(func)
+    = static_cast<rettype(*)parameters>(GNULIB_NAMESPACE::func)
 
 
 /* Keep these checks in the same order as math.in.h!  */