Commit 7c046c7a authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

msvcrt: Write memory forward in memset.

Instead of going backward, which breaks the Linux kernel transparent huge pages allocation assumptions. This can be reproduced by calling memset on large, newly allocated, memory regions. Signed-off-by: 's avatarRémi Bernon <rbernon@codeweavers.com> Signed-off-by: 's avatarPiotr Caban <piotr@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent f7ac9f30
......@@ -2857,13 +2857,14 @@ void * __cdecl memcpy(void *dst, const void *src, size_t n)
static inline void memset_aligned_32(unsigned char *d, uint64_t v, size_t n)
{
while (n >= 32)
{
*(uint64_t *)(d + n - 32) = v;
*(uint64_t *)(d + n - 24) = v;
*(uint64_t *)(d + n - 16) = v;
*(uint64_t *)(d + n - 8) = v;
n -= 32;
unsigned char *end = d + n;
while (d < end)
{
*(uint64_t *)(d + 0) = v;
*(uint64_t *)(d + 8) = v;
*(uint64_t *)(d + 16) = v;
*(uint64_t *)(d + 24) = v;
d += 32;
}
}
......
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