Commit ed0d279e authored by Anna Henningsen's avatar Anna Henningsen Committed by Commit Bot

[platform] Work around potentially missing `madvise()`

Some Linux kernels are built without `madvise()`. In that
case, do not crash but rather ignore the return value instead.

Refs: https://github.com/nodejs/node/issues/21562
Change-Id: Iff8d0d0e9e7935804e2fc994be7f8bd21c553846
Reviewed-on: https://chromium-review.googlesource.com/1131943Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54415}
parent 50ae8de9
......@@ -156,6 +156,8 @@ int ReclaimInaccessibleMemory(void* address, size_t size) {
#else
int ret = madvise(address, size, MADV_FREE);
#endif
if (ret != 0 && errno == ENOSYS)
return 0; // madvise is not available on all systems.
if (ret != 0 && errno == EINVAL) {
// MADV_FREE only works on Linux 4.5+ . If request failed, retry with older
// MADV_DONTNEED . Note that MADV_FREE being defined at compile time doesn't
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment