summaryrefslogtreecommitdiff
path: root/build-aux/snippet/c++defs.h
diff options
context:
space:
mode:
Diffstat (limited to 'build-aux/snippet/c++defs.h')
-rw-r--r--build-aux/snippet/c++defs.h91
1 files changed, 67 insertions, 24 deletions
diff --git a/build-aux/snippet/c++defs.h b/build-aux/snippet/c++defs.h
index 745ae87..2b819da 100644
--- a/build-aux/snippet/c++defs.h
+++ b/build-aux/snippet/c++defs.h
@@ -1,7 +1,5 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* C++ compatible function declaration macros.
- Copyright (C) 2010-2012 Free Software Foundation, Inc.
+ Copyright (C) 2010-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
@@ -19,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
@@ -113,14 +120,25 @@
that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
Example:
_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
- */
+
+ Wrapping rpl_func in an object with an inline conversion operator
+ avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
+ actually used in the program. */
#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
_GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
- rettype (*const func) parameters = ::rpl_func; \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return ::rpl_func; \
+ } \
+ } func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
@@ -137,8 +155,15 @@
# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
- rettype (*const func) parameters = \
- reinterpret_cast<rettype(*)parameters>(::rpl_func); \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return reinterpret_cast<type>(::rpl_func); \
+ } \
+ } func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
@@ -152,19 +177,24 @@
is defined.
Example:
_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
- */
+
+ Wrapping func in an object with an inline conversion operator
+ avoids a reference to func unless GNULIB_NAMESPACE::func is
+ actually used in the program. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
- /* If we were to write
- rettype (*const func) parameters = ::func;
- like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls
- better (remove an indirection through a 'static' pointer variable),
- but then the _GL_CXXALIASWARN macro below would cause a warning not only
- for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */
-# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
- namespace GNULIB_NAMESPACE \
- { \
- static rettype (*func) parameters = ::func; \
- } \
+# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
+ namespace GNULIB_NAMESPACE \
+ { \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return ::func; \
+ } \
+ } func = {}; \
+ } \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
@@ -180,8 +210,15 @@
# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
- static rettype (*func) parameters = \
- reinterpret_cast<rettype(*)parameters>(::func); \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return reinterpret_cast<type>(::func); \
+ } \
+ } func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
@@ -204,9 +241,15 @@
# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
namespace GNULIB_NAMESPACE \
{ \
- static rettype (*func) parameters = \
- reinterpret_cast<rettype(*)parameters>( \
- (rettype2(*)parameters2)(::func)); \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \
+ } \
+ } func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else