summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2022-02-14 13:52:49 +0100
committerTor Egge <Tor.Egge@online.no>2022-02-14 13:52:49 +0100
commit5ff9fa6205e21c4f3ae3a1545e9f826aa1c6a331 (patch)
tree1a981503b03a7aac71cfe97cb60417eec38acb22
parent0df1545a1df897c1dd32c4c5f976ac0e80648792 (diff)
mallopt is linux specific.
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/malloc_mmap_guard.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/staging_vespalib/src/vespa/vespalib/util/malloc_mmap_guard.cpp b/staging_vespalib/src/vespa/vespalib/util/malloc_mmap_guard.cpp
index 0ced160fda2..67181dfd16f 100644
--- a/staging_vespalib/src/vespa/vespalib/util/malloc_mmap_guard.cpp
+++ b/staging_vespalib/src/vespa/vespalib/util/malloc_mmap_guard.cpp
@@ -1,7 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "malloc_mmap_guard.h"
#include <vespa/vespalib/util/size_literals.h>
+#ifdef __linux__
#include <malloc.h>
+#endif
#include <limits>
#include <cassert>
@@ -10,14 +12,20 @@ namespace vespalib {
MallocMmapGuard::MallocMmapGuard(size_t mmapLimit) :
_threadId(std::this_thread::get_id())
{
+#ifdef __linux__
int limit = mmapLimit <= std::numeric_limits<int>::max() ? mmapLimit : std::numeric_limits<int>::max();
mallopt(M_MMAP_THRESHOLD, limit);
+#else
+ (void) mmapLimit;
+#endif
}
MallocMmapGuard::~MallocMmapGuard()
{
assert(_threadId == std::this_thread::get_id());
+#ifdef __linux__
mallopt(M_MMAP_THRESHOLD, 1_Gi);
+#endif
}
}