Bug 1276927: Remove Bionic dependencies from Necko, r=valentin draft
authorThomas Zimmermann <tdz@users.sourceforge.net>
Wed, 15 Jun 2016 09:31:28 +0100
changeset 378343 cf32ffe187bbba24753b1e76c3005f15adb4d9c5
parent 378342 a118c4b48149cdfb7ba5c849b5f21410763b5118
child 378344 8d5281910374661d0aae147822f56e4bab5250ac
push id20985
push usertdz@users.sourceforge.net
push dateThu, 16 Jun 2016 07:41:33 +0000
reviewersvalentin
bugs1276927
milestone50.0a1
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 += [