should be a little more portable to older linux systems (before glibc-2.16).
fixes https://github.com/official-stockfish/Stockfish/issues/2665
closes https://github.com/official-stockfish/Stockfish/pull/2668
No functional change.
constexpr size_t alignment = 2 * 1024 * 1024; // assumed 2MB page sizes
size_t size = ((allocSize + alignment - 1) / alignment) * alignment; // multiple of alignment
- mem = aligned_alloc(alignment, size);
+ if (posix_memalign(&mem, alignment, size))
+ mem = nullptr;
madvise(mem, allocSize, MADV_HUGEPAGE);
return mem;
}