aboutsummaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-connectivity/networkmanager/networkmanager/musl/0003-Fix-build-with-musl-for-n-dhcp4.patch
blob: 62252826e2ba0b7806214cbf9e9ed7fafb2d1063 (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
From aff5cded8847f3eee59f5cec22afb8630d401a85 Mon Sep 17 00:00:00 2001
From: Adrian Freihofer <adrian.freihofer@siemens.com>
Date: Sat, 7 Mar 2020 14:22:36 +0100
Subject: [PATCH 3/4] Fix build with musl for n-dhcp4

---
 shared/n-dhcp4/src/n-dhcp4-c-probe.c | 8 ++++++++
 shared/n-dhcp4/src/n-dhcp4-private.h | 4 ++++
 2 files changed, 12 insertions(+)

diff --git a/shared/n-dhcp4/src/n-dhcp4-c-probe.c b/shared/n-dhcp4/src/n-dhcp4-c-probe.c
index e4477a7..75713c8 100644
--- a/shared/n-dhcp4/src/n-dhcp4-c-probe.c
+++ b/shared/n-dhcp4/src/n-dhcp4-c-probe.c
@@ -360,8 +360,12 @@ static void n_dhcp4_client_probe_config_initialize_random_seed(NDhcp4ClientProbe
         seed16v[1] = (u64 >> 16) ^ (u64 >>  0);
         seed16v[2] = (u64 >> 32) ^ (u64 >> 16);
 
+#ifdef __GLIBC__
         r = seed48_r(seed16v, &config->entropy);
         c_assert(!r);
+#else
+        memcpy(config->entropy, seed16v, sizeof seed16v);
+#endif
 }
 
 /**
@@ -375,10 +379,14 @@ static void n_dhcp4_client_probe_config_initialize_random_seed(NDhcp4ClientProbe
  */
 uint32_t n_dhcp4_client_probe_config_get_random(NDhcp4ClientProbeConfig *config) {
         long int result;
+#ifdef __GLIBC__
         int r;
 
         r = mrand48_r(&config->entropy, &result);
         c_assert(!r);
+#else
+        result = jrand48(config->entropy);
+#endif
 
         return result;
 };
diff --git a/shared/n-dhcp4/src/n-dhcp4-private.h b/shared/n-dhcp4/src/n-dhcp4-private.h
index 436ee80..ffcb4b2 100644
--- a/shared/n-dhcp4/src/n-dhcp4-private.h
+++ b/shared/n-dhcp4/src/n-dhcp4-private.h
@@ -267,7 +267,11 @@ struct NDhcp4ClientProbeConfig {
         bool inform_only;
         bool init_reboot;
         struct in_addr requested_ip;
+#ifdef __GLIBC__
         struct drand48_data entropy;    /* entropy pool */
+#else
+        unsigned short entropy[3];      /* entropy pool */
+#endif
         uint64_t ms_start_delay;        /* max ms to wait before starting probe */
         NDhcp4ClientProbeOption *options[UINT8_MAX + 1];
         int8_t request_parameters[UINT8_MAX + 1];
-- 
2.24.1