xv6: use stosb for memset

This commit is contained in:
rsc 2009-03-08 21:38:30 +00:00
parent c396d065d3
commit 8220135362
2 changed files with 4 additions and 11 deletions

View file

@ -1,14 +1,10 @@
#include "types.h" #include "types.h"
#include "x86.h"
void* void*
memset(void *dst, int c, uint n) memset(void *dst, int c, uint n)
{ {
char *d; stosb(dst, c, n);
d = (char*)dst;
while(n-- > 0)
*d++ = c;
return dst; return dst;
} }

7
ulib.c
View file

@ -2,6 +2,7 @@
#include "stat.h" #include "stat.h"
#include "fcntl.h" #include "fcntl.h"
#include "user.h" #include "user.h"
#include "x86.h"
char* char*
strcpy(char *s, char *t) strcpy(char *s, char *t)
@ -35,11 +36,7 @@ strlen(char *s)
void* void*
memset(void *dst, int c, uint n) memset(void *dst, int c, uint n)
{ {
char *d; stosb(dst, c, n);
d = dst;
while(n-- > 0)
*d++ = c;
return dst; return dst;
} }