From 8220135362c02b5e4a5532a561c6c1bd4b4d1540 Mon Sep 17 00:00:00 2001
From: rsc <rsc>
Date: Sun, 8 Mar 2009 21:38:30 +0000
Subject: [PATCH] xv6: use stosb for memset

---
 string.c | 8 ++------
 ulib.c   | 7 ++-----
 2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/string.c b/string.c
index c6b6de6..cb890ee 100644
--- a/string.c
+++ b/string.c
@@ -1,14 +1,10 @@
 #include "types.h"
+#include "x86.h"
 
 void*
 memset(void *dst, int c, uint n)
 {
-  char *d;
-
-  d = (char*)dst;
-  while(n-- > 0)
-    *d++ = c;
-
+  stosb(dst, c, n);
   return dst;
 }
 
diff --git a/ulib.c b/ulib.c
index ed2542d..0268c26 100644
--- a/ulib.c
+++ b/ulib.c
@@ -2,6 +2,7 @@
 #include "stat.h"
 #include "fcntl.h"
 #include "user.h"
+#include "x86.h"
 
 char*
 strcpy(char *s, char *t)
@@ -35,11 +36,7 @@ strlen(char *s)
 void*
 memset(void *dst, int c, uint n)
 {
-  char *d;
-  
-  d = dst;
-  while(n-- > 0)
-    *d++ = c;
+  stosb(dst, c, n);
   return dst;
 }
 
-- 
GitLab