chiark / gitweb /
Merge pull request #181 from its-pointless/master
[termux-packages] / packages / nodejs / deps-cares-src-ares_init.c.patch
1 diff -u -r ../node-v4.2.2/deps/cares/src/ares_init.c ./deps/cares/src/ares_init.c
2 --- ../node-v4.2.2/deps/cares/src/ares_init.c   2015-11-03 15:00:03.000000000 -0500
3 +++ ./deps/cares/src/ares_init.c        2015-12-01 21:18:14.327288234 -0500
4 @@ -43,7 +43,35 @@
5  #endif
6  
7  #if defined(ANDROID) || defined(__ANDROID__)
8 +# ifdef __LP64__
9 +# include <dlfcn.h>
10 +// http://stackoverflow.com/questions/28413530/api-to-get-android-system-properties-is-removed-in-arm64-platforms
11 +// Android 'L' makes __system_property_get a non-global symbol.
12 +// Here we provide a stub which loads the symbol from libc via dlsym.
13 +#define PROP_NAME_MAX 31
14 +#define PROP_VALUE_MAX 91
15 +typedef int (*PFN_SYSTEM_PROP_GET)(const char *, char *);
16 +int __system_property_get(const char* name, char* value)
17 +{
18 +       static PFN_SYSTEM_PROP_GET __real_system_property_get = NULL;
19 +       if (!__real_system_property_get) {
20 +               // libc.so should already be open, get a handle to it.
21 +               void *handle = dlopen("libc.so", RTLD_NOLOAD);
22 +               if (!handle) {
23 +                       printf("Cannot dlopen libc.so: %s.\n", dlerror());
24 +               } else {
25 +                       __real_system_property_get = (PFN_SYSTEM_PROP_GET)dlsym(handle, "__system_property_get");
26 +               }
27 +               if (!__real_system_property_get) {
28 +                       printf("Cannot resolve __system_property_get(): %s.\n", dlerror());
29 +               }
30 +       }
31 +       return (*__real_system_property_get)(name, value);
32 +} 
33 +# else
34  #include <sys/system_properties.h>
35 +#endif
36 +
37  /* From the Bionic sources */
38  #define DNS_PROP_NAME_PREFIX  "net.dns"
39  #define MAX_DNS_PROPERTIES    8