aboutsummaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-support/open-vm-tools/open-vm-tools/0001-Add-resolv_compat.h-for-musl-builds.patch
blob: c09bc12520aa31293983ac01bf1cf504edf6477e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
From f93b680ec1a816ffe90d5f1bce609f8bf68a456e Mon Sep 17 00:00:00 2001
From: Trevor Gamblin <trevor.gamblin@windriver.com>
Date: Wed, 14 Apr 2021 10:24:52 -0400
Subject: [PATCH] Add resolv_compat.h for musl builds

musl doesn't implement res_ninit, so it needs to be defined
independently for musl builds. This patch is based on the one at
https://gitweb.gentoo.org/proj/musl.git/tree/dev-qt/qtwebengine/files/qtwebengine-5.7.0-musl-resolver.patch?id=7f4100326793d55d45d0f5bb6178827ce6173513

Upstream-Status: Pending

Signed-off-by: Trevor Gamblin <trevor.gamblin@windriver.com>

---
 open-vm-tools/lib/nicInfo/nicInfoPosix.c  |  4 +++
 open-vm-tools/lib/nicInfo/resolv_compat.h | 30 +++++++++++++++++++++++
 2 files changed, 34 insertions(+)
 create mode 100644 open-vm-tools/lib/nicInfo/resolv_compat.h

diff --git a/open-vm-tools/lib/nicInfo/nicInfoPosix.c b/open-vm-tools/lib/nicInfo/nicInfoPosix.c
index c56b73cf..8ae3b2f7 100644
--- a/open-vm-tools/lib/nicInfo/nicInfoPosix.c
+++ b/open-vm-tools/lib/nicInfo/nicInfoPosix.c
@@ -70,6 +70,10 @@
 #   include <net/if.h>
 #endif
 
+#if !defined(__GLIBC__)
+#include "resolv_compat.h"
+#endif
+
 /*
  * resolver(3) and IPv6:
  *
diff --git a/open-vm-tools/lib/nicInfo/resolv_compat.h b/open-vm-tools/lib/nicInfo/resolv_compat.h
new file mode 100644
index 00000000..d768464b
--- /dev/null
+++ b/open-vm-tools/lib/nicInfo/resolv_compat.h
@@ -0,0 +1,30 @@
+#if !defined(__GLIBC__)
+/***************************************************************************
+ * resolv_compat.h
+ *
+ * Mimick GLIBC's res_ninit() and res_nclose() for musl libc
+ * Note: res_init() is actually deprecated according to
+ * http://docs.oracle.com/cd/E36784_01/html/E36875/res-nclose-3resolv.html
+ **************************************************************************/
+#include <string.h>
+
+static inline int res_ninit(res_state statp)
+{
+	int rc = res_init();
+	if (statp != &_res) {
+		memcpy(statp, &_res, sizeof(*statp));
+	}
+	return rc;
+}
+
+static inline int res_nclose(res_state statp)
+{
+	if (!statp)
+		return -1;
+	if (statp != &_res) {
+		memset(statp, 0, sizeof(*statp));
+	}
+	return 0;
+}
+#endif
+