summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Clements <[email protected]>2011-09-01 10:41:21 -0400
committerAustin Clements <[email protected]>2011-09-01 10:41:27 -0400
commitd0f3efca650eccd5179e045cd07f7d723037defc (patch)
treef28734b5ac99749ebb0927e079a4c656f6e0d847
parente25b74ca8069e340c3f2c267d09beed6d9328250 (diff)
downloadxv6-labs-d0f3efca650eccd5179e045cd07f7d723037defc.tar.gz
xv6-labs-d0f3efca650eccd5179e045cd07f7d723037defc.tar.bz2
xv6-labs-d0f3efca650eccd5179e045cd07f7d723037defc.zip
Use stosl in memset; makes boot time bearable
-rw-r--r--string.c6
-rw-r--r--x86.h9
2 files changed, 14 insertions, 1 deletions
diff --git a/string.c b/string.c
index a557dc5..d066c18 100644
--- a/string.c
+++ b/string.c
@@ -4,7 +4,11 @@
void*
memset(void *dst, int c, uint n)
{
- stosb(dst, c, 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);
return dst;
}
diff --git a/x86.h b/x86.h
index 828d5bc..0c3feae 100644
--- a/x86.h
+++ b/x86.h
@@ -48,6 +48,15 @@ stosb(void *addr, int data, int cnt)
"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;
static inline void