From 5840e1515195ccea72f945b03239b79dcf220c16 Mon Sep 17 00:00:00 2001 From: "John Hodge (sonata)" Date: Mon, 3 Nov 2014 18:21:53 +0800 Subject: [PATCH] Kernel/x86_64 - Fix broken memset --- KernelLand/Kernel/arch/x86_64/lib.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/KernelLand/Kernel/arch/x86_64/lib.c b/KernelLand/Kernel/arch/x86_64/lib.c index 977cffd1..85dda824 100644 --- a/KernelLand/Kernel/arch/x86_64/lib.c +++ b/KernelLand/Kernel/arch/x86_64/lib.c @@ -370,11 +370,11 @@ void *memset(void *__dest, int __val, size_t __count) __asm__ __volatile__ ("rep stosb" : : "D"(__dest),"a"(__val),"c"(__count)); else { Uint8 *dst = __dest; + size_t qwords = __count / 8; + size_t trail_bytes = __count % 8; - __asm__ __volatile__ ("rep stosq" : : "D"(dst),"a"(0),"c"(__count/8)); - dst += __count & ~7; - __count = __count & 7; - while( __count-- ) + __asm__ __volatile__ ("rep stosq" : "=D"(dst) : "D"(dst),"a"(0),"c"(qwords)); + while( trail_bytes-- ) *dst++ = 0; } return __dest; -- 2.20.1