mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 09:13:08 +00:00
Use posix_memalign instead of aligned_alloc
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.
This commit is contained in:
parent
fcaf0736fe
commit
8a1de2655c
1 changed files with 2 additions and 1 deletions
|
@ -303,7 +303,8 @@ void* aligned_ttmem_alloc(size_t allocSize, void*& mem) {
|
||||||
|
|
||||||
constexpr size_t alignment = 2 * 1024 * 1024; // assumed 2MB page sizes
|
constexpr size_t alignment = 2 * 1024 * 1024; // assumed 2MB page sizes
|
||||||
size_t size = ((allocSize + alignment - 1) / alignment) * alignment; // multiple of alignment
|
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);
|
madvise(mem, allocSize, MADV_HUGEPAGE);
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue