blob: 4a97c26185b46a4836120b823a8cdd5cc58d3a18 [file] [log] [blame]
Patrick Williams2194f502022-10-16 14:26:09 -05001From c1ee0b0a0a05379d0e6475dfceaaf41876192640 Mon Sep 17 00:00:00 2001
Andrew Geisslere34f8962021-04-15 15:53:51 -05002From: 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
Patrick Williams2194f502022-10-16 14:26:09 -050020index c56b73cfe..8ae3b2f74 100644
Andrew Geisslere34f8962021-04-15 15:53:51 -050021--- 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
Patrick Williams2194f502022-10-16 14:26:09 -050036index 000000000..d768464b9
Andrew Geisslere34f8962021-04-15 15:53:51 -050037--- /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+
Patrick Williams2194f502022-10-16 14:26:09 -050070--
712.25.1
72