Mercurial > hg > octave-jordi > gnulib-hg
changeset 14036:c475f1b6d204
arpa_inet: Use the common idioms with C++ support.
* lib/arpa_inet.in.h: Include c++defs.h.
(inet_ntop, inet_pton): Declare using the macros with C++ namespace
support.
* modules/arpa_inet (Depends-on): Add c++defs.
(Makefile.am): Substitute the contents of c++defs.h.
* modules/arpa_inet-tests (Depends-on): Add arpa_inet-c++-tests.
* modules/arpa_inet-c++-tests: New file.
* tests/test-arpa_inet-c++.cc: New file.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 26 Dec 2010 23:56:33 +0100 |
parents | 1cdd9ed93c4e |
children | 3f2c77c8adb8 |
files | ChangeLog lib/arpa_inet.in.h modules/arpa_inet modules/arpa_inet-c++-tests modules/arpa_inet-tests tests/test-arpa_inet-c++.cc |
diffstat | 6 files changed, 92 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2010-12-26 Bruno Haible <bruno@clisp.org> + + arpa_inet: Use the common idioms with C++ support. + * lib/arpa_inet.in.h: Include c++defs.h. + (inet_ntop, inet_pton): Declare using the macros with C++ namespace + support. + * modules/arpa_inet (Depends-on): Add c++defs. + (Makefile.am): Substitute the contents of c++defs.h. + * modules/arpa_inet-tests (Depends-on): Add arpa_inet-c++-tests. + * modules/arpa_inet-c++-tests: New file. + * tests/test-arpa_inet-c++.cc: New file. + 2010-12-25 Bruno Haible <bruno@clisp.org> Fix more C++ link errors on Solaris 8.
--- a/lib/arpa_inet.in.h +++ b/lib/arpa_inet.in.h @@ -44,13 +44,12 @@ #ifndef _GL_ARPA_INET_H #define _GL_ARPA_INET_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 #if @GNULIB_INET_NTOP@ # if !@HAVE_DECL_INET_NTOP@ @@ -69,10 +68,15 @@ For more details, see the POSIX:2001 specification <http://www.opengroup.org/susv3xsh/inet_ntop.html>. */ -extern const char *inet_ntop (int af, const void *restrict src, - char *restrict dst, socklen_t cnt) - _GL_ARG_NONNULL ((2, 3)); +_GL_FUNCDECL_SYS (inet_ntop, const char *, + (int af, const void *restrict src, + char *restrict dst, socklen_t cnt) + _GL_ARG_NONNULL ((2, 3))); # endif +_GL_CXXALIAS_SYS (inet_ntop, const char *, + (int af, const void *restrict src, + char *restrict dst, socklen_t cnt)); +_GL_CXXALIASWARN (inet_ntop); #elif defined GNULIB_POSIXCHECK # undef inet_ntop # if HAVE_RAW_DECL_INET_NTOP @@ -83,9 +87,13 @@ #if @GNULIB_INET_PTON@ # if !@HAVE_DECL_INET_PTON@ -extern int inet_pton (int af, const char *restrict src, void *restrict dst) - _GL_ARG_NONNULL ((2, 3)); +_GL_FUNCDECL_SYS (inet_pton, int, + (int af, const char *restrict src, void *restrict dst) + _GL_ARG_NONNULL ((2, 3))); # endif +_GL_CXXALIAS_SYS (inet_pton, int, + (int af, const char *restrict src, void *restrict dst)); +_GL_CXXALIASWARN (inet_pton); #elif defined GNULIB_POSIXCHECK # undef inet_pton # if HAVE_RAW_DECL_INET_PTON @@ -94,9 +102,6 @@ # endif #endif -#ifdef __cplusplus -} -#endif #endif /* _GL_ARPA_INET_H */ #endif /* _GL_ARPA_INET_H */
--- a/modules/arpa_inet +++ b/modules/arpa_inet @@ -7,6 +7,7 @@ Depends-on: arg-nonnull +c++defs include_next sys_socket warn-on-use @@ -20,7 +21,7 @@ # We need the following in order to create <arpa/inet.h> when the system # doesn't have one. -arpa/inet.h: arpa_inet.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H) +arpa/inet.h: arpa_inet.in.h $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H) $(AM_V_at)$(MKDIR_P) arpa $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ @@ -34,6 +35,7 @@ -e 's|@''GNULIB_INET_PTON''@|$(GNULIB_INET_PTON)|g' \ -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \ -e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|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)/arpa_inet.in.h; \
new file mode 100644 --- /dev/null +++ b/modules/arpa_inet-c++-tests @@ -0,0 +1,19 @@ +Files: +tests/test-arpa_inet-c++.cc +tests/signature.h + +Status: +c++-test + +Depends-on: +ansi-c++-opt + +configure.ac: + +Makefile.am: +if ANSICXX +TESTS += test-arpa_inet-c++ +check_PROGRAMS += test-arpa_inet-c++ +test_arpa_inet_c___SOURCES = test-arpa_inet-c++.cc +test_arpa_inet_c___LDADD = $(LDADD) $(INET_NTOP_LIB) $(INET_PTON_LIB) $(LIBSOCKET) +endif
--- a/modules/arpa_inet-tests +++ b/modules/arpa_inet-tests @@ -2,6 +2,7 @@ tests/test-arpa_inet.c Depends-on: +arpa_inet-c++-tests configure.ac:
new file mode 100644 --- /dev/null +++ b/tests/test-arpa_inet-c++.cc @@ -0,0 +1,41 @@ +/* Test of <arpa/inet.h> substitute in C++ mode. + 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 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/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2010. */ + +#define GNULIB_NAMESPACE gnulib +#include <config.h> + +#include <arpa/inet.h> + +#include "signature.h" + + +#if GNULIB_TEST_INET_NTOP +SIGNATURE_CHECK (GNULIB_NAMESPACE::inet_ntop, const char *, + (int, const void *, char *, socklen_t)); +#endif + +#if GNULIB_TEST_INET_PTON +SIGNATURE_CHECK (GNULIB_NAMESPACE::inet_pton, int, + (int, const char *, void *)); +#endif + + +int +main () +{ +}