blob: aa7a5607cf187c0ea1c4d7c42d1d74f062878a40 [file] [log] [blame]
Andrew Geisslere34f8962021-04-15 15:53:51 -05001From c0c36ba5dd7047710e4c3135f147ce4119021200 Mon Sep 17 00:00:00 2001
2From: Trevor Gamblin <trevor.gamblin@windriver.com>
3Date: Wed, 14 Apr 2021 10:24:52 -0400
4Subject: [PATCH] Add resolv_compat.h for musl builds
5
6musl doesn't implement res_ninit, so it needs to be defined
7independently for musl builds. This patch is based on the one at
8https://gitweb.gentoo.org/proj/musl.git/tree/dev-qt/qtwebengine/files/qtwebengine-5.7.0-musl-resolver.patch?id=7f4100326793d55d45d0f5bb6178827ce6173513
9
10Upstream-Status: Pending
11
12Signed-off-by: Trevor Gamblin <trevor.gamblin@windriver.com>
13---
14 open-vm-tools/lib/nicInfo/nicInfoPosix.c | 4 +++
15 open-vm-tools/lib/nicInfo/resolv_compat.h | 30 +++++++++++++++++++++++
16 2 files changed, 34 insertions(+)
17 create mode 100644 open-vm-tools/lib/nicInfo/resolv_compat.h
18
19diff --git a/open-vm-tools/lib/nicInfo/nicInfoPosix.c b/open-vm-tools/lib/nicInfo/nicInfoPosix.c
20index 8710c542..25f3146e 100644
21--- a/open-vm-tools/lib/nicInfo/nicInfoPosix.c
22+++ b/open-vm-tools/lib/nicInfo/nicInfoPosix.c
23@@ -70,6 +70,10 @@
24 # include <net/if.h>
25 #endif
26
27+#if !defined(__GLIBC__)
28+#include "resolv_compat.h"
29+#endif
30+
31 /*
32 * resolver(3) and IPv6:
33 *
34diff --git a/open-vm-tools/lib/nicInfo/resolv_compat.h b/open-vm-tools/lib/nicInfo/resolv_compat.h
35new file mode 100644
36index 00000000..d768464b
37--- /dev/null
38+++ b/open-vm-tools/lib/nicInfo/resolv_compat.h
39@@ -0,0 +1,30 @@
40+#if !defined(__GLIBC__)
41+/***************************************************************************
42+ * resolv_compat.h
43+ *
44+ * Mimick GLIBC's res_ninit() and res_nclose() for musl libc
45+ * Note: res_init() is actually deprecated according to
46+ * http://docs.oracle.com/cd/E36784_01/html/E36875/res-nclose-3resolv.html
47+ **************************************************************************/
48+#include <string.h>
49+
50+static inline int res_ninit(res_state statp)
51+{
52+ int rc = res_init();
53+ if (statp != &_res) {
54+ memcpy(statp, &_res, sizeof(*statp));
55+ }
56+ return rc;
57+}
58+
59+static inline int res_nclose(res_state statp)
60+{
61+ if (!statp)
62+ return -1;
63+ if (statp != &_res) {
64+ memset(statp, 0, sizeof(*statp));
65+ }
66+ return 0;
67+}
68+#endif
69+
70--
712.30.2
72