xv6: use stosb for memset
This commit is contained in:
		
							parent
							
								
									c396d065d3
								
							
						
					
					
						commit
						8220135362
					
				
					 2 changed files with 4 additions and 11 deletions
				
			
		
							
								
								
									
										8
									
								
								string.c
									
										
									
									
									
								
							
							
						
						
									
										8
									
								
								string.c
									
										
									
									
									
								
							| 
						 | 
					@ -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
									
										
									
									
									
								
							
							
						
						
									
										7
									
								
								ulib.c
									
										
									
									
									
								
							| 
						 | 
					@ -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;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue