# HG changeset patch # User Bruno Haible # Date 1517047079 -3600 # Node ID 05af34a750412397b465e42d81c7174285536a2e # Parent 9626419f9db35d94bb6177469da17e765a9fa3f3 Fix malfunction of socket functions on HP-UX in 64-bit mode. * m4/socketlib.m4 (gl_SOCKETLIB): Add comment. * m4/extensions.m4 (AC_USE_SYSTEM_EXTENSIONS): Define _HPUX_ALT_XOPEN_SOCKET_API. * modules/accept (Depends-on): Add 'extensions'. * modules/getpeername (Depends-on): Likewise. * modules/getsockname (Depends-on): Likewise. * modules/getsockopt (Depends-on): Likewise. * modules/recvfrom (Depends-on): Likewise. * doc/posix-functions/accept.texi: Mention the HP-UX socklen_t problem. * doc/posix-functions/getpeername.texi: Likewise. * doc/posix-functions/getsockname.texi: Likewise. * doc/posix-functions/getsockopt.texi: Likewise. * doc/posix-functions/recvfrom.texi: Likewise. diff -r 9626419f9db3 -r 05af34a75041 ChangeLog --- a/ChangeLog Sat Jan 27 08:52:31 2018 +0100 +++ b/ChangeLog Sat Jan 27 10:57:59 2018 +0100 @@ -1,3 +1,20 @@ +2018-01-27 Bruno Haible + + Fix malfunction of socket functions on HP-UX in 64-bit mode. + * m4/socketlib.m4 (gl_SOCKETLIB): Add comment. + * m4/extensions.m4 (AC_USE_SYSTEM_EXTENSIONS): Define + _HPUX_ALT_XOPEN_SOCKET_API. + * modules/accept (Depends-on): Add 'extensions'. + * modules/getpeername (Depends-on): Likewise. + * modules/getsockname (Depends-on): Likewise. + * modules/getsockopt (Depends-on): Likewise. + * modules/recvfrom (Depends-on): Likewise. + * doc/posix-functions/accept.texi: Mention the HP-UX socklen_t problem. + * doc/posix-functions/getpeername.texi: Likewise. + * doc/posix-functions/getsockname.texi: Likewise. + * doc/posix-functions/getsockopt.texi: Likewise. + * doc/posix-functions/recvfrom.texi: Likewise. + 2018-01-27 Bruno Haible getsockname tests: More tests. diff -r 9626419f9db3 -r 05af34a75041 doc/posix-functions/accept.texi --- a/doc/posix-functions/accept.texi Sat Jan 27 08:52:31 2018 +0100 +++ b/doc/posix-functions/accept.texi Sat Jan 27 10:57:59 2018 +0100 @@ -17,6 +17,11 @@ On Windows platforms (excluding Cygwin), error codes from this function are not placed in @code{errno}, and @code{WSAGetLastError} must be used instead. +@item +On HP-UX 11, in 64-bit mode, when the macro @code{_HPUX_ALT_XOPEN_SOCKET_API} +is not defined, this function behaves incorrectly because it is declared +to take a pointer to a 64-bit wide @code{socklen_t} entity but in fact +considers it as a pointer to a 32-bit wide @code{unsigned int} entity. @end itemize Portability problems not fixed by Gnulib: diff -r 9626419f9db3 -r 05af34a75041 doc/posix-functions/getpeername.texi --- a/doc/posix-functions/getpeername.texi Sat Jan 27 08:52:31 2018 +0100 +++ b/doc/posix-functions/getpeername.texi Sat Jan 27 10:57:59 2018 +0100 @@ -12,6 +12,11 @@ On Windows platforms (excluding Cygwin), error codes from this function are not placed in @code{errno}, and @code{WSAGetLastError} must be used instead. +@item +On HP-UX 11, in 64-bit mode, when the macro @code{_HPUX_ALT_XOPEN_SOCKET_API} +is not defined, this function behaves incorrectly because it is declared +to take a pointer to a 64-bit wide @code{socklen_t} entity but in fact +considers it as a pointer to a 32-bit wide @code{unsigned int} entity. @end itemize Portability problems not fixed by Gnulib: diff -r 9626419f9db3 -r 05af34a75041 doc/posix-functions/getsockname.texi --- a/doc/posix-functions/getsockname.texi Sat Jan 27 08:52:31 2018 +0100 +++ b/doc/posix-functions/getsockname.texi Sat Jan 27 10:57:59 2018 +0100 @@ -12,6 +12,11 @@ On Windows platforms (excluding Cygwin), error codes from this function are not placed in @code{errno}, and @code{WSAGetLastError} must be used instead. +@item +On HP-UX 11, in 64-bit mode, when the macro @code{_HPUX_ALT_XOPEN_SOCKET_API} +is not defined, this function behaves incorrectly because it is declared +to take a pointer to a 64-bit wide @code{socklen_t} entity but in fact +considers it as a pointer to a 32-bit wide @code{unsigned int} entity. @end itemize Portability problems not fixed by Gnulib: diff -r 9626419f9db3 -r 05af34a75041 doc/posix-functions/getsockopt.texi --- a/doc/posix-functions/getsockopt.texi Sat Jan 27 08:52:31 2018 +0100 +++ b/doc/posix-functions/getsockopt.texi Sat Jan 27 10:57:59 2018 +0100 @@ -12,6 +12,11 @@ On Windows platforms (excluding Cygwin), error codes from this function are not placed in @code{errno}, and @code{WSAGetLastError} must be used instead. +@item +On HP-UX 11, in 64-bit mode, when the macro @code{_HPUX_ALT_XOPEN_SOCKET_API} +is not defined, this function behaves incorrectly because it is declared +to take a pointer to a 64-bit wide @code{socklen_t} entity but in fact +considers it as a pointer to a 32-bit wide @code{unsigned int} entity. @end itemize Portability problems not fixed by Gnulib: diff -r 9626419f9db3 -r 05af34a75041 doc/posix-functions/recvfrom.texi --- a/doc/posix-functions/recvfrom.texi Sat Jan 27 08:52:31 2018 +0100 +++ b/doc/posix-functions/recvfrom.texi Sat Jan 27 10:57:59 2018 +0100 @@ -16,6 +16,11 @@ On Windows platforms (excluding Cygwin), error codes from this function are not placed in @code{errno}, and @code{WSAGetLastError} must be used instead. +@item +On HP-UX 11, in 64-bit mode, when the macro @code{_HPUX_ALT_XOPEN_SOCKET_API} +is not defined, this function behaves incorrectly because it is declared +to take a pointer to a 64-bit wide @code{socklen_t} entity but in fact +considers it as a pointer to a 32-bit wide @code{unsigned int} entity. @end itemize Portability problems not fixed by Gnulib: diff -r 9626419f9db3 -r 05af34a75041 m4/extensions.m4 --- a/m4/extensions.m4 Sat Jan 27 08:52:31 2018 +0100 +++ b/m4/extensions.m4 Sat Jan 27 10:57:59 2018 +0100 @@ -1,4 +1,4 @@ -# serial 17 -*- Autoconf -*- +# serial 18 -*- Autoconf -*- # Enable extensions on systems that normally disable them. # Copyright (C) 2003, 2006-2018 Free Software Foundation, Inc. @@ -118,6 +118,11 @@ #ifndef _XOPEN_SOURCE # undef _XOPEN_SOURCE #endif +/* Enable X/Open compliant socket functions that do not require linking + with -lxnet on HP-UX 11.11. */ +#ifndef _HPUX_ALT_XOPEN_SOCKET_API +# undef _HPUX_ALT_XOPEN_SOCKET_API +#endif /* Enable general extensions on Solaris. */ #ifndef __EXTENSIONS__ # undef __EXTENSIONS__ @@ -163,6 +168,7 @@ [ac_cv_should_define__xopen_source=yes])])]) test $ac_cv_should_define__xopen_source = yes && AC_DEFINE([_XOPEN_SOURCE], [500]) + AC_DEFINE([_HPUX_ALT_XOPEN_SOCKET_API]) ])# AC_USE_SYSTEM_EXTENSIONS # gl_USE_SYSTEM_EXTENSIONS diff -r 9626419f9db3 -r 05af34a75041 m4/socketlib.m4 --- a/m4/socketlib.m4 Sat Jan 27 08:52:31 2018 +0100 +++ b/m4/socketlib.m4 Sat Jan 27 10:57:59 2018 +0100 @@ -1,4 +1,4 @@ -# socketlib.m4 serial 1 +# socketlib.m4 serial 2 dnl Copyright (C) 2008-2018 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -38,6 +38,10 @@ dnl Solaris has most socket functions in libsocket. dnl Haiku has most socket functions in libnetwork. dnl BeOS has most socket functions in libnet. + dnl On HP-UX, do NOT link with libxnet, because in 64-bit mode this would + dnl break code (e.g. in libraries) that invokes accept(), getpeername(), + dnl getsockname(), getsockopt(), or recvfrom() with a 32-bit addrlen. See + dnl "man xopen_networking" for details. AC_CACHE_CHECK([for library containing setsockopt], [gl_cv_lib_socket], [ gl_cv_lib_socket= AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern diff -r 9626419f9db3 -r 05af34a75041 modules/accept --- a/modules/accept Sat Jan 27 08:52:31 2018 +0100 +++ b/modules/accept Sat Jan 27 10:57:59 2018 +0100 @@ -6,6 +6,7 @@ lib/w32sock.h Depends-on: +extensions sys_socket socketlib errno [test "$ac_cv_header_winsock2_h" = yes] diff -r 9626419f9db3 -r 05af34a75041 modules/getpeername --- a/modules/getpeername Sat Jan 27 08:52:31 2018 +0100 +++ b/modules/getpeername Sat Jan 27 10:57:59 2018 +0100 @@ -7,6 +7,7 @@ lib/w32sock.h Depends-on: +extensions sys_socket socketlib errno [test "$ac_cv_header_winsock2_h" = yes] diff -r 9626419f9db3 -r 05af34a75041 modules/getsockname --- a/modules/getsockname Sat Jan 27 08:52:31 2018 +0100 +++ b/modules/getsockname Sat Jan 27 10:57:59 2018 +0100 @@ -7,6 +7,7 @@ lib/w32sock.h Depends-on: +extensions sys_socket socketlib errno [test "$ac_cv_header_winsock2_h" = yes] diff -r 9626419f9db3 -r 05af34a75041 modules/getsockopt --- a/modules/getsockopt Sat Jan 27 08:52:31 2018 +0100 +++ b/modules/getsockopt Sat Jan 27 10:57:59 2018 +0100 @@ -6,6 +6,7 @@ lib/w32sock.h Depends-on: +extensions sys_socket socketlib sys_time [test "$ac_cv_header_winsock2_h" = yes] diff -r 9626419f9db3 -r 05af34a75041 modules/recvfrom --- a/modules/recvfrom Sat Jan 27 08:52:31 2018 +0100 +++ b/modules/recvfrom Sat Jan 27 10:57:59 2018 +0100 @@ -6,6 +6,7 @@ lib/w32sock.h Depends-on: +extensions sys_socket socketlib errno [test "$ac_cv_header_winsock2_h" = yes]