Android variants may not have __system_property_get

Some android systems like ARM64 may not have the __system_property_get
symbol in libc (but still have it in the public headers).  Detect this
condition at build time.  The __system_property_get method of retrieving
name servers is deprecated as of Oreo so should strictly be a fallback
mechanism anyhow.
pull/160/head
Brad House 7 years ago
parent 2e35328b9f
commit 2250b598fe
  1. 4
      CMakeLists.txt
  2. 3
      ares_config.h.cmake
  3. 2
      ares_init.c
  4. 5
      configure.ac

@ -350,6 +350,10 @@ CHECK_SYMBOL_EXISTS (strncmpi "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_STRNCMP
CHECK_SYMBOL_EXISTS (strnicmp "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_STRNICMP)
CHECK_SYMBOL_EXISTS (writev "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_WRITEV)
# On Android, the system headers may define __system_property_get(), but excluded
# from libc. We need to perform a link test instead of a header/symbol test.
CHECK_FUNCTION_EXISTS (__system_property_get HAVE___SYSTEM_PROPERTY_GET)
# Unset temporary data
SET (CMAKE_EXTRA_INCLUDE_FILES)
SET (CMAKE_REQUIRED_DEFINITIONS)

@ -331,6 +331,9 @@
/* Define to 1 if you have the ws2tcpip.h header file. */
#cmakedefine HAVE_WS2TCPIP_H
/* Define to 1 if you have the __system_property_get function */
#cmakedefine HAVE___SYSTEM_PROPERTY_GET
/* Define to 1 if you need the malloc.h header file even with stdlib.h */
#cmakedefine NEED_MALLOC_H

@ -1641,6 +1641,7 @@ static int init_by_resolv_conf(ares_channel channel)
ares_free(dns_servers);
}
# ifdef HAVE___SYSTEM_PROPERTY_GET
/* Old way using the system property still in place as
* a fallback. Older android versions can still use this.
* it's possible for older apps not not have added the new
@ -1662,6 +1663,7 @@ static int init_by_resolv_conf(ares_channel channel)
status = ARES_EOF;
}
}
# endif /* HAVE___SYSTEM_PROPERTY_GET */
#elif defined(CARES_USE_LIBRESOLV)
struct __res_state res;
memset(&res, 0, sizeof(res));

@ -812,6 +812,11 @@ AC_CHECK_FUNCS([bitncmp \
])
])
dnl Android. Some variants like arm64 may no longer have __system_property_get
dnl in libc, but they are defined in the headers. Perform a link check.
AC_CHECK_FUNC([__system_property_get], [
AC_DEFINE([HAVE___SYSTEM_PROPERTY_GET], [1], [Define if __system_property_get exists.])
])
dnl Check if the getnameinfo function is available
dnl and get the types of five of its arguments.

Loading…
Cancel
Save