Use stosl in memset; makes boot time bearable
This commit is contained in:
parent
e25b74ca80
commit
d0f3efca65
4
string.c
4
string.c
|
@ -4,6 +4,10 @@
|
||||||
void*
|
void*
|
||||||
memset(void *dst, int c, uint n)
|
memset(void *dst, int c, uint n)
|
||||||
{
|
{
|
||||||
|
if ((int)dst%4 == 0 && n%4 == 0){
|
||||||
|
c &= 0xFF;
|
||||||
|
stosl(dst, (c<<24)|(c<<16)|(c<<8)|c, n/4);
|
||||||
|
} else
|
||||||
stosb(dst, c, n);
|
stosb(dst, c, n);
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
9
x86.h
9
x86.h
|
@ -48,6 +48,15 @@ stosb(void *addr, int data, int cnt)
|
||||||
"memory", "cc");
|
"memory", "cc");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
stosl(void *addr, int data, int cnt)
|
||||||
|
{
|
||||||
|
asm volatile("cld; rep stosl" :
|
||||||
|
"=D" (addr), "=c" (cnt) :
|
||||||
|
"0" (addr), "1" (cnt), "a" (data) :
|
||||||
|
"memory", "cc");
|
||||||
|
}
|
||||||
|
|
||||||
struct segdesc;
|
struct segdesc;
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
|
|
Loading…
Reference in a new issue