OK, fine. Can I get a new testdir, please? -----Original Message----- From: Bruno Haible [mailto:br...@clisp.org] Sent: Monday, December 27, 2010 1:32 AM To: Joachim Schmitz Cc: bug-gnulib@gnu.org Subject: Re: socket functions on HP-NonStop
Joachim Schmitz wrote: > This seems to be indeed new and due to the new "#include <netdb.h>" > which doesn't agree with gnulib's arpa/inet.h > > source='test-getaddrinfo.c' object='test-getaddrinfo.o' libtool=no > DEPDIR=.deps depmode=none /bin/sh ./../build-aux/depcomp cc -DHAVE_CONFIG_H > -I. -DGNULIB_STRICT_CHECKING=1 -I. -I. -I.. -I./.. -I../gllib > -I./../gllib -I/usr/local/include -g -c -o test-getaddrinfo.o > test-getaddrinfo.c ... > extern const char *inet_ntop (int af, const void *restrict src, > ^ > "/usr/local/Floss/gnulib/testdir-posix/gltests/./../gllib/arpa/inet.h", line > 129: error(235): > declaration is incompatible with > "const char *inet_ntop(int, const void *, char *, size_t)" (declared > at line 421 of "/usr/include/netdb.h") ... > Same error in several tests. I see. So what gnulib needs to do here is 1) Include <netdb.h> in the arpa/inet.h replacement, so that NonStop Kernel's declaration becomes visible. 2) For C++ support with a POSIX compliant prototype (C++ has stricter type checking than C), use the c++defs.h idioms, with a _GL_CXXALIAS_SYS_CAST invocation instead of _GL_CXXALIAS_SYS. I'm applying these three patches: 2010-12-26 Bruno Haible <br...@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. --- lib/arpa_inet.in.h.orig Sun Dec 26 20:25:51 2010 +++ lib/arpa_inet.in.h Sun Dec 26 19:33:21 2010 @@ -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 */ --- modules/arpa_inet.orig Sun Dec 26 20:25:51 2010 +++ modules/arpa_inet Sun Dec 26 19:39:47 2010 @@ -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; \ --- modules/arpa_inet-tests.orig Sun Dec 26 20:25:51 2010 +++ modules/arpa_inet-tests Sun Dec 26 19:40:12 2010 @@ -2,6 +2,7 @@ tests/test-arpa_inet.c Depends-on: +arpa_inet-c++-tests configure.ac: ========================= modules/arpa_inet-c++-tests ========================= 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 ========================= tests/test-arpa_inet-c++.cc ========================= /* 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 <br...@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 () { } =============================================================================== 2010-12-26 Bruno Haible <br...@clisp.org> inet_ntop, inet_pton: Ensure declaration on NonStop Kernel. * lib/arpa_inet.in.h: On NonStop Kernel, include also <netdb.h>. * m4/arpa_inet_h.m4 (gl_HEADER_ARPA_INET): Likewise. * m4/inet_ntop.m4 (gl_PREREQ_INET_NTOP): Include also <netdb.h> when looking for the declaration. * m4/inet_pton.m4 (gl_PREREQ_INET_PTON): Likewise. * doc/posix-functions/inet_ntop.texi: Document the NonStop Kernel problem. * doc/posix-functions/inet_pton.texi: Likewise. --- doc/posix-functions/inet_ntop.texi.orig Mon Dec 27 01:18:08 2010 +++ doc/posix-functions/inet_ntop.texi Mon Dec 27 01:14:36 2010 @@ -11,6 +11,10 @@ @item This function is missing on some platforms: HP-UX 11.00, OSF/1 4.0, Solaris 2.5.1, mingw, Interix 3.5, BeOS. +...@item +This function is declared in @code{<netdb.h>} instead of +...@code{<arpa/inet.h>} on some platforms: +NonStop Kernel. @end itemize Portability problems not fixed by Gnulib: --- doc/posix-functions/inet_pton.texi.orig Mon Dec 27 01:18:08 2010 +++ doc/posix-functions/inet_pton.texi Mon Dec 27 01:14:36 2010 @@ -11,6 +11,10 @@ @item This function is missing on some platforms: HP-UX 11.00, OSF/1 4.0, Solaris 2.5.1, mingw, Interix 3.5, BeOS. +...@item +This function is declared in @code{<netdb.h>} instead of +...@code{<arpa/inet.h>} on some platforms: +NonStop Kernel. @end itemize Portability problems not fixed by Gnulib: --- lib/arpa_inet.in.h.orig Mon Dec 27 01:18:08 2010 +++ lib/arpa_inet.in.h Mon Dec 27 00:01:48 2010 @@ -34,6 +34,12 @@ # include <sys/socket.h> #endif +/* On NonStop Kernel, inet_ntop and inet_pton are declared in <netdb.h>. + But avoid namespace pollution on glibc systems. */ #if defined +__TANDEM && !defined __GLIBC__ # include <netdb.h> #endif + #if @HAVE_ARPA_INET_H@ /* The include_next requires a split double-inclusion guard. */ --- m4/arpa_inet_h.m4.orig Mon Dec 27 01:18:09 2010 +++ m4/arpa_inet_h.m4 Mon Dec 27 01:18:05 2010 @@ -1,4 +1,4 @@ -# arpa_inet_h.m4 serial 10 +# arpa_inet_h.m4 serial 11 dnl Copyright (C) 2006, 2008-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, @@ -31,6 +31,9 @@ #if !(defined __GLIBC__ || defined __UCLIBC__) # include <sys/socket.h> #endif +#ifdef __TANDEM +# include <netdb.h> +#endif #include <arpa/inet.h> ]], [inet_ntop inet_pton]) ]) --- m4/inet_ntop.m4.orig Mon Dec 27 01:18:09 2010 +++ m4/inet_ntop.m4 Mon Dec 27 01:11:46 2010 @@ -1,4 +1,4 @@ -# inet_ntop.m4 serial 12 +# inet_ntop.m4 serial 13 dnl Copyright (C) 2005, 2006, 2008, 2009, 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, @@ -29,7 +29,13 @@ # Prerequisites of lib/inet_ntop.c. AC_DEFUN([gl_PREREQ_INET_NTOP], [ - AC_CHECK_DECLS([inet_ntop],,,[#include <arpa/inet.h>]) + AC_CHECK_HEADERS_ONCE([netdb.h]) + AC_CHECK_DECLS([inet_ntop],,, + [#include <arpa/inet.h> + #if HAVE_NETDB_H + # include <netdb.h> + #endif + ]) if test $ac_cv_have_decl_inet_ntop = no; then HAVE_DECL_INET_NTOP=0 fi --- m4/inet_pton.m4.orig Mon Dec 27 01:18:09 2010 +++ m4/inet_pton.m4 Mon Dec 27 01:12:25 2010 @@ -1,4 +1,4 @@ -# inet_pton.m4 serial 10 +# inet_pton.m4 serial 11 dnl Copyright (C) 2006, 2008, 2009, 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, @@ -29,7 +29,13 @@ # Prerequisites of lib/inet_pton.c. AC_DEFUN([gl_PREREQ_INET_PTON], [ - AC_CHECK_DECLS([inet_pton],,,[#include <arpa/inet.h>]) + AC_CHECK_HEADERS_ONCE([netdb.h]) + AC_CHECK_DECLS([inet_pton],,, + [#include <arpa/inet.h> + #if HAVE_NETDB_H + # include <netdb.h> + #endif + ]) if test $ac_cv_have_decl_inet_pton = no; then HAVE_DECL_INET_PTON=0 fi 2010-12-26 Bruno Haible <br...@clisp.org> inet_ntop: Hide mismatch of declaration on NonStop Kernel. * lib/arpa_inet.in.h (inet_ntop): Use _GL_CXXALIAS_SYS_CAST instead of _GL_CXXALIAS_SYS. Reported by Joachim Schmitz <j...@schmitz-digital.de>. --- lib/arpa_inet.in.h.orig Mon Dec 27 01:24:52 2010 +++ lib/arpa_inet.in.h Mon Dec 27 01:24:41 2010 @@ -79,9 +79,11 @@ 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)); +/* Need to cast, because on NonStop Kernel, the fourth parameter is + size_t cnt. */ +_GL_CXXALIAS_SYS_CAST (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