Check AI_NUMERICSERV is defined before using it
authorJonathan Wakely <jwakely@redhat.com>
Thu, 10 Jan 2019 13:21:54 +0000 (13:21 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 10 Jan 2019 13:21:54 +0000 (13:21 +0000)
The AI_NUMERICSERV constant is missing from old Darwin systems, so only
use it if it's supported.

* include/experimental/internet [AI_NUMERICSERV]
(resolver_base::numeric_service): Define conditionally.
* testsuite/experimental/net/internet/resolver/base.cc: Test it
conditionally.
* testsuite/experimental/net/internet/resolver/ops/lookup.cc:
Likewise.

From-SVN: r267809

libstdc++-v3/ChangeLog
libstdc++-v3/include/experimental/internet
libstdc++-v3/testsuite/experimental/net/internet/resolver/base.cc
libstdc++-v3/testsuite/experimental/net/internet/resolver/ops/lookup.cc

index fdaf477c358964d12c4c335cc81f10c4376fe1b2..19a12f8e1637a1c5cc0fe4a25298547be4aff4db 100644 (file)
@@ -1,3 +1,12 @@
+2019-01-10  Jonathan Wakely  <jwakely@redhat.com>
+
+       * include/experimental/internet [AI_NUMERICSERV]
+       (resolver_base::numeric_service): Define conditionally.
+       * testsuite/experimental/net/internet/resolver/base.cc: Test it
+       conditionally.
+       * testsuite/experimental/net/internet/resolver/ops/lookup.cc:
+       Likewise.
+
 2019-01-10  Ville Voutilainen  <ville.voutilainen@gmail.com>
            Jonathan Wakely  <jwakely@redhat.com>
 
index cd0eee2958509b23299c82abdc5a0ebb1ea2e80d..07c62e697cd6600a726ae679052513dd33dac4fb 100644 (file)
@@ -1629,7 +1629,9 @@ namespace ip
       __flags_passive                  = AI_PASSIVE,
       __flags_canonical_name           = AI_CANONNAME,
       __flags_numeric_host             = AI_NUMERICHOST,
+#ifdef AI_NUMERICSERV
       __flags_numeric_service          = AI_NUMERICSERV,
+#endif
       __flags_v4_mapped                        = AI_V4MAPPED,
       __flags_all_matching             = AI_ALL,
       __flags_address_configured       = AI_ADDRCONFIG
@@ -1637,7 +1639,9 @@ namespace ip
     static constexpr flags passive             = __flags_passive;
     static constexpr flags canonical_name      = __flags_canonical_name;
     static constexpr flags numeric_host                = __flags_numeric_host;
+#ifdef AI_NUMERICSERV
     static constexpr flags numeric_service     = __flags_numeric_service;
+#endif
     static constexpr flags v4_mapped           = __flags_v4_mapped;
     static constexpr flags all_matching                = __flags_all_matching;
     static constexpr flags address_configured  = __flags_address_configured;
index 657e2f56b43afab44b1b7ce500f3c128358e37b2..746557af65673dd1744ecdf804d2c65e75fe8710 100644 (file)
@@ -49,7 +49,9 @@ test01()
   (void) resolver::passive;
   (void) resolver::canonical_name;
   (void) resolver::numeric_host;
+#ifdef AI_NUMERICSERV
   (void) resolver::numeric_service;
+#endif
   (void) resolver::v4_mapped;
   (void) resolver::all_matching;
   (void) resolver::address_configured;
index d926385f1a84edb29f769ec31cf9f768d2a4c790..39fb7fd77087eb64fe652bd3e26e6f9aa58a7efd 100644 (file)
@@ -49,7 +49,10 @@ test02()
   std::error_code ec;
   io_context ctx;
   ip::tcp::resolver resolv(ctx);
-  auto flags = ip::resolver_base::numeric_host | ip::tcp::resolver::numeric_service;
+  auto flags = ip::resolver_base::numeric_host;
+#ifdef AI_NUMERICSERV
+  flags |= ip::tcp::resolver::numeric_service;
+#endif
   auto addrs = resolv.resolve("127.0.0.1", "42", flags, ec);
   VERIFY( !ec );
   VERIFY( addrs.size() > 0 );