| 1 | |
| 2 | |
| 3 | @@ -9,6 +9,10 @@
|
| 4 |
|
| 5 | #include <resolv.h>
|
| 6 |
|
| 7 | +#if !defined(__GLIBC__)
|
| 8 | +#include "resolv_compat.h"
|
| 9 | +#endif
|
| 10 | +
|
| 11 | #include "base/lazy_instance.h"
|
| 12 | #include "base/macros.h"
|
| 13 | #include "base/notreached.h"
|
| 14 | |
| 15 | |
| 16 | @@ -8,6 +8,10 @@
|
| 17 | #include <string>
|
| 18 | #include <type_traits>
|
| 19 |
|
| 20 | +#if !defined(__GLIBC__)
|
| 21 | +#include "resolv_compat.h"
|
| 22 | +#endif
|
| 23 | +
|
| 24 | #include "base/bind.h"
|
| 25 | #include "base/files/file.h"
|
| 26 | #include "base/files/file_path.h"
|
| 27 | diff --git a/src/3rdparty/chromium/net/dns/resolv_compat.h b/src/3rdparty/chromium/net/dns/resolv_compat.h
|
| 28 | new file mode 100644
|
| 29 | index 0000000..4f0e852
|
| 30 | |
| 31 | |
| 32 | @@ -0,0 +1,29 @@
|
| 33 | +#if !defined(__GLIBC__)
|
| 34 | +/***************************************************************************
|
| 35 | + * resolv_compat.h
|
| 36 | + *
|
| 37 | + * Mimick GLIBC's res_ninit() and res_nclose() for musl libc
|
| 38 | + * Note: res_init() is actually deprecated according to
|
| 39 | + * http://docs.oracle.com/cd/E36784_01/html/E36875/res-nclose-3resolv.html
|
| 40 | + **************************************************************************/
|
| 41 | +#include <string.h>
|
| 42 | +
|
| 43 | +static inline int res_ninit(res_state statp)
|
| 44 | +{
|
| 45 | + int rc = res_init();
|
| 46 | + if (statp != &_res) {
|
| 47 | + memcpy(statp, &_res, sizeof(*statp));
|
| 48 | + }
|
| 49 | + return rc;
|
| 50 | +}
|
| 51 | +
|
| 52 | +static inline int res_nclose(res_state statp)
|
| 53 | +{
|
| 54 | + if (!statp)
|
| 55 | + return -1;
|
| 56 | + if (statp != &_res) {
|
| 57 | + memset(statp, 0, sizeof(*statp));
|
| 58 | + }
|
| 59 | + return 0;
|
| 60 | +}
|
| 61 | +#endif
|