| 1 | diff -u -r ../c-ares-1.10.0/ares_init.c ./ares_init.c |
| 2 | --- ../c-ares-1.10.0/ares_init.c 2013-02-17 11:44:02.000000000 -0500 |
| 3 | +++ ./ares_init.c 2016-01-03 08:28:33.855590585 -0500 |
| 4 | @@ -43,7 +43,36 @@ |
| 5 | #endif |
| 6 | |
| 7 | #if defined(ANDROID) || defined(__ANDROID__) |
| 8 | -#include <sys/system_properties.h> |
| 9 | + |
| 10 | +# ifdef __LP64__ |
| 11 | +# include <dlfcn.h> |
| 12 | +// http://stackoverflow.com/questions/28413530/api-to-get-android-system-properties-is-removed-in-arm64-platforms |
| 13 | +// Android 64-bit makes __system_property_get a non-global symbol. |
| 14 | +// Here we provide a stub which loads the symbol from libc via dlsym. |
| 15 | +#define PROP_NAME_MAX 31 |
| 16 | +#define PROP_VALUE_MAX 91 |
| 17 | +typedef int (*PFN_SYSTEM_PROP_GET)(const char *, char *); |
| 18 | +int __system_property_get(const char* name, char* value) |
| 19 | +{ |
| 20 | + static PFN_SYSTEM_PROP_GET __real_system_property_get = NULL; |
| 21 | + if (!__real_system_property_get) { |
| 22 | + // libc.so should already be open, get a handle to it. |
| 23 | + void *handle = dlopen("libc.so", RTLD_NOLOAD); |
| 24 | + if (!handle) { |
| 25 | + printf("Cannot dlopen libc.so: %s.\n", dlerror()); |
| 26 | + } else { |
| 27 | + __real_system_property_get = (PFN_SYSTEM_PROP_GET)dlsym(handle, "__system_property_get"); |
| 28 | + } |
| 29 | + if (!__real_system_property_get) { |
| 30 | + printf("Cannot resolve __system_property_get(): %s.\n", dlerror()); |
| 31 | + } |
| 32 | + } |
| 33 | + return (*__real_system_property_get)(name, value); |
| 34 | +} |
| 35 | +# else |
| 36 | +# include <sys/system_properties.h> |
| 37 | +#endif |
| 38 | + |
| 39 | /* From the Bionic sources */ |
| 40 | #define DNS_PROP_NAME_PREFIX "net.dns" |
| 41 | #define MAX_DNS_PROPERTIES 8 |