From ed4ce96d94a37ea75eb39d6a05b79f0b334cd2d0 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 26 Dec 2010 23:56:33 +0100 Subject: [PATCH] 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. --- ChangeLog | 12 ++++++++++++ lib/arpa_inet.in.h | 27 ++++++++++++++++----------- modules/arpa_inet | 4 +++- modules/arpa_inet-c++-tests | 19 +++++++++++++++++++ modules/arpa_inet-tests | 1 + tests/test-arpa_inet-c++.cc | 41 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 92 insertions(+), 12 deletions(-) create mode 100644 modules/arpa_inet-c++-tests create mode 100644 tests/test-arpa_inet-c++.cc diff --git a/ChangeLog b/ChangeLog index 300eccbf8..4a76cc8f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2010-12-26 Bruno Haible + + 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 Fix more C++ link errors on Solaris 8. diff --git a/lib/arpa_inet.in.h b/lib/arpa_inet.in.h index fbf084252..cfbd97791 100644 --- 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 @@ extern "C" { For more details, see the POSIX:2001 specification . */ -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 @@ _GL_WARN_ON_USE (inet_ntop, "inet_ntop is unportable - " #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 @@ _GL_WARN_ON_USE (inet_pton, "inet_pton is unportable - " # endif #endif -#ifdef __cplusplus -} -#endif #endif /* _GL_ARPA_INET_H */ #endif /* _GL_ARPA_INET_H */ diff --git a/modules/arpa_inet b/modules/arpa_inet index cec5d6c85..34b988161 100644 --- a/modules/arpa_inet +++ b/modules/arpa_inet @@ -7,6 +7,7 @@ m4/arpa_inet_h.m4 Depends-on: arg-nonnull +c++defs include_next sys_socket warn-on-use @@ -20,7 +21,7 @@ BUILT_SOURCES += arpa/inet.h # We need the following in order to create 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 @@ arpa/inet.h: arpa_inet.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H) -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; \ diff --git a/modules/arpa_inet-c++-tests b/modules/arpa_inet-c++-tests new file mode 100644 index 000000000..5d2017045 --- /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 diff --git a/modules/arpa_inet-tests b/modules/arpa_inet-tests index 8c31fdeb2..d6706f93c 100644 --- a/modules/arpa_inet-tests +++ b/modules/arpa_inet-tests @@ -2,6 +2,7 @@ Files: tests/test-arpa_inet.c Depends-on: +arpa_inet-c++-tests configure.ac: diff --git a/tests/test-arpa_inet-c++.cc b/tests/test-arpa_inet-c++.cc new file mode 100644 index 000000000..da08e4803 --- /dev/null +++ b/tests/test-arpa_inet-c++.cc @@ -0,0 +1,41 @@ +/* Test of 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 . */ + +/* Written by Bruno Haible , 2010. */ + +#define GNULIB_NAMESPACE gnulib +#include + +#include + +#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 () +{ +} -- 2.11.0