libtasn1-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Libtasn1-commit] [SCM] GNU libtasn1 branch, master, updated. libtasn1_2


From: Simon Josefsson
Subject: [Libtasn1-commit] [SCM] GNU libtasn1 branch, master, updated. libtasn1_2_4-12-gad76f0c
Date: Mon, 15 Mar 2010 12:58:49 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU libtasn1".

http://git.savannah.gnu.org/cgit/libtasn1.git/commit/?id=ad76f0cee5f0a293fb05935574ac2f16b8080ebc

The branch, master has been updated
       via  ad76f0cee5f0a293fb05935574ac2f16b8080ebc (commit)
      from  8a5d86b1bcbc09012f8cf8a7ddfc3bd742ca17db (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ad76f0cee5f0a293fb05935574ac2f16b8080ebc
Author: Simon Josefsson <address@hidden>
Date:   Mon Mar 15 13:58:17 2010 +0100

    Update gnulib files.

-----------------------------------------------------------------------

Summary of changes:
 build-aux/c++defs.h                   |  233 ++++++++++++
 build-aux/vc-list-files               |    4 +-
 build-aux/warn-on-use.h               |   19 +-
 gl/Makefile.am                        |   33 ++-
 gl/m4/gnulib-common.m4                |   15 +-
 gl/m4/gnulib-comp.m4                  |   66 ++++-
 gl/m4/stdlib_h.m4                     |    4 +-
 gl/m4/unistd_h.m4                     |    4 +-
 gl/m4/warn-on-use.m4                  |    8 +-
 lib/glm4/wchar.m4 => gl/m4/wchar_h.m4 |    4 +-
 gl/stdlib.in.h                        |  311 ++++++++++++-----
 gl/unistd.in.h                        |  640 +++++++++++++++++++++++----------
 gl/wchar.in.h                         |  237 +++++++++----
 lib/gllib/Makefile.am                 |   27 ++-
 lib/gllib/wchar.in.h                  |  237 +++++++++----
 lib/glm4/gnulib-common.m4             |   15 +-
 lib/glm4/gnulib-comp.m4               |   25 ++-
 lib/glm4/warn-on-use.m4               |    8 +-
 gl/m4/wchar.m4 => lib/glm4/wchar_h.m4 |    4 +-
 19 files changed, 1465 insertions(+), 429 deletions(-)
 create mode 100644 build-aux/c++defs.h
 rename lib/glm4/wchar.m4 => gl/m4/wchar_h.m4 (97%)
 rename gl/m4/wchar.m4 => lib/glm4/wchar_h.m4 (97%)

diff --git a/build-aux/c++defs.h b/build-aux/c++defs.h
new file mode 100644
index 0000000..31b29c2
--- /dev/null
+++ b/build-aux/c++defs.h
@@ -0,0 +1,233 @@
+/* C++ compatible function declaration macros.
+   Copyright (C) 2010 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
+   by the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef _GL_CXXDEFS_H
+#define _GL_CXXDEFS_H
+
+/* The three most frequent use cases of these macros are:
+
+   * For providing a substitute for a function that is missing on some
+     platforms, but is declared and works fine on the platforms on which
+     it exists:
+
+       #if @GNULIB_FOO@
+       # if address@hidden@
+       _GL_FUNCDECL_SYS (foo, ...);
+       # endif
+       _GL_CXXALIAS_SYS (foo, ...);
+       _GL_CXXALIASWARN (foo);
+       #elif defined GNULIB_POSIXCHECK
+       ...
+       #endif
+
+   * For providing a replacement for a function that exists on all platforms,
+     but is broken/insufficient and needs to be replaced on some platforms:
+
+       #if @GNULIB_FOO@
+       # if @REPLACE_FOO@
+       #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+       #   undef foo
+       #   define foo rpl_foo
+       #  endif
+       _GL_FUNCDECL_RPL (foo, ...);
+       _GL_CXXALIAS_RPL (foo, ...);
+       # else
+       _GL_CXXALIAS_SYS (foo, ...);
+       # endif
+       _GL_CXXALIASWARN (foo);
+       #elif defined GNULIB_POSIXCHECK
+       ...
+       #endif
+
+   * For providing a replacement for a function that exists on some platforms
+     but is broken/insufficient and needs to be replaced on some of them and
+     is additionally either missing or undeclared on some other platforms:
+
+       #if @GNULIB_FOO@
+       # if @REPLACE_FOO@
+       #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+       #   undef foo
+       #   define foo rpl_foo
+       #  endif
+       _GL_FUNCDECL_RPL (foo, ...);
+       _GL_CXXALIAS_RPL (foo, ...);
+       # else
+       #  if address@hidden@   or   if address@hidden@
+       _GL_FUNCDECL_SYS (foo, ...);
+       #  endif
+       _GL_CXXALIAS_SYS (foo, ...);
+       # endif
+       _GL_CXXALIASWARN (foo);
+       #elif defined GNULIB_POSIXCHECK
+       ...
+       #endif
+*/
+
+/* _GL_EXTERN_C declaration;
+   performs the declaration with C linkage.  */
+#if defined __cplusplus
+# define _GL_EXTERN_C extern "C"
+#else
+# define _GL_EXTERN_C extern
+#endif
+
+/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
+   declares a replacement function, named rpl_func, with the given prototype,
+   consisting of return type, parameters, and attributes.
+   Example:
+     _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
+                                  _GL_ARG_NONNULL ((1)));
+ */
+#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
+  _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
+#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
+  _GL_EXTERN_C rettype rpl_func parameters_and_attributes
+
+/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
+   declares the system function, named func, with the given prototype,
+   consisting of return type, parameters, and attributes.
+   Example:
+     _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
+                                  _GL_ARG_NONNULL ((1)));
+ */
+#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
+  _GL_EXTERN_C rettype func parameters_and_attributes
+
+/* _GL_CXXALIAS_RPL (func, rettype, parameters);
+   declares a C++ alias called GNULIB_NAMESPACE::func
+   that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
+   Example:
+     _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
+ */
+#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;          \
+    }                                                         \
+    _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
+    _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIAS_SYS (func, rettype, parameters);
+   declares a C++ alias called GNULIB_NAMESPACE::func
+   that redirects to the system provided function func, if GNULIB_NAMESPACE
+   is defined.
+   Example:
+     _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
+ */
+#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;  \
+    }                                              \
+    _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
+    _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
+   is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
+   except that the C function func may have a slightly different declaration.
+   A cast is used to silence the "invalid conversion" error that would
+   otherwise occur.  */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
+    namespace GNULIB_NAMESPACE                          \
+    {                                                   \
+      static rettype (*func) parameters =               \
+        reinterpret_cast<rettype(*)parameters>(::func); \
+    }                                                   \
+    _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
+    _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
+   is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
+   except that the C function is picked among a set of overloaded functions,
+   namely the one with rettype2 and parameters2.  Two consecutive casts
+   are used to silence the "cannot find a match" and "invalid conversion"
+   errors that would otherwise occur.  */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+  /* The outer cast must be a reinterpret_cast.
+     The inner cast: When the function is defined as a set of overloaded
+     functions, it works as a static_cast<>, choosing the designated variant.
+     When the function is defined as a single variant, it works as a
+     reinterpret_cast<>. The parenthesized cast syntax works both ways.  */
+# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
+    namespace GNULIB_NAMESPACE                                                \
+    {                                                                         \
+      static rettype (*func) parameters =                                     \
+        reinterpret_cast<rettype(*)parameters>(                               \
+          (rettype2(*)parameters2)(::func));                                  \
+    }                                                                         \
+    _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
+    _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIASWARN (func);
+   causes a warning to be emitted when ::func is used but not when
+   GNULIB_NAMESPACE::func is used.  func must be defined without overloaded
+   variants.  */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIASWARN(func) \
+   _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
+# define _GL_CXXALIASWARN_1(func,namespace) \
+   _GL_CXXALIASWARN_2 (func, namespace)
+# define _GL_CXXALIASWARN_2(func,namespace) \
+   _GL_WARN_ON_USE (func, \
+                    "The symbol ::" #func " refers to the system function. " \
+                    "Use " #namespace "::" #func " instead.")
+#else
+# define _GL_CXXALIASWARN(func) \
+    _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
+   causes a warning to be emitted when the given overloaded variant of ::func
+   is used but not when GNULIB_NAMESPACE::func is used.  */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
+   _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
+                        GNULIB_NAMESPACE)
+# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) 
\
+   _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
+# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) 
\
+   _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
+                        "The symbol ::" #func " refers to the system function. 
" \
+                        "Use " #namespace "::" #func " instead.")
+#else
+# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
+    _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+#endif /* _GL_CXXDEFS_H */
diff --git a/build-aux/vc-list-files b/build-aux/vc-list-files
index c07576d..b9f2fbd 100755
--- a/build-aux/vc-list-files
+++ b/build-aux/vc-list-files
@@ -2,7 +2,7 @@
 # List version-controlled file names.
 
 # Print a version string.
-scriptversion=2009-07-21.16; # UTC
+scriptversion=2010-02-21.13; # UTC
 
 # Copyright (C) 2006-2010 Free Software Foundation, Inc.
 
@@ -85,7 +85,7 @@ elif test -d .hg; then
   eval exec hg locate '"$dir/*"' $postprocess
 elif test -d .bzr; then
   test "$postprocess" = '' && postprocess="| sed 's|^\./||'"
-  eval exec bzr ls --versioned '"$dir"' $postprocess
+  eval exec bzr ls -R --versioned '"$dir"' $postprocess
 elif test -d CVS; then
   test "$postprocess" = '' && postprocess="| sed 's|^\./||'"
   if test -x build-aux/cvsu; then
diff --git a/build-aux/warn-on-use.h b/build-aux/warn-on-use.h
index b314d36..03ae871 100644
--- a/build-aux/warn-on-use.h
+++ b/build-aux/warn-on-use.h
@@ -14,7 +14,7 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-/* _GL_WARN_ON_USE(function, "literal string") issues a declaration
+/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
    for FUNCTION which will then trigger a compiler warning containing
    the text of "literal string" anywhere that function is called, if
    supported by the compiler.  If the compiler does not support this
@@ -73,3 +73,20 @@ extern __typeof__ (function) function __attribute__ 
((__warning__ (message)))
 extern int _gl_warn_on_use
 # endif
 #endif
+
+/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
+   is like _GL_WARN_ON_USE (function, "string"), except that the function is
+   declared with the given prototype, consisting of return type, parameters,
+   and attributes.
+   This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
+   not work in this case.  */
+#ifndef _GL_WARN_ON_USE_CXX
+# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
+#  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
+extern rettype function parameters_and_attributes \
+     __attribute__ ((__warning__ (msg)))
+# else /* Unsupported.  */
+#  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
+extern int _gl_warn_on_use
+# endif
+#endif
diff --git a/gl/Makefile.am b/gl/Makefile.am
index 5f4eddd..38bd889 100644
--- a/gl/Makefile.am
+++ b/gl/Makefile.am
@@ -62,6 +62,30 @@ EXTRA_DIST += $(top_srcdir)/build-aux/arg-nonnull.h
 
 ## end   gnulib module arg-nonnull
 
+## begin gnulib module c++defs
+
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+
+BUILT_SOURCES += c++defs.h
+# The c++defs.h that gets inserted into generated .h files is the same as
+# build-aux/c++defs.h, except that it has the copyright header cut off.
+c++defs.h: $(top_srcdir)/build-aux/c++defs.h
+       $(AM_V_GEN)rm -f address@hidden $@ && \
+       sed -n -e '/_GL_CXXDEFS/,$$p' \
+         < $(top_srcdir)/build-aux/c++defs.h \
+         > address@hidden && \
+       mv address@hidden $@
+MOSTLYCLEANFILES += c++defs.h c++defs.h-t
+
+CXXDEFS_H=c++defs.h
+
+EXTRA_DIST += $(top_srcdir)/build-aux/c++defs.h
+
+## end   gnulib module c++defs
+
 ## begin gnulib module gendocs
 
 
@@ -239,7 +263,7 @@ BUILT_SOURCES += stdlib.h
 
 # We need the following in order to create <stdlib.h> when the system
 # doesn't have one that works with the given compiler.
-stdlib.h: stdlib.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
+stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
        $(AM_V_GEN)rm -f address@hidden $@ && \
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
          sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -295,6 +319,7 @@ stdlib.h: stdlib.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
              -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \
              -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \
              -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \
+             -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
              -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
              -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
              < $(srcdir)/stdlib.in.h; \
@@ -312,7 +337,7 @@ BUILT_SOURCES += unistd.h
 
 # We need the following in order to create an empty placeholder for
 # <unistd.h> when the system doesn't have one.
-unistd.h: unistd.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
+unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
        $(AM_V_GEN)rm -f address@hidden $@ && \
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \
@@ -413,6 +438,7 @@ unistd.h: unistd.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
              -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \
              -e 
's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \
              -e 
's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g'
 \
+             -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
              -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
              -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
        } > address@hidden && \
@@ -481,7 +507,7 @@ BUILT_SOURCES += wchar.h
 
 # We need the following in order to create <wchar.h> when the system
 # version does not work standalone.
-wchar.h: wchar.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
+wchar.h: wchar.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
        $(AM_V_GEN)rm -f address@hidden $@ && \
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -523,6 +549,7 @@ wchar.h: wchar.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
              -e 's|@''REPLACE_WCSRTOMBS''@|$(REPLACE_WCSRTOMBS)|g' \
              -e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \
              -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
+             -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
              -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
              -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
            < $(srcdir)/wchar.in.h; \
diff --git a/gl/m4/gnulib-common.m4 b/gl/m4/gnulib-common.m4
index b7812a8..80ba263 100644
--- a/gl/m4/gnulib-common.m4
+++ b/gl/m4/gnulib-common.m4
@@ -1,4 +1,4 @@
-# gnulib-common.m4 serial 12
+# gnulib-common.m4 serial 13
 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -61,9 +61,16 @@ m4_ifndef([AS_VAR_IF],
 [AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])])
 
 # AC_PROG_MKDIR_P
-# is a backport of autoconf-2.60's AC_PROG_MKDIR_P.
-# Remove this macro when we can assume autoconf >= 2.60.
-m4_ifdef([AC_PROG_MKDIR_P], [], [
+# is a backport of autoconf-2.60's AC_PROG_MKDIR_P, with a fix
+# for interoperability with automake-1.9.6 from autoconf-2.62.
+# Remove this macro when we can assume autoconf >= 2.62 or
+# autoconf >= 2.60 && automake >= 1.10.
+m4_ifdef([AC_PROG_MKDIR_P], [
+  dnl For automake-1.9.6 && autoconf < 2.62: Ensure MKDIR_P is AC_SUBSTed.
+  m4_define([AC_PROG_MKDIR_P],
+    m4_defn([AC_PROG_MKDIR_P])[
+    AC_SUBST([MKDIR_P])])], [
+  dnl For autoconf < 2.60: Backport of AC_PROG_MKDIR_P.
   AC_DEFUN_ONCE([AC_PROG_MKDIR_P],
     [AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake
      MKDIR_P='$(mkdir_p)'
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4
index adc6d64..5c97a53 100644
--- a/gl/m4/gnulib-comp.m4
+++ b/gl/m4/gnulib-comp.m4
@@ -25,13 +25,44 @@ AC_DEFUN([gl_EARLY],
   m4_pattern_allow([^gl_LIBOBJS$])dnl a variable
   m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable
   AC_REQUIRE([AC_PROG_RANLIB])
+  # Code from module arg-nonnull:
+  # Code from module autobuild:
   AB_INIT
+  # Code from module c++defs:
+  # Code from module extensions:
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+  # Code from module fdl-1.3:
+  # Code from module gendocs:
+  # Code from module getopt-gnu:
+  # Code from module getopt-posix:
+  # Code from module gettext-h:
+  # Code from module gnumakefile:
+  # Code from module include_next:
+  # Code from module maintainer-makefile:
+  # Code from module manywarnings:
+  # Code from module multiarch:
+  # Code from module pmccabe2html:
+  # Code from module progname:
+  # Code from module read-file:
+  # Code from module realloc-posix:
+  # Code from module stdarg:
   dnl Some compilers (e.g., AIX 5.3 cc) need to be in c99 mode
   dnl for the builtin va_copy to work.  With Autoconf 2.60 or later,
   dnl AC_PROG_CC_STDC arranges for this.  With older Autoconf AC_PROG_CC_STDC
   dnl shouldn't hurt, though installers are on their own to set c99 mode.
   AC_REQUIRE([AC_PROG_CC_STDC])
+  # Code from module stddef:
+  # Code from module stdint:
+  # Code from module stdlib:
+  # Code from module unistd:
+  # Code from module update-copyright:
+  # Code from module useless-if-before-free:
+  # Code from module vc-list-files:
+  # Code from module version-etc:
+  # Code from module version-etc-fsf:
+  # Code from module warn-on-use:
+  # Code from module warnings:
+  # Code from module wchar:
 ])
 
 # This macro should be invoked from ./configure.ac, in the section
@@ -47,11 +78,21 @@ AC_DEFUN([gl_INIT],
   m4_pushdef([gl_LIBSOURCES_DIR], [])
   gl_COMMON
   gl_source_base='gl'
+  # Code from module arg-nonnull:
+  # Code from module autobuild:
+  # Code from module c++defs:
+  # Code from module extensions:
+  # Code from module fdl-1.3:
+  # Code from module gendocs:
+  # Code from module getopt-gnu:
   gl_FUNC_GETOPT_GNU
   gl_MODULE_INDICATOR([getopt-gnu])
+  # Code from module getopt-posix:
   gl_FUNC_GETOPT_POSIX
+  # Code from module gettext-h:
   AC_SUBST([LIBINTL])
   AC_SUBST([LTLIBINTL])
+  # Code from module gnumakefile:
   # Autoconf 2.61a.99 and earlier don't support linking a file only
   # in VPATH builds.  But since GNUmakefile is for maintainer use
   # only, it does not matter if we skip the link with older autoconf.
@@ -62,23 +103,45 @@ AC_DEFUN([gl_INIT],
        m4_defn([m4_PACKAGE_VERSION])), [1], [],
         [AC_CONFIG_LINKS([$GNUmakefile:$GNUmakefile], [],
        [GNUmakefile=$GNUmakefile])])
+  # Code from module include_next:
+  # Code from module maintainer-makefile:
   AC_CONFIG_COMMANDS_PRE([m4_ifdef([AH_HEADER],
     [AC_SUBST([CONFIG_INCLUDE], m4_defn([AH_HEADER]))])])
+  # Code from module manywarnings:
+  # Code from module multiarch:
   gl_MULTIARCH
+  # Code from module pmccabe2html:
   AC_PATH_PROG([PMCCABE], [pmccabe], [false])
+  # Code from module progname:
   AC_CHECK_DECLS([program_invocation_name], [], [], [#include <errno.h>])
   AC_CHECK_DECLS([program_invocation_short_name], [], [], [#include <errno.h>])
+  # Code from module read-file:
   gl_FUNC_READ_FILE
+  # Code from module realloc-posix:
   gl_FUNC_REALLOC_POSIX
   gl_STDLIB_MODULE_INDICATOR([realloc-posix])
+  # Code from module stdarg:
   gl_STDARG_H
+  # Code from module stddef:
   gl_STDDEF_H
+  # Code from module stdint:
   gl_STDINT_H
+  # Code from module stdlib:
   gl_STDLIB_H
+  # Code from module unistd:
   gl_UNISTD_H
+  # Code from module update-copyright:
+  # Code from module useless-if-before-free:
+  # Code from module vc-list-files:
+  # Code from module version-etc:
   gl_VERSION_ETC
+  # Code from module version-etc-fsf:
+  # Code from module warn-on-use:
+  # Code from module warnings:
   AC_SUBST([WARN_CFLAGS])
+  # Code from module wchar:
   gl_WCHAR_H
+  # End of code from modules
   m4_ifval(gl_LIBSOURCES_LIST, [
     m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ ||
       for gl_file in ]gl_LIBSOURCES_LIST[ ; do
@@ -208,6 +271,7 @@ AC_DEFUN([gltests_LIBSOURCES], [
 # gnulib-tool and may be removed by future gnulib-tool invocations.
 AC_DEFUN([gl_FILE_LIST], [
   build-aux/arg-nonnull.h
+  build-aux/c++defs.h
   build-aux/gendocs.sh
   build-aux/pmccabe.css
   build-aux/pmccabe2html
@@ -256,7 +320,7 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/version-etc.m4
   m4/warn-on-use.m4
   m4/warnings.m4
-  m4/wchar.m4
+  m4/wchar_h.m4
   m4/wchar_t.m4
   m4/wint_t.m4
   top/GNUmakefile
diff --git a/gl/m4/stdlib_h.m4 b/gl/m4/stdlib_h.m4
index 0693d1a..77344bd 100644
--- a/gl/m4/stdlib_h.m4
+++ b/gl/m4/stdlib_h.m4
@@ -1,4 +1,4 @@
-# stdlib_h.m4 serial 22
+# stdlib_h.m4 serial 23
 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -43,6 +43,8 @@ AC_DEFUN([gl_STDLIB_MODULE_INDICATOR],
   dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
   
GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+  dnl Define it also as a C macro, for the benefit of the unit tests.
+  gl_MODULE_INDICATOR([$1])
 ])
 
 AC_DEFUN([gl_STDLIB_H_DEFAULTS],
diff --git a/gl/m4/unistd_h.m4 b/gl/m4/unistd_h.m4
index 31d31c1..f6c35d2 100644
--- a/gl/m4/unistd_h.m4
+++ b/gl/m4/unistd_h.m4
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 39
+# unistd_h.m4 serial 40
 dnl Copyright (C) 2006-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -47,6 +47,8 @@ AC_DEFUN([gl_UNISTD_MODULE_INDICATOR],
   dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
   
GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+  dnl Define it also as a C macro, for the benefit of the unit tests.
+  gl_MODULE_INDICATOR([$1])
 ])
 
 AC_DEFUN([gl_UNISTD_H_DEFAULTS],
diff --git a/gl/m4/warn-on-use.m4 b/gl/m4/warn-on-use.m4
index ab46422..42daae8 100644
--- a/gl/m4/warn-on-use.m4
+++ b/gl/m4/warn-on-use.m4
@@ -1,4 +1,4 @@
-# warn-on-use.m4 serial 1
+# warn-on-use.m4 serial 2
 dnl Copyright (C) 2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -30,12 +30,12 @@ AC_DEFUN([gl_WARN_ON_USE_PREPARE],
   for gl_func in m4_flatten([$2]); do
     AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl
     AC_CACHE_CHECK([whether $gl_func is declared without a macro],
-      [gl_Symbol],
+      gl_Symbol,
       [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1],
 address@hidden:@undef $gl_func
   (void) $gl_func;])],
-        [AS_VAR_SET([gl_Symbol], [yes])], [AS_VAR_SET([gl_Symbol], [no])])])
-     AS_VAR_IF([gl_Symbol], [yes],
+        [AS_VAR_SET(gl_Symbol, [yes])], [AS_VAR_SET(gl_Symbol, [no])])])
+     AS_VAR_IF(gl_Symbol, [yes],
        [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1])
        dnl shortcut - if the raw declaration exists, then set a cache
        dnl variable to allow skipping any later AC_CHECK_DECL efforts
diff --git a/lib/glm4/wchar.m4 b/gl/m4/wchar_h.m4
similarity index 97%
rename from lib/glm4/wchar.m4
rename to gl/m4/wchar_h.m4
index e81485d..0bce51c 100644
--- a/lib/glm4/wchar.m4
+++ b/gl/m4/wchar_h.m4
@@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is 
preserved.
 
 dnl Written by Eric Blake.
 
-# wchar.m4 serial 31
+# wchar_h.m4 serial 32
 
 AC_DEFUN([gl_WCHAR_H],
 [
@@ -108,6 +108,8 @@ AC_DEFUN([gl_WCHAR_MODULE_INDICATOR],
   dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
   AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
   
GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+  dnl Define it also as a C macro, for the benefit of the unit tests.
+  gl_MODULE_INDICATOR([$1])
 ])
 
 AC_DEFUN([gl_WCHAR_H_DEFAULTS],
diff --git a/gl/stdlib.in.h b/gl/stdlib.in.h
index 7f86496..cb55a52 100644
--- a/gl/stdlib.in.h
+++ b/gl/stdlib.in.h
@@ -74,6 +74,8 @@ struct random_data
 # include <unistd.h>
 #endif
 
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
 /* The definition of _GL_ARG_NONNULL is copied here.  */
 
 /* The definition of _GL_WARN_ON_USE is copied here.  */
@@ -93,16 +95,14 @@ struct random_data
 #endif
 
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #if @GNULIB_ATOLL@
-# if address@hidden@
 /* Parse a signed decimal integer.
    Returns the value of the integer.  Errors are not detected.  */
-extern long long atoll (const char *string) _GL_ARG_NONNULL ((1));
+# if address@hidden@
+_GL_FUNCDECL_SYS (atoll, long long, (const char *string) _GL_ARG_NONNULL 
((1)));
 # endif
+_GL_CXXALIAS_SYS (atoll, long long, (const char *string));
+_GL_CXXALIASWARN (atoll);
 #elif defined GNULIB_POSIXCHECK
 # undef atoll
 # if HAVE_RAW_DECL_ATOLL
@@ -113,10 +113,16 @@ _GL_WARN_ON_USE (atoll, "atoll is unportable - "
 
 #if @GNULIB_CALLOC_POSIX@
 # if address@hidden@
-#  undef calloc
-#  define calloc rpl_calloc
-extern void * calloc (size_t nmemb, size_t size);
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef calloc
+#   define calloc rpl_calloc
+#  endif
+_GL_FUNCDECL_RPL (calloc, void *, (size_t nmemb, size_t size));
+_GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size));
+# else
+_GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size));
 # endif
+_GL_CXXALIASWARN (calloc);
 #elif defined GNULIB_POSIXCHECK
 # undef calloc
 /* Assume calloc is always declared.  */
@@ -126,11 +132,20 @@ _GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant 
everywhere - "
 
 #if @GNULIB_CANONICALIZE_FILE_NAME@
 # if @REPLACE_CANONICALIZE_FILE_NAME@
-#  define canonicalize_file_name rpl_canonicalize_file_name
-# endif
-# if address@hidden@ || @REPLACE_CANONICALIZE_FILE_NAME@
-extern char *canonicalize_file_name (const char *name) _GL_ARG_NONNULL ((1));
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define canonicalize_file_name rpl_canonicalize_file_name
+#  endif
+_GL_FUNCDECL_RPL (canonicalize_file_name, char *, (const char *name)
+                                                  _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (canonicalize_file_name, char *, (const char *name)
+                                                  _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name));
 # endif
+_GL_CXXALIASWARN (canonicalize_file_name);
 #elif defined GNULIB_POSIXCHECK
 # undef canonicalize_file_name
 # if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
@@ -140,13 +155,16 @@ _GL_WARN_ON_USE (canonicalize_file_name, 
"canonicalize_file_name is unportable -
 #endif
 
 #if @GNULIB_GETLOADAVG@
-# if address@hidden@
 /* Store max(NELEM,3) load average numbers in LOADAVG[].
    The three numbers are the load average of the last 1 minute, the last 5
    minutes, and the last 15 minutes, respectively.
    LOADAVG is an array of NELEM numbers.  */
-extern int getloadavg (double loadavg[], int nelem) _GL_ARG_NONNULL ((1));
+# if address@hidden@
+_GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem)
+                                   _GL_ARG_NONNULL ((1)));
 # endif
+_GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem));
+_GL_CXXALIASWARN (getloadavg);
 #elif defined GNULIB_POSIXCHECK
 # undef getloadavg
 # if HAVE_RAW_DECL_GETLOADAVG
@@ -168,9 +186,13 @@ _GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - 
"
    For more details see the POSIX:2001 specification.
    http://www.opengroup.org/susv3xsh/getsubopt.html */
 # if address@hidden@
-extern int getsubopt (char **optionp, char *const *tokens, char **valuep)
-     _GL_ARG_NONNULL ((1, 2, 3));
+_GL_FUNCDECL_SYS (getsubopt, int,
+                  (char **optionp, char *const *tokens, char **valuep)
+                  _GL_ARG_NONNULL ((1, 2, 3)));
 # endif
+_GL_CXXALIAS_SYS (getsubopt, int,
+                  (char **optionp, char *const *tokens, char **valuep));
+_GL_CXXALIASWARN (getsubopt);
 #elif defined GNULIB_POSIXCHECK
 # undef getsubopt
 # if HAVE_RAW_DECL_GETSUBOPT
@@ -181,10 +203,16 @@ _GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - "
 
 #if @GNULIB_MALLOC_POSIX@
 # if address@hidden@
-#  undef malloc
-#  define malloc rpl_malloc
-extern void * malloc (size_t size);
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef malloc
+#   define malloc rpl_malloc
+#  endif
+_GL_FUNCDECL_RPL (malloc, void *, (size_t size));
+_GL_CXXALIAS_RPL (malloc, void *, (size_t size));
+# else
+_GL_CXXALIAS_SYS (malloc, void *, (size_t size));
 # endif
+_GL_CXXALIASWARN (malloc);
 #elif defined GNULIB_POSIXCHECK
 # undef malloc
 /* Assume malloc is always declared.  */
@@ -193,14 +221,16 @@ _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant 
everywhere - "
 #endif
 
 #if @GNULIB_MKDTEMP@
-# if address@hidden@
 /* Create a unique temporary directory from TEMPLATE.
    The last six characters of TEMPLATE must be "XXXXXX";
    they are replaced with a string that makes the directory name unique.
    Returns TEMPLATE, or a null pointer if it cannot get a unique name.
    The directory is created mode 700.  */
-extern char * mkdtemp (char * /*template*/) _GL_ARG_NONNULL ((1));
+# if address@hidden@
+_GL_FUNCDECL_SYS (mkdtemp, char *, (char * /*template*/) _GL_ARG_NONNULL 
((1)));
 # endif
+_GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/));
+_GL_CXXALIASWARN (mkdtemp);
 #elif defined GNULIB_POSIXCHECK
 # undef mkdtemp
 # if HAVE_RAW_DECL_MKDTEMP
@@ -210,7 +240,6 @@ _GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - "
 #endif
 
 #if @GNULIB_MKOSTEMP@
-# if address@hidden@
 /* Create a unique temporary file from TEMPLATE.
    The last six characters of TEMPLATE must be "XXXXXX";
    they are replaced with a string that makes the file name unique.
@@ -223,8 +252,12 @@ _GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - "
    implementation.
    Returns the open file descriptor if successful, otherwise -1 and errno
    set.  */
-extern int mkostemp (char * /*template*/, int /*flags*/) _GL_ARG_NONNULL ((1));
+# if address@hidden@
+_GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)
+                                 _GL_ARG_NONNULL ((1)));
 # endif
+_GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/));
+_GL_CXXALIASWARN (mkostemp);
 #elif defined GNULIB_POSIXCHECK
 # undef mkostemp
 # if HAVE_RAW_DECL_MKOSTEMP
@@ -234,7 +267,6 @@ _GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - "
 #endif
 
 #if @GNULIB_MKOSTEMPS@
-# if address@hidden@
 /* Create a unique temporary file from TEMPLATE.
    The last six characters of TEMPLATE before a suffix of length
    SUFFIXLEN must be "XXXXXX";
@@ -248,9 +280,14 @@ _GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - "
    implementation.
    Returns the open file descriptor if successful, otherwise -1 and errno
    set.  */
-extern int mkostemps (char * /*template*/, int /*suffixlen*/, int /*flags*/)
-     _GL_ARG_NONNULL ((1));
+# if address@hidden@
+_GL_FUNCDECL_SYS (mkostemps, int,
+                  (char * /*template*/, int /*suffixlen*/, int /*flags*/)
+                  _GL_ARG_NONNULL ((1)));
 # endif
+_GL_CXXALIAS_SYS (mkostemps, int,
+                  (char * /*template*/, int /*suffixlen*/, int /*flags*/));
+_GL_CXXALIASWARN (mkostemps);
 #elif defined GNULIB_POSIXCHECK
 # undef mkostemps
 # if HAVE_RAW_DECL_MKOSTEMPS
@@ -260,7 +297,6 @@ _GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - "
 #endif
 
 #if @GNULIB_MKSTEMP@
-# if @REPLACE_MKSTEMP@
 /* Create a unique temporary file from TEMPLATE.
    The last six characters of TEMPLATE must be "XXXXXX";
    they are replaced with a string that makes the file name unique.
@@ -270,9 +306,16 @@ _GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - "
    implementation.
    Returns the open file descriptor if successful, otherwise -1 and errno
    set.  */
-#  define mkstemp rpl_mkstemp
-extern int mkstemp (char * /*template*/) _GL_ARG_NONNULL ((1));
+# if @REPLACE_MKSTEMP@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define mkstemp rpl_mkstemp
+#  endif
+_GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/));
+# else
+_GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/));
 # endif
+_GL_CXXALIASWARN (mkstemp);
 #elif defined GNULIB_POSIXCHECK
 # undef mkstemp
 # if HAVE_RAW_DECL_MKSTEMP
@@ -282,7 +325,6 @@ _GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - "
 #endif
 
 #if @GNULIB_MKSTEMPS@
-# if address@hidden@
 /* Create a unique temporary file from TEMPLATE.
    The last six characters of TEMPLATE prior to a suffix of length
    SUFFIXLEN must be "XXXXXX";
@@ -293,9 +335,12 @@ _GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - "
    implementation.
    Returns the open file descriptor if successful, otherwise -1 and errno
    set.  */
-extern int mkstemps (char * /*template*/, int /*suffixlen*/)
-     _GL_ARG_NONNULL ((1));
+# if address@hidden@
+_GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/)
+                                 _GL_ARG_NONNULL ((1)));
 # endif
+_GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/));
+_GL_CXXALIASWARN (mkstemps);
 #elif defined GNULIB_POSIXCHECK
 # undef mkstemps
 # if HAVE_RAW_DECL_MKSTEMPS
@@ -306,45 +351,88 @@ _GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - "
 
 #if @GNULIB_PUTENV@
 # if @REPLACE_PUTENV@
-#  undef putenv
-#  define putenv rpl_putenv
-extern int putenv (char *string) _GL_ARG_NONNULL ((1));
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef putenv
+#   define putenv rpl_putenv
+#  endif
+_GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (putenv, int, (char *string));
+# else
+_GL_CXXALIAS_SYS (putenv, int, (char *string));
 # endif
+_GL_CXXALIASWARN (putenv);
 #endif
 
+
 #if @GNULIB_RANDOM_R@
 # if address@hidden@
-
 #  ifndef RAND_MAX
 #   define RAND_MAX 2147483647
 #  endif
+# endif
+#endif
 
-int srandom_r (unsigned int seed, struct random_data *rand_state)
-     _GL_ARG_NONNULL ((2));
-int initstate_r (unsigned int seed, char *buf, size_t buf_size,
-                 struct random_data *rand_state)
-     _GL_ARG_NONNULL ((2, 4));
-int setstate_r (char *arg_state, struct random_data *rand_state)
-     _GL_ARG_NONNULL ((1, 2));
-int random_r (struct random_data *buf, int32_t *result)
-     _GL_ARG_NONNULL ((1, 2));
+#if @GNULIB_RANDOM_R@
+# if address@hidden@
+_GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result)
+                                 _GL_ARG_NONNULL ((1, 2)));
 # endif
+_GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result));
+_GL_CXXALIASWARN (random_r);
 #elif defined GNULIB_POSIXCHECK
 # undef random_r
 # if HAVE_RAW_DECL_RANDOM_R
 _GL_WARN_ON_USE (random_r, "random_r is unportable - "
                  "use gnulib module random_r for portability");
 # endif
-# undef initstate_r
-# if HAVE_RAW_DECL_INITSTATE_R
-_GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - "
-                 "use gnulib module random_r for portability");
+#endif
+
+#if @GNULIB_RANDOM_R@
+# if address@hidden@
+_GL_FUNCDECL_SYS (srandom_r, int,
+                  (unsigned int seed, struct random_data *rand_state)
+                  _GL_ARG_NONNULL ((2)));
 # endif
+_GL_CXXALIAS_SYS (srandom_r, int,
+                  (unsigned int seed, struct random_data *rand_state));
+_GL_CXXALIASWARN (srandom_r);
+#elif defined GNULIB_POSIXCHECK
 # undef srandom_r
 # if HAVE_RAW_DECL_SRANDOM_R
 _GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - "
                  "use gnulib module random_r for portability");
 # endif
+#endif
+
+#if @GNULIB_RANDOM_R@
+# if address@hidden@
+_GL_FUNCDECL_SYS (initstate_r, int,
+                  (unsigned int seed, char *buf, size_t buf_size,
+                   struct random_data *rand_state)
+                  _GL_ARG_NONNULL ((2, 4)));
+# endif
+_GL_CXXALIAS_SYS (initstate_r, int,
+                  (unsigned int seed, char *buf, size_t buf_size,
+                   struct random_data *rand_state));
+_GL_CXXALIASWARN (initstate_r);
+#elif defined GNULIB_POSIXCHECK
+# undef initstate_r
+# if HAVE_RAW_DECL_INITSTATE_R
+_GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - "
+                 "use gnulib module random_r for portability");
+# endif
+#endif
+
+#if @GNULIB_RANDOM_R@
+# if address@hidden@
+_GL_FUNCDECL_SYS (setstate_r, int,
+                  (char *arg_state, struct random_data *rand_state)
+                  _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (setstate_r, int,
+                  (char *arg_state, struct random_data *rand_state));
+_GL_CXXALIASWARN (setstate_r);
+#elif defined GNULIB_POSIXCHECK
 # undef setstate_r
 # if HAVE_RAW_DECL_SETSTATE_R
 _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
@@ -352,12 +440,19 @@ _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
 # endif
 #endif
 
+
 #if @GNULIB_REALLOC_POSIX@
 # if address@hidden@
-#  undef realloc
-#  define realloc rpl_realloc
-extern void * realloc (void *ptr, size_t size);
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef realloc
+#   define realloc rpl_realloc
+#  endif
+_GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size));
+_GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
+# else
+_GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
 # endif
+_GL_CXXALIASWARN (realloc);
 #elif defined GNULIB_POSIXCHECK
 # undef realloc
 /* Assume realloc is always declared.  */
@@ -367,11 +462,20 @@ _GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant 
everywhere - "
 
 #if @GNULIB_REALPATH@
 # if @REPLACE_REALPATH@
-#  define realpath rpl_realpath
-# endif
-# if address@hidden@ || @REPLACE_REALPATH@
-extern char *realpath (const char *name, char *resolved) _GL_ARG_NONNULL ((1));
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define realpath rpl_realpath
+#  endif
+_GL_FUNCDECL_RPL (realpath, char *, (const char *name, char *resolved)
+                                    _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (realpath, char *, (const char *name, char *resolved));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (realpath, char *, (const char *name, char *resolved)
+                                    _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (realpath, char *, (const char *name, char *resolved));
 # endif
+_GL_CXXALIASWARN (realpath);
 #elif defined GNULIB_POSIXCHECK
 # undef realpath
 # if HAVE_RAW_DECL_REALPATH
@@ -381,11 +485,13 @@ _GL_WARN_ON_USE (realpath, "realpath is unportable - use 
gnulib module "
 #endif
 
 #if @GNULIB_RPMATCH@
-# if address@hidden@
 /* Test a user response to a question.
    Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear.  */
-extern int rpmatch (const char *response) _GL_ARG_NONNULL ((1));
+# if address@hidden@
+_GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1)));
 # endif
+_GL_CXXALIAS_SYS (rpmatch, int, (const char *response));
+_GL_CXXALIASWARN (rpmatch);
 #elif defined GNULIB_POSIXCHECK
 # undef rpmatch
 # if HAVE_RAW_DECL_RPMATCH
@@ -395,16 +501,28 @@ _GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - "
 #endif
 
 #if @GNULIB_SETENV@
-# if @REPLACE_SETENV@
-#  undef setenv
-#  define setenv rpl_setenv
-# endif
-# if address@hidden@ || @REPLACE_SETENV@
 /* Set NAME to VALUE in the environment.
    If REPLACE is nonzero, overwrite an existing value.  */
-extern int setenv (const char *name, const char *value, int replace)
-     _GL_ARG_NONNULL ((1));
+# if @REPLACE_SETENV@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef setenv
+#   define setenv rpl_setenv
+#  endif
+_GL_FUNCDECL_RPL (setenv, int,
+                  (const char *name, const char *value, int replace)
+                  _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (setenv, int,
+                  (const char *name, const char *value, int replace));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (setenv, int,
+                  (const char *name, const char *value, int replace)
+                  _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (setenv, int,
+                  (const char *name, const char *value, int replace));
 # endif
+_GL_CXXALIASWARN (setenv);
 #elif defined GNULIB_POSIXCHECK
 # undef setenv
 # if HAVE_RAW_DECL_SETENV
@@ -414,13 +532,22 @@ _GL_WARN_ON_USE (setenv, "setenv is unportable - "
 #endif
 
 #if @GNULIB_STRTOD@
-# if @REPLACE_STRTOD@
-#  define strtod rpl_strtod
-# endif
-# if address@hidden@ || @REPLACE_STRTOD@
  /* Parse a double from STRING, updating ENDP if appropriate.  */
-extern double strtod (const char *str, char **endp) _GL_ARG_NONNULL ((1));
+# if @REPLACE_STRTOD@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define strtod rpl_strtod
+#  endif
+_GL_FUNCDECL_RPL (strtod, double, (const char *str, char **endp)
+                                  _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (strtod, double, (const char *str, char **endp));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (strtod, double, (const char *str, char **endp)
+                                  _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (strtod, double, (const char *str, char **endp));
 # endif
+_GL_CXXALIASWARN (strtod);
 #elif defined GNULIB_POSIXCHECK
 # undef strtod
 # if HAVE_RAW_DECL_STRTOD
@@ -430,7 +557,6 @@ _GL_WARN_ON_USE (strtod, "strtod is unportable - "
 #endif
 
 #if @GNULIB_STRTOLL@
-# if address@hidden@
 /* Parse a signed integer whose textual representation starts at STRING.
    The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
    it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
@@ -439,9 +565,14 @@ _GL_WARN_ON_USE (strtod, "strtod is unportable - "
    stored in *ENDPTR.
    Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
    to ERANGE.  */
-extern long long strtoll (const char *string, char **endptr, int base)
-     _GL_ARG_NONNULL ((1));
+# if address@hidden@
+_GL_FUNCDECL_SYS (strtoll, long long,
+                  (const char *string, char **endptr, int base)
+                  _GL_ARG_NONNULL ((1)));
 # endif
+_GL_CXXALIAS_SYS (strtoll, long long,
+                  (const char *string, char **endptr, int base));
+_GL_CXXALIASWARN (strtoll);
 #elif defined GNULIB_POSIXCHECK
 # undef strtoll
 # if HAVE_RAW_DECL_STRTOLL
@@ -451,7 +582,6 @@ _GL_WARN_ON_USE (strtoll, "strtoll is unportable - "
 #endif
 
 #if @GNULIB_STRTOULL@
-# if address@hidden@
 /* Parse an unsigned integer whose textual representation starts at STRING.
    The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
    it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
@@ -460,9 +590,14 @@ _GL_WARN_ON_USE (strtoll, "strtoll is unportable - "
    stored in *ENDPTR.
    Upon overflow, the return value is ULLONG_MAX, and errno is set to
    ERANGE.  */
-extern unsigned long long strtoull (const char *string, char **endptr, int 
base)
-     _GL_ARG_NONNULL ((1));
+# if address@hidden@
+_GL_FUNCDECL_SYS (strtoull, unsigned long long,
+                  (const char *string, char **endptr, int base)
+                  _GL_ARG_NONNULL ((1)));
 # endif
+_GL_CXXALIAS_SYS (strtoull, unsigned long long,
+                  (const char *string, char **endptr, int base));
+_GL_CXXALIASWARN (strtoull);
 #elif defined GNULIB_POSIXCHECK
 # undef strtoull
 # if HAVE_RAW_DECL_STRTOULL
@@ -472,14 +607,21 @@ _GL_WARN_ON_USE (strtoull, "strtoull is unportable - "
 #endif
 
 #if @GNULIB_UNSETENV@
-# if @REPLACE_UNSETENV@
-#  undef unsetenv
-#  define unsetenv rpl_unsetenv
-# endif
-# if address@hidden@ || @REPLACE_UNSETENV@
 /* Remove the variable NAME from the environment.  */
-extern int unsetenv (const char *name) _GL_ARG_NONNULL ((1));
+# if @REPLACE_UNSETENV@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef unsetenv
+#   define unsetenv rpl_unsetenv
+#  endif
+_GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (unsetenv, int, (const char *name));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (unsetenv, int, (const char *name));
 # endif
+_GL_CXXALIASWARN (unsetenv);
 #elif defined GNULIB_POSIXCHECK
 # undef unsetenv
 # if HAVE_RAW_DECL_UNSETENV
@@ -488,9 +630,6 @@ _GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - "
 # endif
 #endif
 
-#ifdef __cplusplus
-}
-#endif
 
 #endif /* _GL_STDLIB_H */
 #endif /* _GL_STDLIB_H */
diff --git a/gl/unistd.in.h b/gl/unistd.in.h
index 27c8b17..7a208f3 100644
--- a/gl/unistd.in.h
+++ b/gl/unistd.in.h
@@ -114,6 +114,8 @@
 # endif
 #endif
 
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
 /* The definition of _GL_ARG_NONNULL is copied here.  */
 
 /* The definition of _GL_WARN_ON_USE is copied here.  */
@@ -141,25 +143,36 @@
 
 /* Declare overridden functions.  */
 
-#ifdef __cplusplus
-extern "C" {
+
+#if defined GNULIB_POSIXCHECK
+/* The access() function is a security risk.  */
+_GL_WARN_ON_USE (access, "the access function is a security risk - "
+                 "use the gnulib module faccessat instead");
 #endif
 
 
 #if @GNULIB_CHOWN@
-# if @REPLACE_CHOWN@
-#  undef chown
-#  define chown rpl_chown
-# endif
-# if address@hidden@ || @REPLACE_CHOWN@
 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
    to GID (if GID is not -1).  Follow symbolic links.
    Return 0 if successful, otherwise -1 and errno set.
    See the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/chown.html>.  */
-extern int chown (const char *file, uid_t uid, gid_t gid)
-     _GL_ARG_NONNULL ((1));
+# if @REPLACE_CHOWN@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef chown
+#   define chown rpl_chown
+#  endif
+_GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)
+                              _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)
+                              _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid));
 # endif
+_GL_CXXALIASWARN (chown);
 #elif defined GNULIB_POSIXCHECK
 # undef chown
 # if HAVE_RAW_DECL_CHOWN
@@ -173,10 +186,16 @@ _GL_WARN_ON_USE (chown, "chown fails to follow symlinks 
on some systems and "
 #if @GNULIB_CLOSE@
 # if @REPLACE_CLOSE@
 /* Automatically included by modules that need a replacement for close.  */
-#  undef close
-#  define close rpl_close
-extern int close (int);
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef close
+#   define close rpl_close
+#  endif
+_GL_FUNCDECL_RPL (close, int, (int fd));
+_GL_CXXALIAS_RPL (close, int, (int fd));
+# else
+_GL_CXXALIAS_SYS (close, int, (int fd));
 # endif
+_GL_CXXALIASWARN (close);
 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
 # undef close
 # define close close_used_without_requesting_gnulib_module_close
@@ -189,23 +208,36 @@ _GL_WARN_ON_USE (close, "close does not portably work on 
sockets - "
 
 
 #if @REPLACE_DUP@
-# define dup rpl_dup
-extern int dup (int);
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#  define dup rpl_dup
+# endif
+_GL_FUNCDECL_RPL (dup, int, (int oldfd));
+_GL_CXXALIAS_RPL (dup, int, (int oldfd));
+#else
+_GL_CXXALIAS_SYS (dup, int, (int oldfd));
 #endif
+_GL_CXXALIASWARN (dup);
 
 
 #if @GNULIB_DUP2@
-# if @REPLACE_DUP2@
-#  define dup2 rpl_dup2
-# endif
-# if address@hidden@ || @REPLACE_DUP2@
 /* Copy the file descriptor OLDFD into file descriptor NEWFD.  Do nothing if
    NEWFD = OLDFD, otherwise close NEWFD first if it is open.
    Return newfd if successful, otherwise -1 and errno set.
    See the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/dup2.html>.  */
-extern int dup2 (int oldfd, int newfd);
+# if @REPLACE_DUP2@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define dup2 rpl_dup2
+#  endif
+_GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
+_GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd));
+#  endif
+_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
 # endif
+_GL_CXXALIASWARN (dup2);
 #elif defined GNULIB_POSIXCHECK
 # undef dup2
 # if HAVE_RAW_DECL_DUP2
@@ -225,9 +257,16 @@ _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
    See the Linux man page at
    <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>.  */
 # if @HAVE_DUP3@
-#  define dup3 rpl_dup3
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define dup3 rpl_dup3
+#  endif
+_GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags));
+_GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));
+# else
+_GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags));
+_GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));
 # endif
-extern int dup3 (int oldfd, int newfd, int flags);
+_GL_CXXALIASWARN (dup3);
 #elif defined GNULIB_POSIXCHECK
 # undef dup3
 # if HAVE_RAW_DECL_DUP3
@@ -245,7 +284,13 @@ _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
 #   include <crt_externs.h>
 #   define environ (*_NSGetEnviron ())
 #  else
+#   ifdef __cplusplus
+extern "C" {
+#   endif
 extern char **environ;
+#   ifdef __cplusplus
+}
+#   endif
 #  endif
 # endif
 #elif defined GNULIB_POSIXCHECK
@@ -264,10 +309,18 @@ _GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
 
 
 #if @GNULIB_EUIDACCESS@
-# if address@hidden@
 /* Like access(), except that it uses the effective user id and group id of
    the current process.  */
-extern int euidaccess (const char *filename, int mode) _GL_ARG_NONNULL ((1));
+# if address@hidden@
+_GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode)
+                                   _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode));
+_GL_CXXALIASWARN (euidaccess);
+# if defined GNULIB_POSIXCHECK
+/* Like access(), this function is a security risk.  */
+_GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - "
+                 "use the gnulib module faccessat instead");
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef euidaccess
@@ -280,9 +333,13 @@ _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
 
 #if @GNULIB_FACCESSAT@
 # if address@hidden@
-extern int faccessat (int fd, char const *file, int mode, int flag)
-     _GL_ARG_NONNULL ((2));
+_GL_FUNCDECL_SYS (faccessat, int,
+                  (int fd, char const *file, int mode, int flag)
+                  _GL_ARG_NONNULL ((2)));
 # endif
+_GL_CXXALIAS_SYS (faccessat, int,
+                  (int fd, char const *file, int mode, int flag));
+_GL_CXXALIASWARN (faccessat);
 #elif defined GNULIB_POSIXCHECK
 # undef faccessat
 # if HAVE_RAW_DECL_FACCESSAT
@@ -293,22 +350,26 @@ _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
 
 
 #if @GNULIB_FCHDIR@
-# if @REPLACE_FCHDIR@
 /* Change the process' current working directory to the directory on which
    the given file descriptor is open.
    Return 0 if successful, otherwise -1 and errno set.
    See the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/fchdir.html>.  */
-extern int fchdir (int /*fd*/);
+# if @REPLACE_FCHDIR@
+_GL_FUNCDECL_RPL (fchdir, int, (int /*fd*/));
+_GL_CXXALIAS_RPL (fchdir, int, (int /*fd*/));
 
 /* Gnulib internal hooks needed to maintain the fchdir metadata.  */
-extern int _gl_register_fd (int fd, const char *filename)
+_GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
      _GL_ARG_NONNULL ((2));
-extern void _gl_unregister_fd (int fd);
-extern int _gl_register_dup (int oldfd, int newfd);
-extern const char *_gl_directory_name (int fd);
+_GL_EXTERN_C void _gl_unregister_fd (int fd);
+_GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
+_GL_EXTERN_C const char *_gl_directory_name (int fd);
 
+# else
+_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
 # endif
+_GL_CXXALIASWARN (fchdir);
 #elif defined GNULIB_POSIXCHECK
 # undef fchdir
 # if HAVE_RAW_DECL_FCHDIR
@@ -320,13 +381,25 @@ _GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
 
 #if @GNULIB_FCHOWNAT@
 # if @REPLACE_FCHOWNAT@
-#  undef fchownat
-#  define fchownat rpl_fchownat
-# endif
-# if address@hidden@ || @REPLACE_FCHOWNAT@
-extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int 
flag)
-     _GL_ARG_NONNULL ((2));
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef fchownat
+#   define fchownat rpl_fchownat
+#  endif
+_GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
+                                  uid_t owner, gid_t group, int flag)
+                                 _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
+                                  uid_t owner, gid_t group, int flag));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
+                                  uid_t owner, gid_t group, int flag)
+                                 _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
+                                  uid_t owner, gid_t group, int flag));
 # endif
+_GL_CXXALIASWARN (fchownat);
 #elif defined GNULIB_POSIXCHECK
 # undef fchownat
 # if HAVE_RAW_DECL_FCHOWNAT
@@ -342,8 +415,10 @@ _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
    See POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/fsync.html>.  */
 # if address@hidden@
-extern int fsync (int fd);
+_GL_FUNCDECL_SYS (fsync, int, (int fd));
 # endif
+_GL_CXXALIAS_SYS (fsync, int, (int fd));
+_GL_CXXALIASWARN (fsync);
 #elif defined GNULIB_POSIXCHECK
 # undef fsync
 # if HAVE_RAW_DECL_FSYNC
@@ -354,13 +429,15 @@ _GL_WARN_ON_USE (fsync, "fsync is unportable - "
 
 
 #if @GNULIB_FTRUNCATE@
-# if address@hidden@
 /* Change the size of the file to which FD is opened to become equal to LENGTH.
    Return 0 if successful, otherwise -1 and errno set.
    See the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/ftruncate.html>.  */
-extern int ftruncate (int fd, off_t length);
+# if address@hidden@
+_GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
 # endif
+_GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
+_GL_CXXALIASWARN (ftruncate);
 #elif defined GNULIB_POSIXCHECK
 # undef ftruncate
 # if HAVE_RAW_DECL_FTRUNCATE
@@ -371,7 +448,6 @@ _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
 
 
 #if @GNULIB_GETCWD@
-# if @REPLACE_GETCWD@
 /* Get the name of the current working directory, and put it in SIZE bytes
    of BUF.
    Return BUF if successful, or NULL if the directory couldn't be determined
@@ -382,9 +458,16 @@ _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
    extension: If BUF is NULL, an array is allocated with 'malloc'; the array
    is SIZE bytes long, unless SIZE == 0, in which case it is as big as
    necessary.  */
-#  define getcwd rpl_getcwd
-extern char * getcwd (char *buf, size_t size);
+# if @REPLACE_GETCWD@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define getcwd rpl_getcwd
+#  endif
+_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
+_GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
+# else
+_GL_CXXALIAS_SYS (getcwd, char *, (char *buf, size_t size));
 # endif
+_GL_CXXALIASWARN (getcwd);
 #elif defined GNULIB_POSIXCHECK
 # undef getcwd
 # if HAVE_RAW_DECL_GETCWD
@@ -406,8 +489,13 @@ _GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
    If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
    Return 0 if successful, otherwise set errno and return -1.  */
 # if address@hidden@
-extern int getdomainname(char *name, size_t len) _GL_ARG_NONNULL ((1));
+_GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
+                                      _GL_ARG_NONNULL ((1)));
 # endif
+/* Need to cast, because on MacOS X 10.5 systems, the second parameter is
+                                                        int len.  */
+_GL_CXXALIAS_SYS_CAST (getdomainname, int, (char *name, size_t len));
+_GL_CXXALIASWARN (getdomainname);
 #elif defined GNULIB_POSIXCHECK
 # undef getdomainname
 # if HAVE_RAW_DECL_GETDOMAINNAME
@@ -418,11 +506,13 @@ _GL_WARN_ON_USE (getdomainname, "getdomainname is 
unportable - "
 
 
 #if @GNULIB_GETDTABLESIZE@
-# if address@hidden@
 /* Return the maximum number of file descriptors in the current process.
    In POSIX, this is same as sysconf (_SC_OPEN_MAX).  */
-extern int getdtablesize (void);
+# if address@hidden@
+_GL_FUNCDECL_SYS (getdtablesize, int, (void));
 # endif
+_GL_CXXALIAS_SYS (getdtablesize, int, (void));
+_GL_CXXALIASWARN (getdtablesize);
 #elif defined GNULIB_POSIXCHECK
 # undef getdtablesize
 # if HAVE_RAW_DECL_GETDTABLESIZE
@@ -433,18 +523,25 @@ _GL_WARN_ON_USE (getdtablesize, "getdtablesize is 
unportable - "
 
 
 #if @GNULIB_GETGROUPS@
-# if @REPLACE_GETGROUPS@
-#  undef getgroups
-#  define getgroups rpl_getgroups
-# endif
-# if address@hidden@ || @REPLACE_GETGROUPS@
 /* Return the supplemental groups that the current process belongs to.
    It is unspecified whether the effective group id is in the list.
    If N is 0, return the group count; otherwise, N describes how many
    entries are available in GROUPS.  Return -1 and set errno if N is
    not 0 and not large enough.  Fails with ENOSYS on some systems.  */
-int getgroups (int n, gid_t *groups);
+# if @REPLACE_GETGROUPS@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef getgroups
+#   define getgroups rpl_getgroups
+#  endif
+_GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups));
+_GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups));
+#  endif
+_GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups));
 # endif
+_GL_CXXALIASWARN (getgroups);
 #elif defined GNULIB_POSIXCHECK
 # undef getgroups
 # if HAVE_RAW_DECL_GETGROUPS
@@ -463,12 +560,23 @@ _GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
    If the host name is longer than LEN, set errno = EINVAL and return -1.
    Return 0 if successful, otherwise set errno and return -1.  */
 # if @UNISTD_H_HAVE_WINSOCK2_H@
-#  undef gethostname
-#  define gethostname rpl_gethostname
-# endif
-# if @UNISTD_H_HAVE_WINSOCK2_H@ || address@hidden@
-extern int gethostname(char *name, size_t len) _GL_ARG_NONNULL ((1));
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef gethostname
+#   define gethostname rpl_gethostname
+#  endif
+_GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len)
+                                    _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
+                                    _GL_ARG_NONNULL ((1)));
+#  endif
+/* Need to cast, because on Solaris 10 systems, the second parameter is
+                                                      int len.  */
+_GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
 # endif
+_GL_CXXALIASWARN (gethostname);
 #elif @UNISTD_H_HAVE_WINSOCK2_H@
 # undef gethostname
 # define gethostname 
gethostname_used_without_requesting_gnulib_module_gethostname
@@ -493,8 +601,10 @@ _GL_WARN_ON_USE (gethostname, "gethostname is unportable - 
"
      $USERNAME               on native Windows platforms.
  */
 # if address@hidden@
-extern char *getlogin (void);
+_GL_FUNCDECL_SYS (getlogin, char *, (void));
 # endif
+_GL_CXXALIAS_SYS (getlogin, char *, (void));
+_GL_CXXALIASWARN (getlogin);
 #elif defined GNULIB_POSIXCHECK
 # undef getlogin
 # if HAVE_RAW_DECL_GETLOGIN
@@ -520,8 +630,13 @@ _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
      $USERNAME               on native Windows platforms.
  */
 # if address@hidden@
-extern int getlogin_r (char *name, size_t size) _GL_ARG_NONNULL ((1));
+_GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
+                                   _GL_ARG_NONNULL ((1)));
 # endif
+/* Need to cast, because on Solaris 10 systems, the second argument is
+                                                     int size.  */
+_GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
+_GL_CXXALIASWARN (getlogin_r);
 #elif defined GNULIB_POSIXCHECK
 # undef getlogin_r
 # if HAVE_RAW_DECL_GETLOGIN_R
@@ -533,53 +648,72 @@ _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
 
 #if @GNULIB_GETPAGESIZE@
 # if @REPLACE_GETPAGESIZE@
-#  define getpagesize rpl_getpagesize
-extern int getpagesize (void);
-# elif address@hidden@
-/* This is for POSIX systems.  */
-#  if !defined getpagesize && defined _SC_PAGESIZE
-#   if ! (defined __VMS && __VMS_VER < 70000000)
-#    define getpagesize() sysconf (_SC_PAGESIZE)
-#   endif
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define getpagesize rpl_getpagesize
 #  endif
+_GL_FUNCDECL_RPL (getpagesize, int, (void));
+_GL_CXXALIAS_RPL (getpagesize, int, (void));
+# else
+#  if address@hidden@
+#   if !defined getpagesize
+/* This is for POSIX systems.  */
+#    if !defined _gl_getpagesize && defined _SC_PAGESIZE
+#     if ! (defined __VMS && __VMS_VER < 70000000)
+#      define _gl_getpagesize() sysconf (_SC_PAGESIZE)
+#     endif
+#    endif
 /* This is for older VMS.  */
-#  if !defined getpagesize && defined __VMS
-#   ifdef __ALPHA
-#    define getpagesize() 8192
-#   else
-#    define getpagesize() 512
-#   endif
-#  endif
+#    if !defined _gl_getpagesize && defined __VMS
+#     ifdef __ALPHA
+#      define _gl_getpagesize() 8192
+#     else
+#      define _gl_getpagesize() 512
+#     endif
+#    endif
 /* This is for BeOS.  */
-#  if !defined getpagesize && @HAVE_OS_H@
-#   include <OS.h>
-#   if defined B_PAGE_SIZE
-#    define getpagesize() B_PAGE_SIZE
-#   endif
-#  endif
+#    if !defined _gl_getpagesize && @HAVE_OS_H@
+#     include <OS.h>
+#     if defined B_PAGE_SIZE
+#      define _gl_getpagesize() B_PAGE_SIZE
+#     endif
+#    endif
 /* This is for AmigaOS4.0.  */
-#  if !defined getpagesize && defined __amigaos4__
-#   define getpagesize() 2048
-#  endif
+#    if !defined _gl_getpagesize && defined __amigaos4__
+#     define _gl_getpagesize() 2048
+#    endif
 /* This is for older Unix systems.  */
-#  if !defined getpagesize && @HAVE_SYS_PARAM_H@
-#   include <sys/param.h>
-#   ifdef EXEC_PAGESIZE
-#    define getpagesize() EXEC_PAGESIZE
-#   else
-#    ifdef NBPG
-#     ifndef CLSIZE
-#      define CLSIZE 1
+#    if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
+#     include <sys/param.h>
+#     ifdef EXEC_PAGESIZE
+#      define _gl_getpagesize() EXEC_PAGESIZE
+#     else
+#      ifdef NBPG
+#       ifndef CLSIZE
+#        define CLSIZE 1
+#       endif
+#       define _gl_getpagesize() (NBPG * CLSIZE)
+#      else
+#       ifdef NBPC
+#        define _gl_getpagesize() NBPC
+#       endif
+#      endif
 #     endif
-#     define getpagesize() (NBPG * CLSIZE)
+#    endif
+#    if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#     define getpagesize() _gl_getpagesize ()
 #    else
-#     ifdef NBPC
-#      define getpagesize() NBPC
-#     endif
+static inline int
+getpagesize ()
+{
+  return _gl_getpagesize ();
+}
 #    endif
 #   endif
 #  endif
+/* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t.  
*/
+_GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
 # endif
+_GL_CXXALIASWARN (getpagesize);
 #elif defined GNULIB_POSIXCHECK
 # undef getpagesize
 # if HAVE_RAW_DECL_GETPAGESIZE
@@ -590,27 +724,45 @@ _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable 
- "
 
 
 #if @GNULIB_GETUSERSHELL@
-# if address@hidden@
 /* Return the next valid login shell on the system, or NULL when the end of
    the list has been reached.  */
-extern char *getusershell (void);
-/* Rewind to pointer that is advanced at each getusershell() call.  */
-extern void setusershell (void);
-/* Free the pointer that is advanced at each getusershell() call and
-   associated resources.  */
-extern void endusershell (void);
+# if address@hidden@
+_GL_FUNCDECL_SYS (getusershell, char *, (void));
 # endif
+_GL_CXXALIAS_SYS (getusershell, char *, (void));
+_GL_CXXALIASWARN (getusershell);
 #elif defined GNULIB_POSIXCHECK
 # undef getusershell
 # if HAVE_RAW_DECL_GETUSERSHELL
 _GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
                  "use gnulib module getusershell for portability");
 # endif
+#endif
+
+#if @GNULIB_GETUSERSHELL@
+/* Rewind to pointer that is advanced at each getusershell() call.  */
+# if address@hidden@
+_GL_FUNCDECL_SYS (setusershell, void, (void));
+# endif
+_GL_CXXALIAS_SYS (setusershell, void, (void));
+_GL_CXXALIASWARN (setusershell);
+#elif defined GNULIB_POSIXCHECK
 # undef setusershell
 # if HAVE_RAW_DECL_SETUSERSHELL
 _GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
                  "use gnulib module getusershell for portability");
 # endif
+#endif
+
+#if @GNULIB_GETUSERSHELL@
+/* Free the pointer that is advanced at each getusershell() call and
+   associated resources.  */
+# if address@hidden@
+_GL_FUNCDECL_SYS (endusershell, void, (void));
+# endif
+_GL_CXXALIAS_SYS (endusershell, void, (void));
+_GL_CXXALIASWARN (endusershell);
+#elif defined GNULIB_POSIXCHECK
 # undef endusershell
 # if HAVE_RAW_DECL_ENDUSERSHELL
 _GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
@@ -620,19 +772,27 @@ _GL_WARN_ON_USE (endusershell, "endusershell is 
unportable - "
 
 
 #if @GNULIB_LCHOWN@
-# if @REPLACE_LCHOWN@
-#  undef lchown
-#  define lchown rpl_lchown
-# endif
-# if address@hidden@ || @REPLACE_LCHOWN@
 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
    to GID (if GID is not -1).  Do not follow symbolic links.
    Return 0 if successful, otherwise -1 and errno set.
    See the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/lchown.html>.  */
-extern int lchown (char const *file, uid_t owner, gid_t group)
-     _GL_ARG_NONNULL ((1));
+# if @REPLACE_LCHOWN@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef lchown
+#   define lchown rpl_lchown
+#  endif
+_GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)
+                               _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)
+                               _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
 # endif
+_GL_CXXALIASWARN (lchown);
 #elif defined GNULIB_POSIXCHECK
 # undef lchown
 # if HAVE_RAW_DECL_LCHOWN
@@ -643,17 +803,25 @@ _GL_WARN_ON_USE (lchown, "lchown is unportable to 
pre-POSIX.1-2001 systems - "
 
 
 #if @GNULIB_LINK@
-# if @REPLACE_LINK@
-#  define link rpl_link
-# endif
 /* Create a new hard link for an existing file.
    Return 0 if successful, otherwise -1 and errno set.
    See POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/link.html>.  */
-# if address@hidden@ || @REPLACE_LINK@
-extern int link (const char *path1, const char *path2)
-     _GL_ARG_NONNULL ((1, 2));
+# if @REPLACE_LINK@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define link rpl_link
+#  endif
+_GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2)
+                             _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2)
+                             _GL_ARG_NONNULL ((1, 2)));
+#  endif
+_GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
 # endif
+_GL_CXXALIASWARN (link);
 #elif defined GNULIB_POSIXCHECK
 # undef link
 # if HAVE_RAW_DECL_LINK
@@ -662,19 +830,35 @@ _GL_WARN_ON_USE (link, "link is unportable - "
 # endif
 #endif
 
+
 #if @GNULIB_LINKAT@
-# if @REPLACE_LINKAT@
-#  undef linkat
-#  define linkat rpl_linkat
-# endif
 /* Create a new hard link for an existing file, relative to two
    directories.  FLAG controls whether symlinks are followed.
    Return 0 if successful, otherwise -1 and errno set.  */
-# if address@hidden@ || @REPLACE_LINKAT@
-extern int linkat (int fd1, const char *path1, int fd2, const char *path2,
+# if @REPLACE_LINKAT@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef linkat
+#   define linkat rpl_linkat
+#  endif
+_GL_FUNCDECL_RPL (linkat, int,
+                  (int fd1, const char *path1, int fd2, const char *path2,
                    int flag)
-     _GL_ARG_NONNULL ((2, 4));
+                  _GL_ARG_NONNULL ((2, 4)));
+_GL_CXXALIAS_RPL (linkat, int,
+                  (int fd1, const char *path1, int fd2, const char *path2,
+                   int flag));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (linkat, int,
+                  (int fd1, const char *path1, int fd2, const char *path2,
+                   int flag)
+                  _GL_ARG_NONNULL ((2, 4)));
+#  endif
+_GL_CXXALIAS_SYS (linkat, int,
+                  (int fd1, const char *path1, int fd2, const char *path2,
+                   int flag));
 # endif
+_GL_CXXALIASWARN (linkat);
 #elif defined GNULIB_POSIXCHECK
 # undef linkat
 # if HAVE_RAW_DECL_LINKAT
@@ -683,15 +867,22 @@ _GL_WARN_ON_USE (linkat, "linkat is unportable - "
 # endif
 #endif
 
+
 #if @GNULIB_LSEEK@
-# if @REPLACE_LSEEK@
 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
    Return the new offset if successful, otherwise -1 and errno set.
    See the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/lseek.html>.  */
-#  define lseek rpl_lseek
-   extern off_t lseek (int fd, off_t offset, int whence);
+# if @REPLACE_LSEEK@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define lseek rpl_lseek
+#  endif
+_GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
+_GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
+# else
+_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
 # endif
+_GL_CXXALIASWARN (lseek);
 #elif defined GNULIB_POSIXCHECK
 # undef lseek
 # if HAVE_RAW_DECL_LSEEK
@@ -711,9 +902,16 @@ _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE 
on pipes on some "
    See also the Linux man page at
    <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>.  */
 # if @HAVE_PIPE2@
-#  define pipe2 rpl_pipe2
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define pipe2 rpl_pipe2
+#  endif
+_GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
+# else
+_GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
 # endif
-extern int pipe2 (int fd[2], int flags) _GL_ARG_NONNULL ((1));
+_GL_CXXALIASWARN (pipe2);
 #elif defined GNULIB_POSIXCHECK
 # undef pipe2
 # if HAVE_RAW_DECL_PIPE2
@@ -724,17 +922,29 @@ _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
 
 
 #if @GNULIB_PREAD@
-# if @REPLACE_PREAD@
-#  define pread rpl_pread
-# endif
 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
    Return the number of bytes placed into BUF if successful, otherwise
    set errno and return -1.  0 indicates EOF.  See the POSIX:2001
    specification <http://www.opengroup.org/susv3xsh/pread.html>.  */
-# if address@hidden@ || @REPLACE_PREAD@
-  extern ssize_t pread (int fd, void *buf, size_t bufsize, off_t offset)
-       _GL_ARG_NONNULL ((2));
+# if @REPLACE_PREAD@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define pread rpl_pread
+#  endif
+_GL_FUNCDECL_RPL (pread, ssize_t,
+                  (int fd, void *buf, size_t bufsize, off_t offset)
+                  _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (pread, ssize_t,
+                  (int fd, void *buf, size_t bufsize, off_t offset));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (pread, ssize_t,
+                  (int fd, void *buf, size_t bufsize, off_t offset)
+                  _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (pread, ssize_t,
+                  (int fd, void *buf, size_t bufsize, off_t offset));
 # endif
+_GL_CXXALIASWARN (pread);
 #elif defined GNULIB_POSIXCHECK
 # undef pread
 # if HAVE_RAW_DECL_PREAD
@@ -745,18 +955,30 @@ _GL_WARN_ON_USE (pread, "pread is unportable - "
 
 
 #if @GNULIB_READLINK@
-# if @REPLACE_READLINK@
-#  define readlink rpl_readlink
-# endif
 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
    bytes of it into BUF.  Return the number of bytes placed into BUF if
    successful, otherwise -1 and errno set.
    See the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/readlink.html>.  */
-# if address@hidden@ || @REPLACE_READLINK@
-extern ssize_t readlink (const char *file, char *buf, size_t bufsize)
-     _GL_ARG_NONNULL ((1, 2));
+# if @REPLACE_READLINK@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define readlink rpl_readlink
+#  endif
+_GL_FUNCDECL_RPL (readlink, ssize_t,
+                  (const char *file, char *buf, size_t bufsize)
+                  _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (readlink, ssize_t,
+                  (const char *file, char *buf, size_t bufsize));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (readlink, ssize_t,
+                  (const char *file, char *buf, size_t bufsize)
+                  _GL_ARG_NONNULL ((1, 2)));
+#  endif
+_GL_CXXALIAS_SYS (readlink, ssize_t,
+                  (const char *file, char *buf, size_t bufsize));
 # endif
+_GL_CXXALIASWARN (readlink);
 #elif defined GNULIB_POSIXCHECK
 # undef readlink
 # if HAVE_RAW_DECL_READLINK
@@ -768,9 +990,13 @@ _GL_WARN_ON_USE (readlink, "readlink is unportable - "
 
 #if @GNULIB_READLINKAT@
 # if address@hidden@
-extern ssize_t readlinkat (int fd, char const *file, char *buf, size_t len)
-     _GL_ARG_NONNULL ((2, 3));
+_GL_FUNCDECL_SYS (readlinkat, ssize_t,
+                  (int fd, char const *file, char *buf, size_t len)
+                  _GL_ARG_NONNULL ((2, 3)));
 # endif
+_GL_CXXALIAS_SYS (readlinkat, ssize_t,
+                  (int fd, char const *file, char *buf, size_t len));
+_GL_CXXALIASWARN (readlinkat);
 #elif defined GNULIB_POSIXCHECK
 # undef readlinkat
 # if HAVE_RAW_DECL_READLINKAT
@@ -781,11 +1007,17 @@ _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable 
- "
 
 
 #if @GNULIB_RMDIR@
-# if @REPLACE_RMDIR@
-#  define rmdir rpl_rmdir
 /* Remove the directory DIR.  */
-extern int rmdir (char const *name) _GL_ARG_NONNULL ((1));
+# if @REPLACE_RMDIR@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define rmdir rpl_rmdir
+#  endif
+_GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (rmdir, int, (char const *name));
+# else
+_GL_CXXALIAS_SYS (rmdir, int, (char const *name));
 # endif
+_GL_CXXALIASWARN (rmdir);
 #elif defined GNULIB_POSIXCHECK
 # undef rmdir
 # if HAVE_RAW_DECL_RMDIR
@@ -796,17 +1028,24 @@ _GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
 
 
 #if @GNULIB_SLEEP@
-# if @REPLACE_SLEEP@
-#  undef sleep
-#  define sleep rpl_sleep
-# endif
 /* Pause the execution of the current thread for N seconds.
    Returns the number of seconds left to sleep.
    See the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/sleep.html>.  */
-# if address@hidden@ || @REPLACE_SLEEP@
-extern unsigned int sleep (unsigned int n);
+# if @REPLACE_SLEEP@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef sleep
+#   define sleep rpl_sleep
+#  endif
+_GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n));
+_GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n));
+#  endif
+_GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
 # endif
+_GL_CXXALIASWARN (sleep);
 #elif defined GNULIB_POSIXCHECK
 # undef sleep
 # if HAVE_RAW_DECL_SLEEP
@@ -818,13 +1057,21 @@ _GL_WARN_ON_USE (sleep, "sleep is unportable - "
 
 #if @GNULIB_SYMLINK@
 # if @REPLACE_SYMLINK@
-#  undef symlink
-#  define symlink rpl_symlink
-# endif
-# if address@hidden@ || @REPLACE_SYMLINK@
-extern int symlink (char const *contents, char const *file)
-     _GL_ARG_NONNULL ((1, 2));
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef symlink
+#   define symlink rpl_symlink
+#  endif
+_GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file)
+                                _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file)
+                                _GL_ARG_NONNULL ((1, 2)));
+#  endif
+_GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file));
 # endif
+_GL_CXXALIASWARN (symlink);
 #elif defined GNULIB_POSIXCHECK
 # undef symlink
 # if HAVE_RAW_DECL_SYMLINK
@@ -836,9 +1083,13 @@ _GL_WARN_ON_USE (symlink, "symlink is not portable - "
 
 #if @GNULIB_SYMLINKAT@
 # if address@hidden@
-extern int symlinkat (char const *contents, int fd, char const *file)
-     _GL_ARG_NONNULL ((1, 3));
+_GL_FUNCDECL_SYS (symlinkat, int,
+                  (char const *contents, int fd, char const *file)
+                  _GL_ARG_NONNULL ((1, 3)));
 # endif
+_GL_CXXALIAS_SYS (symlinkat, int,
+                  (char const *contents, int fd, char const *file));
+_GL_CXXALIASWARN (symlinkat);
 #elif defined GNULIB_POSIXCHECK
 # undef symlinkat
 # if HAVE_RAW_DECL_SYMLINKAT
@@ -850,10 +1101,16 @@ _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - 
"
 
 #if @GNULIB_UNLINK@
 # if @REPLACE_UNLINK@
-#  undef unlink
-#  define unlink rpl_unlink
-extern int unlink (char const *file) _GL_ARG_NONNULL ((1));
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef unlink
+#   define unlink rpl_unlink
+#  endif
+_GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (unlink, int, (char const *file));
+# else
+_GL_CXXALIAS_SYS (unlink, int, (char const *file));
 # endif
+_GL_CXXALIASWARN (unlink);
 #elif defined GNULIB_POSIXCHECK
 # undef unlink
 # if HAVE_RAW_DECL_UNLINK
@@ -865,12 +1122,21 @@ _GL_WARN_ON_USE (unlink, "unlink is not portable - "
 
 #if @GNULIB_UNLINKAT@
 # if @REPLACE_UNLINKAT@
-#  undef unlinkat
-#  define unlinkat rpl_unlinkat
-# endif
-# if address@hidden@ || @REPLACE_UNLINKAT@
-extern int unlinkat (int fd, char const *file, int flag) _GL_ARG_NONNULL ((2));
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef unlinkat
+#   define unlinkat rpl_unlinkat
+#  endif
+_GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag)
+                                 _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag)
+                                 _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
 # endif
+_GL_CXXALIASWARN (unlinkat);
 #elif defined GNULIB_POSIXCHECK
 # undef unlinkat
 # if HAVE_RAW_DECL_UNLINKAT
@@ -881,17 +1147,24 @@ _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
 
 
 #if @GNULIB_USLEEP@
-# if @REPLACE_USLEEP@
-#  undef usleep
-#  define usleep rpl_usleep
-# endif
-# if address@hidden@ || @REPLACE_USLEEP@
 /* Pause the execution of the current thread for N microseconds.
    Returns 0 on completion, or -1 on range error.
    See the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/sleep.html>.  */
-extern int usleep (useconds_t n);
+# if @REPLACE_USLEEP@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef usleep
+#   define usleep rpl_usleep
+#  endif
+_GL_FUNCDECL_RPL (usleep, int, (useconds_t n));
+_GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
+#  endif
+_GL_CXXALIAS_SYS (usleep, int, (useconds_t n));
 # endif
+_GL_CXXALIASWARN (usleep);
 #elif defined GNULIB_POSIXCHECK
 # undef usleep
 # if HAVE_RAW_DECL_USLEEP
@@ -901,19 +1174,22 @@ _GL_WARN_ON_USE (usleep, "usleep is unportable - "
 #endif
 
 
-#if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
+#if @GNULIB_WRITE@
 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
    See the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/write.html>.  */
-# undef write
-# define write rpl_write
-extern ssize_t write (int fd, const void *buf, size_t count)
-     _GL_ARG_NONNULL ((2));
-#endif
-
-
-#ifdef __cplusplus
-}
+# if @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef write
+#   define write rpl_write
+#  endif
+_GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
+                                  _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
+# else
+_GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count));
+# endif
+_GL_CXXALIASWARN (write);
 #endif
 
 
diff --git a/gl/wchar.in.h b/gl/wchar.in.h
index 6342b4e..287204f 100644
--- a/gl/wchar.in.h
+++ b/gl/wchar.in.h
@@ -75,14 +75,12 @@
 #ifndef _GL_WCHAR_H
 #define _GL_WCHAR_H
 
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
 /* The definition of _GL_ARG_NONNULL is copied here.  */
 
 /* The definition of _GL_WARN_ON_USE is copied here.  */
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 
 /* Define wint_t.  (Also done in wctype.in.h.)  */
 #if address@hidden@ && !defined wint_t
@@ -107,12 +105,19 @@ typedef int rpl_mbstate_t;
 /* Convert a single-byte character to a wide character.  */
 #if @GNULIB_BTOWC@
 # if @REPLACE_BTOWC@
-#  undef btowc
-#  define btowc rpl_btowc
-# endif
-# if address@hidden@ || @REPLACE_BTOWC@
-extern wint_t btowc (int c);
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef btowc
+#   define btowc rpl_btowc
+#  endif
+_GL_FUNCDECL_RPL (btowc, wint_t, (int c));
+_GL_CXXALIAS_RPL (btowc, wint_t, (int c));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (btowc, wint_t, (int c));
+#  endif
+_GL_CXXALIAS_SYS (btowc, wint_t, (int c));
 # endif
+_GL_CXXALIASWARN (btowc);
 #elif defined GNULIB_POSIXCHECK
 # undef btowc
 # if HAVE_RAW_DECL_BTOWC
@@ -125,13 +130,20 @@ _GL_WARN_ON_USE (btowc, "btowc is unportable - "
 /* Convert a wide character to a single-byte character.  */
 #if @GNULIB_WCTOB@
 # if @REPLACE_WCTOB@
-#  undef wctob
-#  define wctob rpl_wctob
-# endif
-# if (!defined wctob && address@hidden@) || @REPLACE_WCTOB@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef wctob
+#   define wctob rpl_wctob
+#  endif
+_GL_FUNCDECL_RPL (wctob, int, (wint_t wc));
+_GL_CXXALIAS_RPL (wctob, int, (wint_t wc));
+# else
+#  if !defined wctob && address@hidden@
 /* wctob is provided by gnulib, or wctob exists but is not declared.  */
-extern int wctob (wint_t wc);
+_GL_FUNCDECL_SYS (wctob, int, (wint_t wc));
+#  endif
+_GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
 # endif
+_GL_CXXALIASWARN (wctob);
 #elif defined GNULIB_POSIXCHECK
 # undef wctob
 # if HAVE_RAW_DECL_WCTOB
@@ -144,12 +156,19 @@ _GL_WARN_ON_USE (wctob, "wctob is unportable - "
 /* Test whether *PS is in the initial state.  */
 #if @GNULIB_MBSINIT@
 # if @REPLACE_MBSINIT@
-#  undef mbsinit
-#  define mbsinit rpl_mbsinit
-# endif
-# if address@hidden@ || @REPLACE_MBSINIT@
-extern int mbsinit (const mbstate_t *ps);
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef mbsinit
+#   define mbsinit rpl_mbsinit
+#  endif
+_GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps));
+_GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps));
+#  endif
+_GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
 # endif
+_GL_CXXALIASWARN (mbsinit);
 #elif defined GNULIB_POSIXCHECK
 # undef mbsinit
 # if HAVE_RAW_DECL_MBSINIT
@@ -162,12 +181,23 @@ _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
 /* Convert a multibyte character to a wide character.  */
 #if @GNULIB_MBRTOWC@
 # if @REPLACE_MBRTOWC@
-#  undef mbrtowc
-#  define mbrtowc rpl_mbrtowc
-# endif
-# if address@hidden@ || @REPLACE_MBRTOWC@
-extern size_t mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps);
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef mbrtowc
+#   define mbrtowc rpl_mbrtowc
+#  endif
+_GL_FUNCDECL_RPL (mbrtowc, size_t,
+                  (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
+_GL_CXXALIAS_RPL (mbrtowc, size_t,
+                  (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (mbrtowc, size_t,
+                  (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
+#  endif
+_GL_CXXALIAS_SYS (mbrtowc, size_t,
+                  (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
 # endif
+_GL_CXXALIASWARN (mbrtowc);
 #elif defined GNULIB_POSIXCHECK
 # undef mbrtowc
 # if HAVE_RAW_DECL_MBRTOWC
@@ -180,12 +210,19 @@ _GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
 /* Recognize a multibyte character.  */
 #if @GNULIB_MBRLEN@
 # if @REPLACE_MBRLEN@
-#  undef mbrlen
-#  define mbrlen rpl_mbrlen
-# endif
-# if address@hidden@ || @REPLACE_MBRLEN@
-extern size_t mbrlen (const char *s, size_t n, mbstate_t *ps);
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef mbrlen
+#   define mbrlen rpl_mbrlen
+#  endif
+_GL_FUNCDECL_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
+_GL_CXXALIAS_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
+#  endif
+_GL_CXXALIAS_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
 # endif
+_GL_CXXALIASWARN (mbrlen);
 #elif defined GNULIB_POSIXCHECK
 # undef mbrlen
 # if HAVE_RAW_DECL_MBRLEN
@@ -198,13 +235,27 @@ _GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
 /* Convert a string to a wide string.  */
 #if @GNULIB_MBSRTOWCS@
 # if @REPLACE_MBSRTOWCS@
-#  undef mbsrtowcs
-#  define mbsrtowcs rpl_mbsrtowcs
-# endif
-# if address@hidden@ || @REPLACE_MBSRTOWCS@
-extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, 
mbstate_t *ps)
-     _GL_ARG_NONNULL ((2));
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef mbsrtowcs
+#   define mbsrtowcs rpl_mbsrtowcs
+#  endif
+_GL_FUNCDECL_RPL (mbsrtowcs, size_t,
+                  (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
+                  _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (mbsrtowcs, size_t,
+                  (wchar_t *dest, const char **srcp, size_t len,
+                   mbstate_t *ps));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (mbsrtowcs, size_t,
+                  (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
+                  _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (mbsrtowcs, size_t,
+                  (wchar_t *dest, const char **srcp, size_t len,
+                   mbstate_t *ps));
 # endif
+_GL_CXXALIASWARN (mbsrtowcs);
 #elif defined GNULIB_POSIXCHECK
 # undef mbsrtowcs
 # if HAVE_RAW_DECL_MBSRTOWCS
@@ -217,13 +268,29 @@ _GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
 /* Convert a string to a wide string.  */
 #if @GNULIB_MBSNRTOWCS@
 # if @REPLACE_MBSNRTOWCS@
-#  undef mbsnrtowcs
-#  define mbsnrtowcs rpl_mbsnrtowcs
-# endif
-# if address@hidden@ || @REPLACE_MBSNRTOWCS@
-extern size_t mbsnrtowcs (wchar_t *dest, const char **srcp, size_t srclen, 
size_t len, mbstate_t *ps)
-     _GL_ARG_NONNULL ((2));
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef mbsnrtowcs
+#   define mbsnrtowcs rpl_mbsnrtowcs
+#  endif
+_GL_FUNCDECL_RPL (mbsnrtowcs, size_t,
+                  (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
+                   mbstate_t *ps)
+                  _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (mbsnrtowcs, size_t,
+                  (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
+                   mbstate_t *ps));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (mbsnrtowcs, size_t,
+                  (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
+                   mbstate_t *ps)
+                  _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
+                  (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
+                   mbstate_t *ps));
 # endif
+_GL_CXXALIASWARN (mbsnrtowcs);
 #elif defined GNULIB_POSIXCHECK
 # undef mbsnrtowcs
 # if HAVE_RAW_DECL_MBSNRTOWCS
@@ -236,12 +303,19 @@ _GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
 /* Convert a wide character to a multibyte character.  */
 #if @GNULIB_WCRTOMB@
 # if @REPLACE_WCRTOMB@
-#  undef wcrtomb
-#  define wcrtomb rpl_wcrtomb
-# endif
-# if address@hidden@ || @REPLACE_WCRTOMB@
-extern size_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps);
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef wcrtomb
+#   define wcrtomb rpl_wcrtomb
+#  endif
+_GL_FUNCDECL_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
+_GL_CXXALIAS_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
+#  endif
+_GL_CXXALIAS_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
 # endif
+_GL_CXXALIASWARN (wcrtomb);
 #elif defined GNULIB_POSIXCHECK
 # undef wcrtomb
 # if HAVE_RAW_DECL_WCRTOMB
@@ -254,13 +328,27 @@ _GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
 /* Convert a wide string to a string.  */
 #if @GNULIB_WCSRTOMBS@
 # if @REPLACE_WCSRTOMBS@
-#  undef wcsrtombs
-#  define wcsrtombs rpl_wcsrtombs
-# endif
-# if address@hidden@ || @REPLACE_WCSRTOMBS@
-extern size_t wcsrtombs (char *dest, const wchar_t **srcp, size_t len, 
mbstate_t *ps)
-     _GL_ARG_NONNULL ((2));
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef wcsrtombs
+#   define wcsrtombs rpl_wcsrtombs
+#  endif
+_GL_FUNCDECL_RPL (wcsrtombs, size_t,
+                  (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
+                  _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (wcsrtombs, size_t,
+                  (char *dest, const wchar_t **srcp, size_t len,
+                   mbstate_t *ps));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (wcsrtombs, size_t,
+                  (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
+                  _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (wcsrtombs, size_t,
+                  (char *dest, const wchar_t **srcp, size_t len,
+                   mbstate_t *ps));
 # endif
+_GL_CXXALIASWARN (wcsrtombs);
 #elif defined GNULIB_POSIXCHECK
 # undef wcsrtombs
 # if HAVE_RAW_DECL_WCSRTOMBS
@@ -273,13 +361,29 @@ _GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - "
 /* Convert a wide string to a string.  */
 #if @GNULIB_WCSNRTOMBS@
 # if @REPLACE_WCSNRTOMBS@
-#  undef wcsnrtombs
-#  define wcsnrtombs rpl_wcsnrtombs
-# endif
-# if address@hidden@ || @REPLACE_WCSNRTOMBS@
-extern size_t wcsnrtombs (char *dest, const wchar_t **srcp, size_t srclen, 
size_t len, mbstate_t *ps)
-     _GL_ARG_NONNULL ((2));
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef wcsnrtombs
+#   define wcsnrtombs rpl_wcsnrtombs
+#  endif
+_GL_FUNCDECL_RPL (wcsnrtombs, size_t,
+                  (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
+                   mbstate_t *ps)
+                  _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (wcsnrtombs, size_t,
+                  (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
+                   mbstate_t *ps));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (wcsnrtombs, size_t,
+                  (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
+                   mbstate_t *ps)
+                  _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (wcsnrtombs, size_t,
+                  (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
+                   mbstate_t *ps));
 # endif
+_GL_CXXALIASWARN (wcsnrtombs);
 #elif defined GNULIB_POSIXCHECK
 # undef wcsnrtombs
 # if HAVE_RAW_DECL_WCSNRTOMBS
@@ -292,15 +396,20 @@ _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
 /* Return the number of screen columns needed for WC.  */
 #if @GNULIB_WCWIDTH@
 # if @REPLACE_WCWIDTH@
-#  undef wcwidth
-#  define wcwidth rpl_wcwidth
-extern int wcwidth (wchar_t);
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef wcwidth
+#   define wcwidth rpl_wcwidth
+#  endif
+_GL_FUNCDECL_RPL (wcwidth, int, (wchar_t));
+_GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
 # else
 #  if !defined wcwidth && address@hidden@
 /* wcwidth exists but is not declared.  */
-extern int wcwidth (int /* actually wchar_t */);
+_GL_FUNCDECL_SYS (wcwidth, int, (wchar_t));
 #  endif
+_GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
 # endif
+_GL_CXXALIASWARN (wcwidth);
 #elif defined GNULIB_POSIXCHECK
 # undef wcwidth
 # if HAVE_RAW_DECL_WCWIDTH
@@ -310,10 +419,6 @@ _GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
 #endif
 
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif /* _GL_WCHAR_H */
 #endif /* _GL_WCHAR_H */
 #endif
diff --git a/lib/gllib/Makefile.am b/lib/gllib/Makefile.am
index b7a68ae..c6a6354 100644
--- a/lib/gllib/Makefile.am
+++ b/lib/gllib/Makefile.am
@@ -61,6 +61,30 @@ EXTRA_DIST += $(top_srcdir)/build-aux/arg-nonnull.h
 
 ## end   gnulib module arg-nonnull
 
+## begin gnulib module c++defs
+
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+
+BUILT_SOURCES += c++defs.h
+# The c++defs.h that gets inserted into generated .h files is the same as
+# build-aux/c++defs.h, except that it has the copyright header cut off.
+c++defs.h: $(top_srcdir)/build-aux/c++defs.h
+       $(AM_V_GEN)rm -f address@hidden $@ && \
+       sed -n -e '/_GL_CXXDEFS/,$$p' \
+         < $(top_srcdir)/build-aux/c++defs.h \
+         > address@hidden && \
+       mv address@hidden $@
+MOSTLYCLEANFILES += c++defs.h c++defs.h-t
+
+CXXDEFS_H=c++defs.h
+
+EXTRA_DIST += $(top_srcdir)/build-aux/c++defs.h
+
+## end   gnulib module c++defs
+
 ## begin gnulib module lib-symbol-visibility
 
 # The value of $(CFLAG_VISIBILITY) needs to be added to the CFLAGS for the
@@ -161,7 +185,7 @@ BUILT_SOURCES += wchar.h
 
 # We need the following in order to create <wchar.h> when the system
 # version does not work standalone.
-wchar.h: wchar.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
+wchar.h: wchar.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
        $(AM_V_GEN)rm -f address@hidden $@ && \
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -203,6 +227,7 @@ wchar.h: wchar.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
              -e 's|@''REPLACE_WCSRTOMBS''@|$(REPLACE_WCSRTOMBS)|g' \
              -e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \
              -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
+             -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
              -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
              -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
            < $(srcdir)/wchar.in.h; \
diff --git a/lib/gllib/wchar.in.h b/lib/gllib/wchar.in.h
index c492dd6..3eeafd1 100644
--- a/lib/gllib/wchar.in.h
+++ b/lib/gllib/wchar.in.h
@@ -75,14 +75,12 @@
 #ifndef _GL_WCHAR_H
 #define _GL_WCHAR_H
 
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
 /* The definition of _GL_ARG_NONNULL is copied here.  */
 
 /* The definition of _GL_WARN_ON_USE is copied here.  */
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 
 /* Define wint_t.  (Also done in wctype.in.h.)  */
 #if address@hidden@ && !defined wint_t
@@ -107,12 +105,19 @@ typedef int rpl_mbstate_t;
 /* Convert a single-byte character to a wide character.  */
 #if @GNULIB_BTOWC@
 # if @REPLACE_BTOWC@
-#  undef btowc
-#  define btowc rpl_btowc
-# endif
-# if address@hidden@ || @REPLACE_BTOWC@
-extern wint_t btowc (int c);
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef btowc
+#   define btowc rpl_btowc
+#  endif
+_GL_FUNCDECL_RPL (btowc, wint_t, (int c));
+_GL_CXXALIAS_RPL (btowc, wint_t, (int c));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (btowc, wint_t, (int c));
+#  endif
+_GL_CXXALIAS_SYS (btowc, wint_t, (int c));
 # endif
+_GL_CXXALIASWARN (btowc);
 #elif defined GNULIB_POSIXCHECK
 # undef btowc
 # if HAVE_RAW_DECL_BTOWC
@@ -125,13 +130,20 @@ _GL_WARN_ON_USE (btowc, "btowc is unportable - "
 /* Convert a wide character to a single-byte character.  */
 #if @GNULIB_WCTOB@
 # if @REPLACE_WCTOB@
-#  undef wctob
-#  define wctob rpl_wctob
-# endif
-# if (!defined wctob && address@hidden@) || @REPLACE_WCTOB@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef wctob
+#   define wctob rpl_wctob
+#  endif
+_GL_FUNCDECL_RPL (wctob, int, (wint_t wc));
+_GL_CXXALIAS_RPL (wctob, int, (wint_t wc));
+# else
+#  if !defined wctob && address@hidden@
 /* wctob is provided by gnulib, or wctob exists but is not declared.  */
-extern int wctob (wint_t wc);
+_GL_FUNCDECL_SYS (wctob, int, (wint_t wc));
+#  endif
+_GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
 # endif
+_GL_CXXALIASWARN (wctob);
 #elif defined GNULIB_POSIXCHECK
 # undef wctob
 # if HAVE_RAW_DECL_WCTOB
@@ -144,12 +156,19 @@ _GL_WARN_ON_USE (wctob, "wctob is unportable - "
 /* Test whether *PS is in the initial state.  */
 #if @GNULIB_MBSINIT@
 # if @REPLACE_MBSINIT@
-#  undef mbsinit
-#  define mbsinit rpl_mbsinit
-# endif
-# if address@hidden@ || @REPLACE_MBSINIT@
-extern int mbsinit (const mbstate_t *ps);
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef mbsinit
+#   define mbsinit rpl_mbsinit
+#  endif
+_GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps));
+_GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps));
+#  endif
+_GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
 # endif
+_GL_CXXALIASWARN (mbsinit);
 #elif defined GNULIB_POSIXCHECK
 # undef mbsinit
 # if HAVE_RAW_DECL_MBSINIT
@@ -162,12 +181,23 @@ _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
 /* Convert a multibyte character to a wide character.  */
 #if @GNULIB_MBRTOWC@
 # if @REPLACE_MBRTOWC@
-#  undef mbrtowc
-#  define mbrtowc rpl_mbrtowc
-# endif
-# if address@hidden@ || @REPLACE_MBRTOWC@
-extern size_t mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps);
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef mbrtowc
+#   define mbrtowc rpl_mbrtowc
+#  endif
+_GL_FUNCDECL_RPL (mbrtowc, size_t,
+                  (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
+_GL_CXXALIAS_RPL (mbrtowc, size_t,
+                  (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (mbrtowc, size_t,
+                  (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
+#  endif
+_GL_CXXALIAS_SYS (mbrtowc, size_t,
+                  (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
 # endif
+_GL_CXXALIASWARN (mbrtowc);
 #elif defined GNULIB_POSIXCHECK
 # undef mbrtowc
 # if HAVE_RAW_DECL_MBRTOWC
@@ -180,12 +210,19 @@ _GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
 /* Recognize a multibyte character.  */
 #if @GNULIB_MBRLEN@
 # if @REPLACE_MBRLEN@
-#  undef mbrlen
-#  define mbrlen rpl_mbrlen
-# endif
-# if address@hidden@ || @REPLACE_MBRLEN@
-extern size_t mbrlen (const char *s, size_t n, mbstate_t *ps);
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef mbrlen
+#   define mbrlen rpl_mbrlen
+#  endif
+_GL_FUNCDECL_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
+_GL_CXXALIAS_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
+#  endif
+_GL_CXXALIAS_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
 # endif
+_GL_CXXALIASWARN (mbrlen);
 #elif defined GNULIB_POSIXCHECK
 # undef mbrlen
 # if HAVE_RAW_DECL_MBRLEN
@@ -198,13 +235,27 @@ _GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
 /* Convert a string to a wide string.  */
 #if @GNULIB_MBSRTOWCS@
 # if @REPLACE_MBSRTOWCS@
-#  undef mbsrtowcs
-#  define mbsrtowcs rpl_mbsrtowcs
-# endif
-# if address@hidden@ || @REPLACE_MBSRTOWCS@
-extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, 
mbstate_t *ps)
-     _GL_ARG_NONNULL ((2));
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef mbsrtowcs
+#   define mbsrtowcs rpl_mbsrtowcs
+#  endif
+_GL_FUNCDECL_RPL (mbsrtowcs, size_t,
+                  (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
+                  _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (mbsrtowcs, size_t,
+                  (wchar_t *dest, const char **srcp, size_t len,
+                   mbstate_t *ps));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (mbsrtowcs, size_t,
+                  (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
+                  _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (mbsrtowcs, size_t,
+                  (wchar_t *dest, const char **srcp, size_t len,
+                   mbstate_t *ps));
 # endif
+_GL_CXXALIASWARN (mbsrtowcs);
 #elif defined GNULIB_POSIXCHECK
 # undef mbsrtowcs
 # if HAVE_RAW_DECL_MBSRTOWCS
@@ -217,13 +268,29 @@ _GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
 /* Convert a string to a wide string.  */
 #if @GNULIB_MBSNRTOWCS@
 # if @REPLACE_MBSNRTOWCS@
-#  undef mbsnrtowcs
-#  define mbsnrtowcs rpl_mbsnrtowcs
-# endif
-# if address@hidden@ || @REPLACE_MBSNRTOWCS@
-extern size_t mbsnrtowcs (wchar_t *dest, const char **srcp, size_t srclen, 
size_t len, mbstate_t *ps)
-     _GL_ARG_NONNULL ((2));
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef mbsnrtowcs
+#   define mbsnrtowcs rpl_mbsnrtowcs
+#  endif
+_GL_FUNCDECL_RPL (mbsnrtowcs, size_t,
+                  (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
+                   mbstate_t *ps)
+                  _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (mbsnrtowcs, size_t,
+                  (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
+                   mbstate_t *ps));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (mbsnrtowcs, size_t,
+                  (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
+                   mbstate_t *ps)
+                  _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
+                  (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
+                   mbstate_t *ps));
 # endif
+_GL_CXXALIASWARN (mbsnrtowcs);
 #elif defined GNULIB_POSIXCHECK
 # undef mbsnrtowcs
 # if HAVE_RAW_DECL_MBSNRTOWCS
@@ -236,12 +303,19 @@ _GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
 /* Convert a wide character to a multibyte character.  */
 #if @GNULIB_WCRTOMB@
 # if @REPLACE_WCRTOMB@
-#  undef wcrtomb
-#  define wcrtomb rpl_wcrtomb
-# endif
-# if address@hidden@ || @REPLACE_WCRTOMB@
-extern size_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps);
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef wcrtomb
+#   define wcrtomb rpl_wcrtomb
+#  endif
+_GL_FUNCDECL_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
+_GL_CXXALIAS_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
+#  endif
+_GL_CXXALIAS_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
 # endif
+_GL_CXXALIASWARN (wcrtomb);
 #elif defined GNULIB_POSIXCHECK
 # undef wcrtomb
 # if HAVE_RAW_DECL_WCRTOMB
@@ -254,13 +328,27 @@ _GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
 /* Convert a wide string to a string.  */
 #if @GNULIB_WCSRTOMBS@
 # if @REPLACE_WCSRTOMBS@
-#  undef wcsrtombs
-#  define wcsrtombs rpl_wcsrtombs
-# endif
-# if address@hidden@ || @REPLACE_WCSRTOMBS@
-extern size_t wcsrtombs (char *dest, const wchar_t **srcp, size_t len, 
mbstate_t *ps)
-     _GL_ARG_NONNULL ((2));
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef wcsrtombs
+#   define wcsrtombs rpl_wcsrtombs
+#  endif
+_GL_FUNCDECL_RPL (wcsrtombs, size_t,
+                  (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
+                  _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (wcsrtombs, size_t,
+                  (char *dest, const wchar_t **srcp, size_t len,
+                   mbstate_t *ps));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (wcsrtombs, size_t,
+                  (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
+                  _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (wcsrtombs, size_t,
+                  (char *dest, const wchar_t **srcp, size_t len,
+                   mbstate_t *ps));
 # endif
+_GL_CXXALIASWARN (wcsrtombs);
 #elif defined GNULIB_POSIXCHECK
 # undef wcsrtombs
 # if HAVE_RAW_DECL_WCSRTOMBS
@@ -273,13 +361,29 @@ _GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - "
 /* Convert a wide string to a string.  */
 #if @GNULIB_WCSNRTOMBS@
 # if @REPLACE_WCSNRTOMBS@
-#  undef wcsnrtombs
-#  define wcsnrtombs rpl_wcsnrtombs
-# endif
-# if address@hidden@ || @REPLACE_WCSNRTOMBS@
-extern size_t wcsnrtombs (char *dest, const wchar_t **srcp, size_t srclen, 
size_t len, mbstate_t *ps)
-     _GL_ARG_NONNULL ((2));
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef wcsnrtombs
+#   define wcsnrtombs rpl_wcsnrtombs
+#  endif
+_GL_FUNCDECL_RPL (wcsnrtombs, size_t,
+                  (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
+                   mbstate_t *ps)
+                  _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (wcsnrtombs, size_t,
+                  (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
+                   mbstate_t *ps));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (wcsnrtombs, size_t,
+                  (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
+                   mbstate_t *ps)
+                  _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (wcsnrtombs, size_t,
+                  (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
+                   mbstate_t *ps));
 # endif
+_GL_CXXALIASWARN (wcsnrtombs);
 #elif defined GNULIB_POSIXCHECK
 # undef wcsnrtombs
 # if HAVE_RAW_DECL_WCSNRTOMBS
@@ -292,15 +396,20 @@ _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
 /* Return the number of screen columns needed for WC.  */
 #if @GNULIB_WCWIDTH@
 # if @REPLACE_WCWIDTH@
-#  undef wcwidth
-#  define wcwidth rpl_wcwidth
-extern int wcwidth (wchar_t);
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef wcwidth
+#   define wcwidth rpl_wcwidth
+#  endif
+_GL_FUNCDECL_RPL (wcwidth, int, (wchar_t));
+_GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
 # else
 #  if !defined wcwidth && address@hidden@
 /* wcwidth exists but is not declared.  */
-extern int wcwidth (int /* actually wchar_t */);
+_GL_FUNCDECL_SYS (wcwidth, int, (wchar_t));
 #  endif
+_GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
 # endif
+_GL_CXXALIASWARN (wcwidth);
 #elif defined GNULIB_POSIXCHECK
 # undef wcwidth
 # if HAVE_RAW_DECL_WCWIDTH
@@ -310,10 +419,6 @@ _GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
 #endif
 
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif /* _GL_WCHAR_H */
 #endif /* _GL_WCHAR_H */
 #endif
diff --git a/lib/glm4/gnulib-common.m4 b/lib/glm4/gnulib-common.m4
index b7812a8..80ba263 100644
--- a/lib/glm4/gnulib-common.m4
+++ b/lib/glm4/gnulib-common.m4
@@ -1,4 +1,4 @@
-# gnulib-common.m4 serial 12
+# gnulib-common.m4 serial 13
 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -61,9 +61,16 @@ m4_ifndef([AS_VAR_IF],
 [AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])])
 
 # AC_PROG_MKDIR_P
-# is a backport of autoconf-2.60's AC_PROG_MKDIR_P.
-# Remove this macro when we can assume autoconf >= 2.60.
-m4_ifdef([AC_PROG_MKDIR_P], [], [
+# is a backport of autoconf-2.60's AC_PROG_MKDIR_P, with a fix
+# for interoperability with automake-1.9.6 from autoconf-2.62.
+# Remove this macro when we can assume autoconf >= 2.62 or
+# autoconf >= 2.60 && automake >= 1.10.
+m4_ifdef([AC_PROG_MKDIR_P], [
+  dnl For automake-1.9.6 && autoconf < 2.62: Ensure MKDIR_P is AC_SUBSTed.
+  m4_define([AC_PROG_MKDIR_P],
+    m4_defn([AC_PROG_MKDIR_P])[
+    AC_SUBST([MKDIR_P])])], [
+  dnl For autoconf < 2.60: Backport of AC_PROG_MKDIR_P.
   AC_DEFUN_ONCE([AC_PROG_MKDIR_P],
     [AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake
      MKDIR_P='$(mkdir_p)'
diff --git a/lib/glm4/gnulib-comp.m4 b/lib/glm4/gnulib-comp.m4
index bb56f12..96f8d58 100644
--- a/lib/glm4/gnulib-comp.m4
+++ b/lib/glm4/gnulib-comp.m4
@@ -25,6 +25,16 @@ AC_DEFUN([lgl_EARLY],
   m4_pattern_allow([^gl_LIBOBJS$])dnl a variable
   m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable
   AC_REQUIRE([AC_PROG_RANLIB])
+  # Code from module arg-nonnull:
+  # Code from module c++defs:
+  # Code from module include_next:
+  # Code from module lib-symbol-versions:
+  # Code from module lib-symbol-visibility:
+  # Code from module multiarch:
+  # Code from module stddef:
+  # Code from module stdint:
+  # Code from module warn-on-use:
+  # Code from module wchar:
 ])
 
 # This macro should be invoked from ./configure.ac, in the section
@@ -40,12 +50,24 @@ AC_DEFUN([lgl_INIT],
   m4_pushdef([lgl_LIBSOURCES_DIR], [])
   gl_COMMON
   gl_source_base='lib/gllib'
+  # Code from module arg-nonnull:
+  # Code from module c++defs:
+  # Code from module include_next:
+  # Code from module lib-symbol-versions:
   gl_LD_VERSION_SCRIPT
+  # Code from module lib-symbol-visibility:
   gl_VISIBILITY
+  # Code from module multiarch:
   gl_MULTIARCH
+  # Code from module stddef:
   gl_STDDEF_H
+  # Code from module stdint:
   gl_STDINT_H
+  # Code from module warn-on-use:
+  # Code from module wchar:
   gl_WCHAR_H
+  # Code from module dummy:
+  # End of code from modules
   m4_ifval(lgl_LIBSOURCES_LIST, [
     m4_syscmd([test ! -d ]m4_defn([lgl_LIBSOURCES_DIR])[ ||
       for gl_file in ]lgl_LIBSOURCES_LIST[ ; do
@@ -175,6 +197,7 @@ AC_DEFUN([lgltests_LIBSOURCES], [
 # gnulib-tool and may be removed by future gnulib-tool invocations.
 AC_DEFUN([lgl_FILE_LIST], [
   build-aux/arg-nonnull.h
+  build-aux/c++defs.h
   build-aux/warn-on-use.h
   lib/dummy.c
   lib/stddef.in.h
@@ -190,7 +213,7 @@ AC_DEFUN([lgl_FILE_LIST], [
   m4/stdint.m4
   m4/visibility.m4
   m4/warn-on-use.m4
-  m4/wchar.m4
+  m4/wchar_h.m4
   m4/wchar_t.m4
   m4/wint_t.m4
 ])
diff --git a/lib/glm4/warn-on-use.m4 b/lib/glm4/warn-on-use.m4
index ab46422..42daae8 100644
--- a/lib/glm4/warn-on-use.m4
+++ b/lib/glm4/warn-on-use.m4
@@ -1,4 +1,4 @@
-# warn-on-use.m4 serial 1
+# warn-on-use.m4 serial 2
 dnl Copyright (C) 2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -30,12 +30,12 @@ AC_DEFUN([gl_WARN_ON_USE_PREPARE],
   for gl_func in m4_flatten([$2]); do
     AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl
     AC_CACHE_CHECK([whether $gl_func is declared without a macro],
-      [gl_Symbol],
+      gl_Symbol,
       [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1],
 address@hidden:@undef $gl_func
   (void) $gl_func;])],
-        [AS_VAR_SET([gl_Symbol], [yes])], [AS_VAR_SET([gl_Symbol], [no])])])
-     AS_VAR_IF([gl_Symbol], [yes],
+        [AS_VAR_SET(gl_Symbol, [yes])], [AS_VAR_SET(gl_Symbol, [no])])])
+     AS_VAR_IF(gl_Symbol, [yes],
        [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1])
        dnl shortcut - if the raw declaration exists, then set a cache
        dnl variable to allow skipping any later AC_CHECK_DECL efforts
diff --git a/gl/m4/wchar.m4 b/lib/glm4/wchar_h.m4
similarity index 97%
rename from gl/m4/wchar.m4
rename to lib/glm4/wchar_h.m4
index e81485d..0bce51c 100644
--- a/gl/m4/wchar.m4
+++ b/lib/glm4/wchar_h.m4
@@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is 
preserved.
 
 dnl Written by Eric Blake.
 
-# wchar.m4 serial 31
+# wchar_h.m4 serial 32
 
 AC_DEFUN([gl_WCHAR_H],
 [
@@ -108,6 +108,8 @@ AC_DEFUN([gl_WCHAR_MODULE_INDICATOR],
   dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
   AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
   
GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+  dnl Define it also as a C macro, for the benefit of the unit tests.
+  gl_MODULE_INDICATOR([$1])
 ])
 
 AC_DEFUN([gl_WCHAR_H_DEFAULTS],


hooks/post-receive
-- 
GNU libtasn1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]