1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-25 20:22:30 +01:00

vm_native: supply only one madvise flag at a time

This commit is contained in:
Nekotekina 2021-04-18 09:29:05 +03:00
parent bdac1d9bfd
commit c061991c43

View File

@ -160,6 +160,10 @@ namespace utils
{ {
ensure(::madvise(ptr, orig_size, c_madv_no_dump) != -1); ensure(::madvise(ptr, orig_size, c_madv_no_dump) != -1);
} }
else
{
ensure(::madvise(ptr, orig_size, c_madv_free) != -1);
}
return ptr; return ptr;
#endif #endif
@ -172,7 +176,15 @@ namespace utils
#else #else
const u64 ptr64 = reinterpret_cast<u64>(pointer); const u64 ptr64 = reinterpret_cast<u64>(pointer);
ensure(::mprotect(reinterpret_cast<void*>(ptr64 & -4096), size + (ptr64 & 4095), +prot) != -1); ensure(::mprotect(reinterpret_cast<void*>(ptr64 & -4096), size + (ptr64 & 4095), +prot) != -1);
ensure(::madvise(reinterpret_cast<void*>(ptr64 & -4096), size + (ptr64 & 4095), MADV_WILLNEED | c_madv_dump) != -1);
if constexpr (c_madv_dump != 0)
{
ensure(::madvise(reinterpret_cast<void*>(ptr64 & -4096), size + (ptr64 & 4095), c_madv_dump) != -1);
}
else
{
ensure(::madvise(reinterpret_cast<void*>(ptr64 & -4096), size + (ptr64 & 4095), MADV_WILLNEED) != -1);
}
#endif #endif
} }
@ -188,6 +200,10 @@ namespace utils
{ {
ensure(::madvise(reinterpret_cast<void*>(ptr64 & -4096), size + (ptr64 & 4095), c_madv_no_dump) != -1); ensure(::madvise(reinterpret_cast<void*>(ptr64 & -4096), size + (ptr64 & 4095), c_madv_no_dump) != -1);
} }
else
{
ensure(::madvise(reinterpret_cast<void*>(ptr64 & -4096), size + (ptr64 & 4095), c_madv_free) != -1);
}
#endif #endif
} }
@ -208,7 +224,14 @@ namespace utils
} }
} }
ensure(::madvise(reinterpret_cast<void*>(ptr64 & -4096), size + (ptr64 & 4095), MADV_WILLNEED | c_madv_dump) != -1); if constexpr (c_madv_dump != 0)
{
ensure(::madvise(reinterpret_cast<void*>(ptr64 & -4096), size + (ptr64 & 4095), c_madv_dump) != -1);
}
else
{
ensure(::madvise(reinterpret_cast<void*>(ptr64 & -4096), size + (ptr64 & 4095), MADV_WILLNEED) != -1);
}
#endif #endif
} }