Skip to contentSkip to conversation

systemd: Make 254 work on musl

PATCH New Khem Raj 1 participant 1 message Aug 3, 2023

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 systemd: Make 254 work on musl

---
 ...ake-malloc_trim-conditional-on-glibc.patch | 39 +++++++++++++++
 ...hared-Do-not-use-malloc_info-on-musl.patch | 50 +++++++++++++++++++
 meta/recipes-core/systemd/systemd_254.bb      |  2 +
 3 files changed, 91 insertions(+)
 create mode 100644 meta/recipes-core/systemd/systemd/0028-sd-event-Make-malloc_trim-conditional-on-glibc.patch
 create mode 100644 meta/recipes-core/systemd/systemd/0029-shared-Do-not-use-malloc_info-on-musl.patch
meta/recipes-core/systemd/systemd/0028-sd-event-Make-malloc_trim-conditional-on-glibc.patch new file +39 -0
new file mode 100644
index 00000000000..c9ec00012e8
@@ -0,0 +1,39 @@
+From 148645ba8b62f04c7c5ff5907378663f97880f22 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Wed, 2 Aug 2023 12:06:27 -0700
+Subject: [PATCH 1/4] sd-event: Make malloc_trim() conditional on glibc
+
+musl does not have this API
+
+Upstream-Status: Inappropriate [musl-specific]
+Signed-off-by: Khem Raj <[email protected]>
+---
+ src/libsystemd/sd-event/sd-event.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
+index aba458185b..48c94a7672 100644
+--- a/src/libsystemd/sd-event/sd-event.c
++++ b/src/libsystemd/sd-event/sd-event.c
+@@ -1874,7 +1874,7 @@ _public_ int sd_event_add_exit(
+ }
+
+ _public_ int sd_event_trim_memory(void) {
+-        int r;
++        int r = 0;
+
+         /* A default implementation of a memory pressure callback. Simply releases our own allocation caches
+          * and glibc's. This is automatically used when people call sd_event_add_memory_pressure() with a
+@@ -1888,7 +1888,9 @@ _public_ int sd_event_trim_memory(void) {
+
+         usec_t before_timestamp = now(CLOCK_MONOTONIC);
+         hashmap_trim_pools();
++#ifdef __GLIBC__
+         r = malloc_trim(0);
++#endif
+         usec_t after_timestamp = now(CLOCK_MONOTONIC);
+
+         if (r > 0)
+--
+2.41.0
+
meta/recipes-core/systemd/systemd/0029-shared-Do-not-use-malloc_info-on-musl.patch new file +50 -0

50 lines not on this page · raw message

meta/recipes-core/systemd/systemd_254.bb +2 -0
index 7ba4233f6a2..ea1a4f02f05 100644
@@ -53,6 +53,8 @@ SRC_URI_MUSL = "\
                file://0025-include-sys-file.h-for-LOCK_EX.patch \
                file://0026-test-test-sizeof-Include-sys-timex.h-for-struct-time.patch \
                file://0027-include-missing-sys-file.h-for-LOCK_EX.patch \
+               file://0028-sd-event-Make-malloc_trim-conditional-on-glibc.patch \
+               file://0029-shared-Do-not-use-malloc_info-on-musl.patch \
                "
 
 PAM_PLUGINS = " \
Signature · 1 line
2.41.0