mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-09 00:00:03 +01:00
minor improvements in memset (usage of stosq instead of stosb)
This commit is contained in:
parent
c5f2c1f0b7
commit
a2819c6874
1 changed files with 13 additions and 3 deletions
|
@ -66,9 +66,19 @@ inline static void *memset(void* dest, int val, size_t count)
|
|||
if (BUILTIN_EXPECT(!dest, 0))
|
||||
return dest;
|
||||
|
||||
asm volatile ("cld; rep stosb"
|
||||
: "=&c"(i), "=&D"(j)
|
||||
: "a"(val), "1"(dest), "0"(count) : "memory","cc");
|
||||
if (val) {
|
||||
asm volatile ("cld; rep stosb"
|
||||
: "=&c"(i), "=&D"(j)
|
||||
: "a"(val), "1"(dest), "0"(count) : "memory","cc");
|
||||
} else {
|
||||
asm volatile (
|
||||
"cld; rep stosq\n\t"
|
||||
"movq %5, %%rcx\n\t"
|
||||
"andq $7, %%rcx\n\t"
|
||||
"rep stosb\n\t"
|
||||
: "=&c"(i), "=&D"(j)
|
||||
: "a"((size_t)val), "1"(dest), "0"(count/8), "g"(count): "memory","cc");
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue