diff options
| author | Mark Hatle <mark.hatle@amd.com> | 2023-09-22 12:53:09 -0600 |
|---|---|---|
| committer | Mark Hatle <mark.hatle@amd.com> | 2023-09-22 12:53:09 -0600 |
| commit | c13e0ce78ba6c7fde53a3760cb2ed4da4c870e08 (patch) | |
| tree | e67ae8396a57e88426a104cb8c7624b0fbb5f7d9 /meta-microblaze/recipes-core/systemd/files/microblaze-once-macro.patch | |
| parent | dc7b83b753e2213bd15d35432e5d2e95578ee980 (diff) | |
| download | meta-xilinx-c13e0ce78ba6c7fde53a3760cb2ed4da4c870e08.tar.gz | |
meta-microblaze: systemd: Refactor for update systemd
Signed-off-by: Mark Hatle <mark.hatle@amd.com>
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 | 52 |
1 files changed, 31 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 f27a8b43..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,42 +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 | Upstream-Status: Pending | 14 | Upstream-Status: Pending |
| 11 | 15 | ||
| 12 | Signed-off-by: Mark Hatle <mark.hatle@xilinx.com> | 16 | Signed-off-by: Mark Hatle <mark.hatle@amd.com> |
| 17 | --- | ||
| 18 | src/fundamental/macro-fundamental.h | 17 +++++++++++++++++ | ||
| 19 | 1 file changed, 17 insertions(+) | ||
| 13 | 20 | ||
| 14 | Index: git/src/fundamental/macro-fundamental.h | 21 | diff --git a/src/fundamental/macro-fundamental.h b/src/fundamental/macro-fundamental.h |
| 15 | =================================================================== | 22 | index 1d49765fce..f45f55cdfe 100644 |
| 16 | --- git.orig/src/fundamental/macro-fundamental.h | 23 | --- a/src/fundamental/macro-fundamental.h |
| 17 | +++ git/src/fundamental/macro-fundamental.h | 24 | +++ b/src/fundamental/macro-fundamental.h |
| 18 | @@ -109,11 +109,28 @@ | 25 | @@ -116,11 +116,28 @@ |
| 19 | * on this macro will run concurrently to all other code conditionalized | 26 | * on this macro will run concurrently to all other code conditionalized |
| 20 | * the same way, there's no ordering or completion enforced. */ | 27 | * the same way, there's no ordering or completion enforced. */ |
| 21 | #define ONCE __ONCE(UNIQ_T(_once_, UNIQ)) | 28 | #define ONCE __ONCE(UNIQ_T(_once_, UNIQ)) |
| 22 | +#if !defined (__microblaze__) | 29 | +#if !defined (__microblaze__) |
| 23 | #define __ONCE(o) \ | 30 | #define __ONCE(o) \ |
| 24 | ({ \ | 31 | ({ \ |
| 25 | static sd_bool (o) = sd_false; \ | 32 | static bool (o) = false; \ |
| 26 | __sync_bool_compare_and_swap(&(o), sd_false, sd_true); \ | 33 | __atomic_exchange_n(&(o), true, __ATOMIC_SEQ_CST); \ |
| 27 | }) | 34 | }) |
| 28 | +#else | 35 | +#else |
| 29 | + /* 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 |
| 30 | + * 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 |
| 31 | + * 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 |
| 32 | + * an issue. */ | 39 | + * an issue with systemd usage. */ |
| 33 | +#define __ONCE(o) \ | 40 | +#define __ONCE(o) \ |
| 34 | + ({ \ | 41 | + ({ \ |
| 35 | + static bool (o) = sd_false; \ | 42 | + static bool (o) = false; \ |
| 36 | + bool rc = sd_false; \ | 43 | + bool rc = false; \ |
| 37 | + if ((o) == sd_false) { \ | 44 | + if ((o) == false) { \ |
| 38 | + (o) = sd_true; \ | 45 | + (o) = true; \ |
| 39 | + rc = sd_true; \ | 46 | + rc = true; \ |
| 40 | + } \ | 47 | + } \ |
| 41 | + rc; \ | 48 | + rc; \ |
| 42 | + }) | 49 | + }) |
| @@ -44,3 +51,6 @@ Index: git/src/fundamental/macro-fundamental.h | |||
| 44 | 51 | ||
| 45 | #undef MAX | 52 | #undef MAX |
| 46 | #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 | |||
