Commit 187fdaea by Jonathan Wakely Committed by Jonathan Wakely

PR libstdc++/89460 Fix Networking TS test failures on HP-UX

Check for availability of POSIX sockatmark before using it.

Rename _S_ntoh overloads that are ambiguous when passed an integral type
that is neither uint16_t nor uint32_t.

	PR libstdc++/89460
	* configure.ac: Check for sockatmark.
	* crossconfig.m4: Check for sockatmark.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* include/experimental/internet (address_v4::_S_hton): Rename
	overloaded functions to _S_hton_16 and _S_ntoh_16.
	(address_v4::_S_ntoh): Rename to _S_ntoh_16 and _S_ntoh_32.
	(basic_endpoint): Adjust calls to _S_hton and _S_ntoh.
	* include/experimental/socket (basic_socket::at_mark): Check
	_GLIBCXX_HAVE_SOCKATMARK.

From-SVN: r269588
parent 93964ebd
2019-03-11 Jonathan Wakely <jwakely@redhat.com> 2019-03-11 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/89460
* configure.ac: Check for sockatmark.
* crossconfig.m4: Check for sockatmark.
* config.h.in: Regenerate.
* configure: Regenerate.
* include/experimental/internet (address_v4::_S_hton): Rename
overloaded functions to _S_hton_16 and _S_ntoh_16.
(address_v4::_S_ntoh): Rename to _S_ntoh_16 and _S_ntoh_32.
(basic_endpoint): Adjust calls to _S_hton and _S_ntoh.
* include/experimental/socket (basic_socket::at_mark): Check
_GLIBCXX_HAVE_SOCKATMARK.
* testsuite/29_atomics/atomic_flag/test_and_set/explicit-hle.cc: Use * testsuite/29_atomics/atomic_flag/test_and_set/explicit-hle.cc: Use
const variables instead of macros. const variables instead of macros.
......
...@@ -390,6 +390,9 @@ ...@@ -390,6 +390,9 @@
/* Defined if sleep exists. */ /* Defined if sleep exists. */
#undef HAVE_SLEEP #undef HAVE_SLEEP
/* Define to 1 if you have the `sockatmark' function. */
#undef HAVE_SOCKATMARK
/* Define to 1 if you have the `sqrtf' function. */ /* Define to 1 if you have the `sqrtf' function. */
#undef HAVE_SQRTF #undef HAVE_SQRTF
......
...@@ -28446,6 +28446,19 @@ fi ...@@ -28446,6 +28446,19 @@ fi
done done
# For Networking TS.
for ac_func in sockatmark
do :
ac_fn_c_check_func "$LINENO" "sockatmark" "ac_cv_func_sockatmark"
if test "x$ac_cv_func_sockatmark" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SOCKATMARK 1
_ACEOF
fi
done
# For iconv support. # For iconv support.
if test "X$prefix" = "XNONE"; then if test "X$prefix" = "XNONE"; then
...@@ -53641,6 +53654,17 @@ _ACEOF ...@@ -53641,6 +53654,17 @@ _ACEOF
fi fi
done done
for ac_func in sockatmark
do :
ac_fn_c_check_func "$LINENO" "sockatmark" "ac_cv_func_sockatmark"
if test "x$ac_cv_func_sockatmark" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SOCKATMARK 1
_ACEOF
fi
done
;; ;;
*-fuchsia*) *-fuchsia*)
...@@ -60268,6 +60292,17 @@ _ACEOF ...@@ -60268,6 +60292,17 @@ _ACEOF
fi fi
done done
for ac_func in sockatmark
do :
ac_fn_c_check_func "$LINENO" "sockatmark" "ac_cv_func_sockatmark"
if test "x$ac_cv_func_sockatmark" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SOCKATMARK 1
_ACEOF
fi
done
...@@ -66592,6 +66627,17 @@ _ACEOF ...@@ -66592,6 +66627,17 @@ _ACEOF
fi fi
done done
for ac_func in sockatmark
do :
ac_fn_c_check_func "$LINENO" "sockatmark" "ac_cv_func_sockatmark"
if test "x$ac_cv_func_sockatmark" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SOCKATMARK 1
_ACEOF
fi
done
;; ;;
*-qnx6.1* | *-qnx6.2*) *-qnx6.1* | *-qnx6.2*)
SECTION_FLAGS='-ffunction-sections -fdata-sections' SECTION_FLAGS='-ffunction-sections -fdata-sections'
...@@ -268,6 +268,9 @@ if $GLIBCXX_IS_NATIVE; then ...@@ -268,6 +268,9 @@ if $GLIBCXX_IS_NATIVE; then
# C11 functions for C++17 library # C11 functions for C++17 library
AC_CHECK_FUNCS(timespec_get) AC_CHECK_FUNCS(timespec_get)
# For Networking TS.
AC_CHECK_FUNCS(sockatmark)
# For iconv support. # For iconv support.
AM_ICONV AM_ICONV
......
...@@ -136,6 +136,7 @@ case "${host}" in ...@@ -136,6 +136,7 @@ case "${host}" in
AC_CHECK_FUNCS(__cxa_thread_atexit) AC_CHECK_FUNCS(__cxa_thread_atexit)
AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc) AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc)
AC_CHECK_FUNCS(timespec_get) AC_CHECK_FUNCS(timespec_get)
AC_CHECK_FUNCS(sockatmark)
;; ;;
*-fuchsia*) *-fuchsia*)
...@@ -196,6 +197,7 @@ case "${host}" in ...@@ -196,6 +197,7 @@ case "${host}" in
AC_CHECK_FUNCS(__cxa_thread_atexit_impl) AC_CHECK_FUNCS(__cxa_thread_atexit_impl)
AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc) AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc)
AC_CHECK_FUNCS(timespec_get) AC_CHECK_FUNCS(timespec_get)
AC_CHECK_FUNCS(sockatmark)
AM_ICONV AM_ICONV
;; ;;
*-mingw32*) *-mingw32*)
...@@ -224,6 +226,7 @@ case "${host}" in ...@@ -224,6 +226,7 @@ case "${host}" in
fi fi
AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc) AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc)
AC_CHECK_FUNCS(timespec_get) AC_CHECK_FUNCS(timespec_get)
AC_CHECK_FUNCS(sockatmark)
;; ;;
*-qnx6.1* | *-qnx6.2*) *-qnx6.1* | *-qnx6.2*)
SECTION_FLAGS='-ffunction-sections -fdata-sections' SECTION_FLAGS='-ffunction-sections -fdata-sections'
......
...@@ -158,7 +158,7 @@ namespace ip ...@@ -158,7 +158,7 @@ namespace ip
{ } { }
explicit constexpr explicit constexpr
address_v4(uint_type __val) : _M_addr(_S_hton(__val)) address_v4(uint_type __val) : _M_addr(_S_hton_32(__val))
{ {
#if UINT_LEAST32_MAX > 0xFFFFFFFF #if UINT_LEAST32_MAX > 0xFFFFFFFF
if (__val > 0xFFFFFFFF) if (__val > 0xFFFFFFFF)
...@@ -191,7 +191,8 @@ namespace ip ...@@ -191,7 +191,8 @@ namespace ip
}; };
} }
constexpr uint_type to_uint() const noexcept { return _S_ntoh(_M_addr); } constexpr uint_type
to_uint() const noexcept { return _S_ntoh_32(_M_addr); }
#ifdef _GLIBCXX_HAVE_ARPA_INET_H #ifdef _GLIBCXX_HAVE_ARPA_INET_H
template<typename _Allocator = allocator<char>> template<typename _Allocator = allocator<char>>
...@@ -224,22 +225,22 @@ namespace ip ...@@ -224,22 +225,22 @@ namespace ip
friend address_v4 make_address_v4(const char*, error_code&) noexcept; friend address_v4 make_address_v4(const char*, error_code&) noexcept;
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
static constexpr uint16_t _S_hton(uint16_t __h) { return __h; } static constexpr uint16_t _S_hton_16(uint16_t __h) { return __h; }
static constexpr uint16_t _S_ntoh(uint16_t __n) { return __n; } static constexpr uint16_t _S_ntoh_16(uint16_t __n) { return __n; }
static constexpr uint32_t _S_hton(uint32_t __h) { return __h; } static constexpr uint32_t _S_hton_32(uint32_t __h) { return __h; }
static constexpr uint32_t _S_ntoh(uint32_t __n) { return __n; } static constexpr uint32_t _S_ntoh_32(uint32_t __n) { return __n; }
#else #else
static constexpr uint16_t static constexpr uint16_t
_S_hton(uint16_t __h) { return __builtin_bswap16(__h); } _S_hton_16(uint16_t __h) { return __builtin_bswap16(__h); }
static constexpr uint16_t static constexpr uint16_t
_S_ntoh(uint16_t __n) { return __builtin_bswap16(__n); } _S_ntoh_16(uint16_t __n) { return __builtin_bswap16(__n); }
static constexpr uint32_t static constexpr uint32_t
_S_hton(uint32_t __h) { return __builtin_bswap32(__h); } _S_hton_32(uint32_t __h) { return __builtin_bswap32(__h); }
static constexpr uint32_t static constexpr uint32_t
_S_ntoh(uint32_t __n) { return __builtin_bswap32(__n); } _S_ntoh_32(uint32_t __n) { return __builtin_bswap32(__n); }
#endif #endif
in_addr_t _M_addr; // network byte order in_addr_t _M_addr; // network byte order
...@@ -1396,7 +1397,7 @@ namespace ip ...@@ -1396,7 +1397,7 @@ namespace ip
|| __proto == protocol_type::v6()); || __proto == protocol_type::v6());
_M_data._M_v4.sin_family = __proto.family(); _M_data._M_v4.sin_family = __proto.family();
_M_data._M_v4.sin_port = address_v4::_S_hton(__port_num); _M_data._M_v4.sin_port = address_v4::_S_hton_16(__port_num);
} }
constexpr constexpr
...@@ -1407,14 +1408,14 @@ namespace ip ...@@ -1407,14 +1408,14 @@ namespace ip
if (__addr.is_v4()) if (__addr.is_v4())
{ {
_M_data._M_v4.sin_family = protocol_type::v4().family(); _M_data._M_v4.sin_family = protocol_type::v4().family();
_M_data._M_v4.sin_port = address_v4::_S_hton(__port_num); _M_data._M_v4.sin_port = address_v4::_S_hton_16(__port_num);
_M_data._M_v4.sin_addr.s_addr = __addr._M_v4._M_addr; _M_data._M_v4.sin_addr.s_addr = __addr._M_v4._M_addr;
} }
else else
{ {
_M_data._M_v6 = {}; _M_data._M_v6 = {};
_M_data._M_v6.sin6_family = protocol_type::v6().family(); _M_data._M_v6.sin6_family = protocol_type::v6().family();
_M_data._M_v6.sin6_port = address_v4::_S_hton(__port_num); _M_data._M_v6.sin6_port = address_v4::_S_hton_16(__port_num);
__builtin_memcpy(_M_data._M_v6.sin6_addr.s6_addr, __builtin_memcpy(_M_data._M_v6.sin6_addr.s6_addr,
__addr._M_v6._M_bytes.data(), 16); __addr._M_v6._M_bytes.data(), 16);
_M_data._M_v6.sin6_scope_id = __addr._M_v6._M_scope_id; _M_data._M_v6.sin6_scope_id = __addr._M_v6._M_scope_id;
...@@ -1466,11 +1467,11 @@ namespace ip ...@@ -1466,11 +1467,11 @@ namespace ip
constexpr port_type constexpr port_type
port() const noexcept port() const noexcept
{ return address_v4::_S_ntoh(_M_data._M_v4.sin_port); } { return address_v4::_S_ntoh_16(_M_data._M_v4.sin_port); }
void void
port(port_type __port_num) noexcept port(port_type __port_num) noexcept
{ _M_data._M_v4.sin_port = address_v4::_S_hton(__port_num); } { _M_data._M_v4.sin_port = address_v4::_S_hton_16(__port_num); }
void* data() noexcept { return &_M_data; } void* data() noexcept { return &_M_data; }
const void* data() const noexcept { return &_M_data; } const void* data() const noexcept { return &_M_data; }
......
...@@ -794,7 +794,7 @@ inline namespace v1 ...@@ -794,7 +794,7 @@ inline namespace v1
bool bool
at_mark(error_code& __ec) const at_mark(error_code& __ec) const
{ {
#ifdef _GLIBCXX_HAVE_SYS_SOCKET_H #ifdef _GLIBCXX_HAVE_SOCKATMARK
const int __result = ::sockatmark(native_handle()); const int __result = ::sockatmark(native_handle());
if (__result == -1) if (__result == -1)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment