X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Farch%2Fx86_64%2Flib.c;fp=KernelLand%2FKernel%2Farch%2Fx86_64%2Flib.c;h=85dda82438452ab445a553ce5c8362d24499c841;hb=5f8480455a9e2172b15dfc7fb96480a68506c30d;hp=977cffd1ee283d36c687ab951c53d17f824ace95;hpb=280a08f6c4380924b3a288d0283ef70a00f7bba9;p=tpg%2Facess2.git 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;