You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/net-im/spectrum2/files/spectrum2-2.0.13-musl-compa...

96 lines
2.9 KiB

From 19b10896fa3426b2bd9e4e75a63ca52322373d33 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov <vitalyster@gmail.com>
Date: Fri, 24 Jul 2020 15:09:28 +0300
Subject: [PATCH] musl compatibility
---
backends/libpurple/main.cpp | 6 +++---
backends/swiften/main.cpp | 2 ++
libtransport/UserManager.cpp | 2 ++
spectrum/src/main.cpp | 2 ++
4 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/backends/libpurple/main.cpp b/backends/libpurple/main.cpp
index 54c618e0..4555edbc 100644
--- a/backends/libpurple/main.cpp
+++ b/backends/libpurple/main.cpp
@@ -528,7 +528,7 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
purple_accounts_delete_wrapped(account);
#ifndef WIN32
-#if !defined(__FreeBSD__) && !defined(__APPLE__)
+#if !defined(__FreeBSD__) && !defined(__APPLE__) && defined (__GLIBC__)
malloc_trim(0);
#endif
#endif
@@ -2287,7 +2287,7 @@ static void signed_on(PurpleConnection *gc, gpointer unused) {
PurpleAccount *account = purple_connection_get_account_wrapped(gc);
np->handleConnected(np->m_accounts[account]);
#ifndef WIN32
-#if !defined(__FreeBSD__) && !defined(__APPLE__)
+#if !defined(__FreeBSD__) && !defined(__APPLE__) && defined (__GLIBC__)
// force returning of memory chunks allocated by libxml2 to kernel
malloc_trim(0);
#endif
@@ -2516,7 +2516,7 @@ int main(int argc, char **argv) {
boost::locale::generator gen;
std::locale::global(gen(""));
#ifndef WIN32
-#if !defined(__FreeBSD__) && !defined(__APPLE__)
+#if !defined(__FreeBSD__) && !defined(__APPLE__) && defined (__GLIBC__)
mallopt(M_CHECK_ACTION, 2);
mallopt(M_PERTURB, 0xb);
#endif
diff --git a/backends/swiften/main.cpp b/backends/swiften/main.cpp
index f0acdb6d..6c111464 100644
--- a/backends/swiften/main.cpp
+++ b/backends/swiften/main.cpp
@@ -227,10 +227,12 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
#ifndef WIN32
#ifndef __FreeBSD__
#ifndef __MACH__
+#if defined (__GLIBC__)
// force returning of memory chunks allocated by libxml2 to kernel
malloc_trim(0);
#endif
#endif
+#endif
#endif
}
diff --git a/libtransport/UserManager.cpp b/libtransport/UserManager.cpp
index 73fcdae9..a622754f 100644
--- a/libtransport/UserManager.cpp
+++ b/libtransport/UserManager.cpp
@@ -125,10 +125,12 @@ void UserManager::removeUser(User *user, bool onUserBehalf) {
#ifndef WIN32
#ifndef __FreeBSD__
#ifndef __MACH__
+#if defined (__GLIBC__)
malloc_trim(0);
#endif
#endif
#endif
+#endif
// VALGRIND_DO_LEAK_CHECK;
}
diff --git a/spectrum/src/main.cpp b/spectrum/src/main.cpp
index 0f5985a2..89e5b9a1 100644
--- a/spectrum/src/main.cpp
+++ b/spectrum/src/main.cpp
@@ -320,11 +320,13 @@ int main(int argc, char **argv)
#ifndef WIN32
#ifndef __FreeBSD__
#ifndef __MACH__
+#if defined (__GLIBC__)
mallopt(M_CHECK_ACTION, 2);
mallopt(M_PERTURB, 0xb);
#endif
#endif
#endif
+#endif
#ifndef WIN32
if (signal(SIGINT, spectrum_sigint_handler) == SIG_ERR) {