aboutsummaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-connectivity/networkmanager/networkmanager/musl/0001-Fix-build-with-musl.patch
blob: 21e9a16d6d6565782ad502c9a3e3ceeb6f460ba5 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
From f43c9a5b07832a91383e59d655bc3c8a9f48c451 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@gmail.com>
Date: Tue, 2 Apr 2019 01:34:35 +0200
Subject: [PATCH] Fix build with musl
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Upstream-Status: Pending

Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
---
 clients/cli/connections.c                    |  1 -
 configure.ac                                 |  1 +
 libnm-core/nm-utils.c                        |  2 +-
 shared/n-acd/src/n-acd.c                     |  1 -
 shared/systemd/src/basic/in-addr-util.c      |  1 +
 shared/systemd/src/basic/process-util.c      |  9 ++++++
 shared/systemd/src/basic/socket-util.h       |  6 ++++
 shared/systemd/src/basic/stdio-util.h        |  2 ++
 shared/systemd/src/basic/string-util.h       |  5 ++++
 shared/systemd/src/basic/util.h              | 29 ++++----------------
 src/platform/wifi/nm-wifi-utils.h            |  4 +++
 src/platform/wpan/nm-wpan-utils.h            |  2 --
 src/settings/nm-settings-connection.h        |  2 --
 src/systemd/src/libsystemd-network/sd-lldp.c |  1 +
 src/systemd/src/systemd/sd-dhcp-client.h     |  2 ++
 src/systemd/src/systemd/sd-dhcp-lease.h      |  2 ++
 src/systemd/src/systemd/sd-dhcp6-client.h    |  2 ++
 src/systemd/src/systemd/sd-ipv4ll.h          |  2 ++
 src/systemd/src/systemd/sd-lldp.h            |  2 +-
 19 files changed, 44 insertions(+), 32 deletions(-)

diff --git a/clients/cli/connections.c b/clients/cli/connections.c
index 6db44f8..36e51cc 100644
--- a/clients/cli/connections.c
+++ b/clients/cli/connections.c
@@ -25,7 +25,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <signal.h>
-#include <netinet/ether.h>
 #include <readline/readline.h>
 #include <readline/history.h>
 #include <fcntl.h>
diff --git a/configure.ac b/configure.ac
index 872c292..b1d7a68 100644
--- a/configure.ac
+++ b/configure.ac
@@ -241,6 +241,7 @@ dnl
 dnl Checks for libdl - on certain platforms its part of libc
 dnl
 AC_SEARCH_LIBS([dlopen], [dl dld], [], [ac_cv_search_dlopen=])
+AS_IF([test "$ac_cv_search_dlopen" = "none required"],[ac_cv_search_dlopen=""])
 AC_SUBST([DL_LIBS], "$ac_cv_search_dlopen")
 
 PKG_CHECK_MODULES(GLIB, [gio-unix-2.0 >= 2.37.6 gmodule-2.0],
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c
index d276cfe..2aec785 100644
--- a/libnm-core/nm-utils.c
+++ b/libnm-core/nm-utils.c
@@ -21,10 +21,10 @@
 
 #include "nm-default.h"
 
+#include <netinet/ether.h>
 #include "nm-utils.h"
 
 #include <stdlib.h>
-#include <netinet/ether.h>
 #include <arpa/inet.h>
 #include <uuid/uuid.h>
 #include <libintl.h>
diff --git a/shared/n-acd/src/n-acd.c b/shared/n-acd/src/n-acd.c
index def56a2..dd4eb78 100644
--- a/shared/n-acd/src/n-acd.c
+++ b/shared/n-acd/src/n-acd.c
@@ -11,7 +11,6 @@
 #include <inttypes.h>
 #include <limits.h>
 #include <linux/if_packet.h>
-#include <netinet/if_ether.h>
 #include <netinet/in.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/shared/systemd/src/basic/in-addr-util.c b/shared/systemd/src/basic/in-addr-util.c
index 5ced350..c6b52b8 100644
--- a/shared/systemd/src/basic/in-addr-util.c
+++ b/shared/systemd/src/basic/in-addr-util.c
@@ -13,6 +13,7 @@
 #include "in-addr-util.h"
 #include "macro.h"
 #include "parse-util.h"
+#include "string-util.h"
 #include "util.h"
 
 bool in4_addr_is_null(const struct in_addr *a) {
diff --git a/shared/systemd/src/basic/process-util.c b/shared/systemd/src/basic/process-util.c
index b0afb5c..7adc8bd 100644
--- a/shared/systemd/src/basic/process-util.c
+++ b/shared/systemd/src/basic/process-util.c
@@ -21,6 +21,9 @@
 #include <sys/wait.h>
 #include <syslog.h>
 #include <unistd.h>
+#ifndef __GLIBC__
+#include <pthread.h>
+#endif
 #if 0 /* NM_IGNORED */
 #if HAVE_VALGRIND_VALGRIND_H
 #include <valgrind/valgrind.h>
@@ -1168,11 +1171,13 @@ void reset_cached_pid(void) {
         cached_pid = CACHED_PID_UNSET;
 }
 
+#ifdef __GLIBC__
 /* We use glibc __register_atfork() + __dso_handle directly here, as they are not included in the glibc
  * headers. __register_atfork() is mostly equivalent to pthread_atfork(), but doesn't require us to link against
  * libpthread, as it is part of glibc anyway. */
 extern int __register_atfork(void (*prepare) (void), void (*parent) (void), void (*child) (void), void *dso_handle);
 extern void* __dso_handle _weak_;
+#endif
 
 pid_t getpid_cached(void) {
         static bool installed = false;
@@ -1201,7 +1206,11 @@ pid_t getpid_cached(void) {
                          * only half-documented (glibc doesn't document it but LSB does — though only superficially)
                          * we'll check for errors only in the most generic fashion possible. */
 
+#ifdef __GLIBC__
                         if (__register_atfork(NULL, NULL, reset_cached_pid, __dso_handle) != 0) {
+#else
+                        if (pthread_atfork(NULL, NULL, reset_cached_pid) != 0) {
+#endif
                                 /* OOM? Let's try again later */
                                 cached_pid = CACHED_PID_UNSET;
                                 return new_pid;
diff --git a/shared/systemd/src/basic/socket-util.h b/shared/systemd/src/basic/socket-util.h
index d2246a8..76f257f 100644
--- a/shared/systemd/src/basic/socket-util.h
+++ b/shared/systemd/src/basic/socket-util.h
@@ -13,6 +13,12 @@
 #include <sys/types.h>
 #include <sys/un.h>
 
+#if !defined(__GLIBC__)
+/* SIOCGSTAMPNS from linux/asm-generic.h
+ * for src/systemd/src/libsystemd-network/sd-lldp.c */
+#include <linux/sockios.h>
+#endif
+
 #include "macro.h"
 #include "missing_socket.h"
 #include "sparse-endian.h"
diff --git a/shared/systemd/src/basic/stdio-util.h b/shared/systemd/src/basic/stdio-util.h
index dc67b6e..6336243 100644
--- a/shared/systemd/src/basic/stdio-util.h
+++ b/shared/systemd/src/basic/stdio-util.h
@@ -1,7 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 #pragma once
 
+#if defined(__GLIBC__)
 #include <printf.h>
+#endif
 #include <stdarg.h>
 #include <stdio.h>
 #include <sys/types.h>
diff --git a/shared/systemd/src/basic/string-util.h b/shared/systemd/src/basic/string-util.h
index 38070ab..6b918e0 100644
--- a/shared/systemd/src/basic/string-util.h
+++ b/shared/systemd/src/basic/string-util.h
@@ -27,6 +27,11 @@
 #define strcaseeq(a,b) (strcasecmp((a),(b)) == 0)
 #define strncaseeq(a, b, n) (strncasecmp((a), (b), (n)) == 0)
 
+/* musl does not know strndupa */
+#if !defined(__GLIBC__)
+#define strndupa(x,s) strncpy(alloca(strlen(x)+1),x,s)
+#endif
+
 int strcmp_ptr(const char *a, const char *b) _pure_;
 
 static inline bool streq_ptr(const char *a, const char *b) {
diff --git a/shared/systemd/src/basic/util.h b/shared/systemd/src/basic/util.h
index dc33d66..cc768e9 100644
--- a/shared/systemd/src/basic/util.h
+++ b/shared/systemd/src/basic/util.h
@@ -27,6 +27,11 @@
 #include "macro.h"
 #include "time-util.h"
 
+#if !defined(__GLIBC__)
+typedef int (*__compar_fn_t) (const void*, const void*);
+typedef __compar_fn_t comparison_fn_t;
+#endif
+
 size_t page_size(void) _pure_;
 #define PAGE_ALIGN(l) ALIGN_TO((l), page_size())
 
@@ -66,16 +71,6 @@ int prot_from_flags(int flags) _const_;
 bool in_initrd(void);
 void in_initrd_force(bool value);
 
-void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
-                 __compar_d_fn_t compar, void *arg);
-
-#define typesafe_bsearch_r(k, b, n, func, userdata)                     \
-        ({                                                              \
-                const typeof(b[0]) *_k = k;                             \
-                int (*_func_)(const typeof(b[0])*, const typeof(b[0])*, typeof(userdata)) = func; \
-                xbsearch_r((const void*) _k, (b), (n), sizeof((b)[0]), (__compar_d_fn_t) _func_, userdata); \
-        })
-
 /**
  * Normal bsearch requires base to be nonnull. Here were require
  * that only if nmemb > 0.
@@ -116,20 +111,6 @@ static inline void qsort_safe(void *base, size_t nmemb, size_t size, __compar_fn
                 qsort_safe((p), (n), sizeof((p)[0]), (__compar_fn_t) _func_); \
         })
 
-static inline void qsort_r_safe(void *base, size_t nmemb, size_t size, __compar_d_fn_t compar, void *userdata) {
-        if (nmemb <= 1)
-                return;
-
-        assert(base);
-        qsort_r(base, nmemb, size, compar, userdata);
-}
-
-#define typesafe_qsort_r(p, n, func, userdata)                          \
-        ({                                                              \
-                int (*_func_)(const typeof(p[0])*, const typeof(p[0])*, typeof(userdata)) = func; \
-                qsort_r_safe((p), (n), sizeof((p)[0]), (__compar_d_fn_t) _func_, userdata); \
-        })
-
 /* Normal memcpy requires src to be nonnull. We do nothing if n is 0. */
 static inline void memcpy_safe(void *dst, const void *src, size_t n) {
         if (n == 0)
diff --git a/src/platform/wifi/nm-wifi-utils.h b/src/platform/wifi/nm-wifi-utils.h
index 36148b5..d282eb2 100644
--- a/src/platform/wifi/nm-wifi-utils.h
+++ b/src/platform/wifi/nm-wifi-utils.h
@@ -22,7 +22,11 @@
 #ifndef __WIFI_UTILS_H__
 #define __WIFI_UTILS_H__
 
+#if defined(__GLIBC__)
 #include <net/ethernet.h>
+#else /* musl libc */
+#define ETH_ALEN	6		/* Octets in one ethernet addr	 */
+#endif
 
 #include "nm-dbus-interface.h"
 #include "nm-setting-wireless.h"
diff --git a/src/platform/wpan/nm-wpan-utils.h b/src/platform/wpan/nm-wpan-utils.h
index 1b54ec4..ed39938 100644
--- a/src/platform/wpan/nm-wpan-utils.h
+++ b/src/platform/wpan/nm-wpan-utils.h
@@ -20,8 +20,6 @@
 #ifndef __WPAN_UTILS_H__
 #define __WPAN_UTILS_H__
 
-#include <net/ethernet.h>
-
 #include "nm-dbus-interface.h"
 #include "platform/nm-netlink.h"
 
diff --git a/src/settings/nm-settings-connection.h b/src/settings/nm-settings-connection.h
index e796b71..c01fef6 100644
--- a/src/settings/nm-settings-connection.h
+++ b/src/settings/nm-settings-connection.h
@@ -22,8 +22,6 @@
 #ifndef __NETWORKMANAGER_SETTINGS_CONNECTION_H__
 #define __NETWORKMANAGER_SETTINGS_CONNECTION_H__
 
-#include <net/ethernet.h>
-
 #include "nm-dbus-object.h"
 #include "nm-connection.h"
 
diff --git a/src/systemd/src/libsystemd-network/sd-lldp.c b/src/systemd/src/libsystemd-network/sd-lldp.c
index 741128e..62914ae 100644
--- a/src/systemd/src/libsystemd-network/sd-lldp.c
+++ b/src/systemd/src/libsystemd-network/sd-lldp.c
@@ -3,6 +3,7 @@
 #include "nm-sd-adapt-core.h"
 
 #include <arpa/inet.h>
+#include <net/ethernet.h>
 #include <linux/sockios.h>
 #include <sys/ioctl.h>
 
diff --git a/src/systemd/src/systemd/sd-dhcp-client.h b/src/systemd/src/systemd/sd-dhcp-client.h
index bd0d429..c935fe1 100644
--- a/src/systemd/src/systemd/sd-dhcp-client.h
+++ b/src/systemd/src/systemd/sd-dhcp-client.h
@@ -20,7 +20,9 @@
 ***/
 
 #include <inttypes.h>
+#if defined(__GLIBC__)
 #include <net/ethernet.h>
+#endif
 #include <netinet/in.h>
 #include <sys/types.h>
 #include <stdbool.h>
diff --git a/src/systemd/src/systemd/sd-dhcp-lease.h b/src/systemd/src/systemd/sd-dhcp-lease.h
index d299c79..991e67e 100644
--- a/src/systemd/src/systemd/sd-dhcp-lease.h
+++ b/src/systemd/src/systemd/sd-dhcp-lease.h
@@ -19,7 +19,9 @@
 ***/
 
 #include <inttypes.h>
+#if defined(__GLIBC__)
 #include <net/ethernet.h>
+#endif
 #include <netinet/in.h>
 #include <sys/types.h>
 
diff --git a/src/systemd/src/systemd/sd-dhcp6-client.h b/src/systemd/src/systemd/sd-dhcp6-client.h
index 43d38f5..57ab487 100644
--- a/src/systemd/src/systemd/sd-dhcp6-client.h
+++ b/src/systemd/src/systemd/sd-dhcp6-client.h
@@ -20,7 +20,9 @@
 ***/
 
 #include <inttypes.h>
+#if defined(__GLIBC__)
 #include <net/ethernet.h>
+#endif
 #include <sys/types.h>
 
 #include "sd-dhcp6-lease.h"
diff --git a/src/systemd/src/systemd/sd-ipv4ll.h b/src/systemd/src/systemd/sd-ipv4ll.h
index 71bd4cf..1c667ba 100644
--- a/src/systemd/src/systemd/sd-ipv4ll.h
+++ b/src/systemd/src/systemd/sd-ipv4ll.h
@@ -19,7 +19,9 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
+#if defined(__GLIBC__)
 #include <net/ethernet.h>
+#endif
 #include <netinet/in.h>
 
 #include "sd-event.h"
diff --git a/src/systemd/src/systemd/sd-lldp.h b/src/systemd/src/systemd/sd-lldp.h
index bf3afad..4cace87 100644
--- a/src/systemd/src/systemd/sd-lldp.h
+++ b/src/systemd/src/systemd/sd-lldp.h
@@ -18,7 +18,7 @@
 ***/
 
 #include <inttypes.h>
-#include <net/ethernet.h>
+//#include <net/ethernet.h>
 #include <sys/types.h>
 
 #include "sd-event.h"
-- 
2.20.1