diff options
Diffstat (limited to 'meta-microblaze/recipes-core/systemd/files/microblaze-once-macro.patch')
-rw-r--r-- | meta-microblaze/recipes-core/systemd/files/microblaze-once-macro.patch | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/meta-microblaze/recipes-core/systemd/files/microblaze-once-macro.patch b/meta-microblaze/recipes-core/systemd/files/microblaze-once-macro.patch index 8cb618ec..3862803b 100644 --- a/meta-microblaze/recipes-core/systemd/files/microblaze-once-macro.patch +++ b/meta-microblaze/recipes-core/systemd/files/microblaze-once-macro.patch | |||
@@ -1,40 +1,49 @@ | |||
1 | For microblaze, replace the ONCE macro | 1 | From 239d51b5b02ba766f34b3fce9803f8fd13097471 Mon Sep 17 00:00:00 2001 |
2 | From: Mark Hatle <mark.hatle@amd.com> | ||
3 | Date: Fri, 22 Sep 2023 11:09:50 -0600 | ||
4 | Subject: [PATCH] macro-funcamental.h: Microblaze does not have atomic | ||
5 | functions | ||
2 | 6 | ||
3 | For some reason the systemd developers decided that needed to hardcode | 7 | For some reason the systemd developers decided that needed to hardcode |
4 | the usage of __sync_bool_compare_and_swap, however not all architectures | 8 | the usage of __atomic_exchange functions, however not all architectures |
5 | define this. Microblaze is one such architecture, so we fall back to | 9 | define this. Microblaze is one such architecture, so we fall back to |
6 | a less 'safe' way of doing the work. However a quick inspection of | 10 | a less safe way of doing the same thing. A quick inspection of |
7 | the ONCE users shows that even if we end up with a race condition the | 11 | the ONCE users show that even if we end up with a race condition the |
8 | worst expected behavior could be multiple log messages. | 12 | worst expected behavior could be multiple log messages. |
9 | 13 | ||
10 | Signed-off-by: Mark Hatle <mark.hatle@xilinx.com> | 14 | Upstream-Status: Pending |
11 | 15 | ||
12 | Index: git/src/fundamental/macro-fundamental.h | 16 | Signed-off-by: Mark Hatle <mark.hatle@amd.com> |
13 | =================================================================== | 17 | --- |
14 | --- git.orig/src/fundamental/macro-fundamental.h | 18 | src/fundamental/macro-fundamental.h | 17 +++++++++++++++++ |
15 | +++ git/src/fundamental/macro-fundamental.h | 19 | 1 file changed, 17 insertions(+) |
16 | @@ -109,11 +109,28 @@ | 20 | |
21 | diff --git a/src/fundamental/macro-fundamental.h b/src/fundamental/macro-fundamental.h | ||
22 | index 1d49765fce..f45f55cdfe 100644 | ||
23 | --- a/src/fundamental/macro-fundamental.h | ||
24 | +++ b/src/fundamental/macro-fundamental.h | ||
25 | @@ -116,11 +116,28 @@ | ||
17 | * on this macro will run concurrently to all other code conditionalized | 26 | * on this macro will run concurrently to all other code conditionalized |
18 | * the same way, there's no ordering or completion enforced. */ | 27 | * the same way, there's no ordering or completion enforced. */ |
19 | #define ONCE __ONCE(UNIQ_T(_once_, UNIQ)) | 28 | #define ONCE __ONCE(UNIQ_T(_once_, UNIQ)) |
20 | +#if !defined (__microblaze__) | 29 | +#if !defined (__microblaze__) |
21 | #define __ONCE(o) \ | 30 | #define __ONCE(o) \ |
22 | ({ \ | 31 | ({ \ |
23 | static sd_bool (o) = sd_false; \ | 32 | static bool (o) = false; \ |
24 | __sync_bool_compare_and_swap(&(o), sd_false, sd_true); \ | 33 | __atomic_exchange_n(&(o), true, __ATOMIC_SEQ_CST); \ |
25 | }) | 34 | }) |
26 | +#else | 35 | +#else |
27 | + /* Microblaze does not contain __sync_bool_compare_and_swap, so we do it | 36 | + /* Microblaze does not contain __atomic_exchange_n*, so we do it |
28 | + * the old fashioned way. Note, it's possible that ONCE may run more | 37 | + * the old fashioned way. Note, it's possible that ONCE may run more |
29 | + * then ONCE due to possible races, however it is not expected to cause | 38 | + * then ONCE due to possible races, however it is not expected to cause |
30 | + * an issue. */ | 39 | + * an issue with systemd usage. */ |
31 | +#define __ONCE(o) \ | 40 | +#define __ONCE(o) \ |
32 | + ({ \ | 41 | + ({ \ |
33 | + static bool (o) = sd_false; \ | 42 | + static bool (o) = false; \ |
34 | + bool rc = sd_false; \ | 43 | + bool rc = false; \ |
35 | + if ((o) == sd_false) { \ | 44 | + if ((o) == false) { \ |
36 | + (o) = sd_true; \ | 45 | + (o) = true; \ |
37 | + rc = sd_true; \ | 46 | + rc = true; \ |
38 | + } \ | 47 | + } \ |
39 | + rc; \ | 48 | + rc; \ |
40 | + }) | 49 | + }) |
@@ -42,3 +51,6 @@ Index: git/src/fundamental/macro-fundamental.h | |||
42 | 51 | ||
43 | #undef MAX | 52 | #undef MAX |
44 | #define MAX(a, b) __MAX(UNIQ, (a), UNIQ, (b)) | 53 | #define MAX(a, b) __MAX(UNIQ, (a), UNIQ, (b)) |
54 | -- | ||
55 | 2.34.1 | ||
56 | |||