gate mallopt behind GLIBC check

This commit is contained in:
Lemmy
2026-05-10 09:34:07 -04:00
parent 32c6be928a
commit bb7d565837
+6 -6
View File
@@ -12,16 +12,14 @@
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>
#ifdef __has_include #ifdef __GLIBC__
#if __has_include(<jemalloc/jemalloc.h>) #if __has_include(<jemalloc/jemalloc.h>)
#include <jemalloc/jemalloc.h> #include <jemalloc/jemalloc.h>
#define HAS_JEMALLOC 1 #define HAS_JEMALLOC 1
#endif #else
#endif
#ifndef HAS_JEMALLOC
#include <malloc.h> #include <malloc.h>
#endif #endif
#endif
namespace { namespace {
@@ -75,9 +73,11 @@ const char* malloc_conf = "narenas:2,dirty_decay_ms:1000,muzzy_decay_ms:5000,tca
#endif #endif
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
#ifndef HAS_JEMALLOC
#if defined(__GLIBC__) && !defined(HAS_JEMALLOC)
mallopt(M_ARENA_MAX, 2); mallopt(M_ARENA_MAX, 2);
#endif #endif
std::setlocale(LC_ALL, ""); std::setlocale(LC_ALL, "");
if (argc >= 2) { if (argc >= 2) {
if (std::strcmp(argv[1], "theme") == 0) if (std::strcmp(argv[1], "theme") == 0)