[libc] Remove unnecessary "cld" instruction from memset()

Saving is one byte per call to memset().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
pull/598/head
Michael Brown 2012-11-04 22:58:42 +00:00
parent 61c6af3f0b
commit f8ece72fc9
1 changed files with 18 additions and 11 deletions

View File

@ -192,17 +192,24 @@ memmove ( void *dest, const void *src, size_t len ) {
} }
#define __HAVE_ARCH_MEMSET #define __HAVE_ARCH_MEMSET
static inline void * memset(void *s, int c,size_t count)
{ /**
int d0, d1; * Fill memory region
__asm__ __volatile__( *
"cld\n\t" * @v dest Destination address
"rep\n\t" * @v fill Fill pattern
"stosb" * @v len Length
: "=&c" (d0), "=&D" (d1) * @ret dest Destination address
:"a" (c),"1" (s),"0" (count) */
:"memory"); static inline void * memset ( void *dest, int fill, size_t len ) {
return s; void *discard_D;
size_t discard_c;
__asm__ __volatile__ ( "rep stosb"
: "=&D" ( discard_D ), "=&c" ( discard_c )
: "0" ( dest ), "1" ( len ), "a" ( fill )
: "memory" );
return dest;
} }
#define __HAVE_ARCH_MEMSWAP #define __HAVE_ARCH_MEMSWAP