From 8b45b1c4907b4b2186441e02edd3b0c37f8b3269 Mon Sep 17 00:00:00 2001 From: Joost VandeVondele Date: Fri, 21 Aug 2020 07:42:19 +0200 Subject: [PATCH] Deal with very old linux kernels MADV_HUGEPAGE might not be available, for kernels before 2.6.38 (released 2011). Just skip the madvise. closes https://github.com/official-stockfish/Stockfish/pull/3039 No functional change --- src/misc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/misc.cpp b/src/misc.cpp index 459ea100..56a3dcad 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -367,7 +367,9 @@ void* aligned_ttmem_alloc(size_t allocSize, void*& mem) { size_t size = ((allocSize + alignment - 1) / alignment) * alignment; // multiple of alignment if (posix_memalign(&mem, alignment, size)) mem = nullptr; +#if defined(MADV_HUGEPAGE) madvise(mem, allocSize, MADV_HUGEPAGE); +#endif return mem; } -- 2.39.2