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
|
From 239d51b5b02ba766f34b3fce9803f8fd13097471 Mon Sep 17 00:00:00 2001
From: Mark Hatle <mark.hatle@amd.com>
Date: Fri, 22 Sep 2023 11:09:50 -0600
Subject: [PATCH] macro-funcamental.h: Microblaze does not have atomic
functions
For some reason the systemd developers decided that needed to hardcode
the usage of __atomic_exchange functions, however not all architectures
define this. Microblaze is one such architecture, so we fall back to
a less safe way of doing the same thing. A quick inspection of
the ONCE users show that even if we end up with a race condition the
worst expected behavior could be multiple log messages.
Upstream-Status: Pending
Signed-off-by: Mark Hatle <mark.hatle@amd.com>
---
src/fundamental/macro-fundamental.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/src/fundamental/macro-fundamental.h b/src/fundamental/macro-fundamental.h
index 1d49765fce..f45f55cdfe 100644
--- a/src/fundamental/macro-fundamental.h
+++ b/src/fundamental/macro-fundamental.h
@@ -116,11 +116,28 @@
* on this macro will run concurrently to all other code conditionalized
* the same way, there's no ordering or completion enforced. */
#define ONCE __ONCE(UNIQ_T(_once_, UNIQ))
+#if !defined (__microblaze__)
#define __ONCE(o) \
({ \
static bool (o) = false; \
__atomic_exchange_n(&(o), true, __ATOMIC_SEQ_CST); \
})
+#else
+ /* Microblaze does not contain __atomic_exchange_n*, so we do it
+ * the old fashioned way. Note, it's possible that ONCE may run more
+ * then ONCE due to possible races, however it is not expected to cause
+ * an issue with systemd usage. */
+#define __ONCE(o) \
+ ({ \
+ static bool (o) = false; \
+ bool rc = false; \
+ if ((o) == false) { \
+ (o) = true; \
+ rc = true; \
+ } \
+ rc; \
+ })
+#endif
#undef MAX
#define MAX(a, b) __MAX(UNIQ, (a), UNIQ, (b))
--
2.34.1
|