Bug 1276927: Remove Bionic dependencies from Necko, r=valentin
authorThomas Zimmermann <tdz@users.sourceforge.net>
Thu, 16 Jun 2016 08:43:51 +0100
changeset 301965 26c264de3544b9ef5be0f946b21572376cc232f7
parent 301964 f3f3ce8ed0d118f9150da89ee2c93646e1d12295
child 301966 318e39c41b7974fb2c886aec2f8a427f93ef0f7d
push id30346
push usercbook@mozilla.com
push dateThu, 16 Jun 2016 23:32:32 +0000
treeherdermozilla-central@5f95858f8ddf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1276927
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1276927: Remove Bionic dependencies from Necko, r=valentin B2G builds now use the header files from Android NDKs. Bionic is not supported by the build any longer and Bionic features can't be used anymore. This patch removes Necko's dependencies on Bionic in favor of the respective Android code. MozReview-Commit-ID: HP6jC22fLGn
netwerk/dns/GetAddrInfo.cpp
netwerk/dns/moz.build
--- a/netwerk/dns/GetAddrInfo.cpp
+++ b/netwerk/dns/GetAddrInfo.cpp
@@ -13,20 +13,16 @@
 #include "nsAutoPtr.h"
 #include "mozilla/StaticPtr.h"
 #include "MainThreadUtils.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/net/DNS.h"
 #include <algorithm>
 #include "prerror.h"
 
-#if defined(ANDROID) && ANDROID_VERSION > 19
-#include <resolv_netid.h>
-#endif
-
 #include "mozilla/Logging.h"
 
 #if DNSQUERY_AVAILABLE
 // There is a bug in windns.h where the type of parameter ppQueryResultsSet for
 // DnsQuery_A is dependent on UNICODE being set. It should *always* be
 // PDNS_RECORDA, but if UNICODE is set it is PDNS_RECORDW. To get around this
 // we make sure that UNICODE is unset.
 #undef UNICODE
@@ -243,80 +239,16 @@ static MOZ_ALWAYS_INLINE nsresult
     return NS_ERROR_FAILURE;
   }
 
   *aResult = ttl;
   return NS_OK;
 }
 #endif
 
-#if defined(ANDROID) && ANDROID_VERSION >= 19
-// Make the same as nspr functions.
-static MOZ_ALWAYS_INLINE PRAddrInfo*
-_Android_GetAddrInfoForNetInterface(const char* hostname,
-                                   uint16_t af,
-                                   uint16_t flags,
-                                   const char* aNetworkInterface)
-{
-  if ((af != PR_AF_INET && af != PR_AF_UNSPEC) ||
-      (flags & ~ PR_AI_NOCANONNAME) != PR_AI_ADDRCONFIG) {
-    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
-    return nullptr;
-  }
-
-  struct addrinfo *res, hints;
-  int rv;
-  memset(&hints, 0, sizeof(hints));
-  if (!(flags & PR_AI_NOCANONNAME)) {
-    hints.ai_flags |= AI_CANONNAME;
-  }
-
-#ifdef AI_ADDRCONFIG
-  if ((flags & PR_AI_ADDRCONFIG) &&
-      strcmp(hostname, "localhost") != 0 &&
-      strcmp(hostname, "localhost.localdomain") != 0 &&
-      strcmp(hostname, "localhost6") != 0 &&
-      strcmp(hostname, "localhost6.localdomain6") != 0) {
-    hints.ai_flags |= AI_ADDRCONFIG;
-  }
-#endif
-
-  hints.ai_family = (af == PR_AF_INET) ? AF_INET : AF_UNSPEC;
-  hints.ai_socktype = SOCK_STREAM;
-
-#if ANDROID_VERSION == 19
-  rv = android_getaddrinfoforiface(hostname, NULL, &hints, aNetworkInterface,
-                                   0, &res);
-#else
-  uint32_t netId = atoi(aNetworkInterface);
-  rv = android_getaddrinfofornet(hostname, NULL, &hints, netId, 0, &res);
-#endif
-
-#ifdef AI_ADDRCONFIG
-  if (rv == EAI_BADFLAGS && (hints.ai_flags & AI_ADDRCONFIG)) {
-    hints.ai_flags &= ~AI_ADDRCONFIG;
-#if ANDROID_VERSION == 19
-    rv = android_getaddrinfoforiface(hostname, NULL, &hints, aNetworkInterface,
-                                     0, &res);
-#else
-    uint32_t netId = atoi(aNetworkInterface);
-    rv = android_getaddrinfofornet(hostname, NULL, &hints, netId, 0, &res);
-#endif
-  }
-#endif
-
-  if (rv == 0) {
-    return (PRAddrInfo *) res;
-  }
-
-  PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, rv);
-  return nullptr;
-}
-#endif
-
 ////////////////////////////////////
 // PORTABLE RUNTIME IMPLEMENTATION//
 ////////////////////////////////////
 
 static MOZ_ALWAYS_INLINE nsresult
 _GetAddrInfo_Portable(const char* aCanonHost, uint16_t aAddressFamily,
                       uint16_t aFlags, const char* aNetworkInterface,
                       AddrInfo** aAddrInfo)
@@ -334,28 +266,17 @@ static MOZ_ALWAYS_INLINE nsresult
 
   // We need to remove IPv4 records manually because PR_GetAddrInfoByName
   // doesn't support PR_AF_INET6.
   bool disableIPv4 = aAddressFamily == PR_AF_INET6;
   if (disableIPv4) {
     aAddressFamily = PR_AF_UNSPEC;
   }
 
-  PRAddrInfo* prai;
-#if defined(ANDROID) && ANDROID_VERSION >= 19
-  if (aNetworkInterface && aNetworkInterface[0] != '\0') {
-    prai = _Android_GetAddrInfoForNetInterface(aCanonHost,
-                                               aAddressFamily,
-                                               prFlags,
-                                               aNetworkInterface);
-  } else
-#endif
-  {
-    prai = PR_GetAddrInfoByName(aCanonHost, aAddressFamily, prFlags);
-  }
+  PRAddrInfo* prai = PR_GetAddrInfoByName(aCanonHost, aAddressFamily, prFlags);
 
   if (!prai) {
     return NS_ERROR_UNKNOWN_HOST;
   }
 
   const char* canonName = nullptr;
   if (aFlags & nsHostResolver::RES_CANON_NAME) {
     canonName = PR_GetCanonNameFromAddrInfo(prai);
--- a/netwerk/dns/moz.build
+++ b/netwerk/dns/moz.build
@@ -61,19 +61,16 @@ etld_data = GENERATED_FILES['etld_data.i
 etld_data.script = 'prepare_tlds.py'
 etld_data.inputs = ['effective_tld_names.dat']
 
 # need to include etld_data.inc
 LOCAL_INCLUDES += [
     '/netwerk/base',
 ]
 
-if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['ANDROID_VERSION'] > '19':
-    LOCAL_INCLUDES += ['%' + '%s/bionic/libc/dns/include' % CONFIG['ANDROID_SOURCE']]
-
 if CONFIG['ENABLE_INTL_API']:
     DEFINES['IDNA2008'] = True
     CXXFLAGS += CONFIG['MOZ_ICU_CFLAGS']
     CFLAGS += CONFIG['MOZ_ICU_CFLAGS']
     LOCAL_INCLUDES += CONFIG['MOZ_ICU_INCLUDES']
     USE_LIBS += ['icu']
 else:
     UNIFIED_SOURCES += [