Deal with very old linux kernels
authorJoost VandeVondele <Joost.VandeVondele@gmail.com>
Fri, 21 Aug 2020 05:42:19 +0000 (07:42 +0200)
committerJoost VandeVondele <Joost.VandeVondele@gmail.com>
Fri, 21 Aug 2020 15:56:33 +0000 (17:56 +0200)
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

index 459ea10035b6ae9e6a4de47e01a60f2dec596865..56a3dcad42d888fb7afeccc808f69432fbccf1c6 100644 (file)
@@ -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;
 }