]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[libc] Remove unnecessary "cld" instruction from memset()
authorMichael Brown <mcb30@ipxe.org>
Sun, 4 Nov 2012 22:58:42 +0000 (22:58 +0000)
committerMichael Brown <mcb30@ipxe.org>
Mon, 12 Nov 2012 16:58:49 +0000 (16:58 +0000)
Saving is one byte per call to memset().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/x86/include/bits/string.h

index f0d3c965970cd7bea779eaea88b44454af856c28..5736295ab42f738e3ede990f5b9b0a2cff8b64aa 100644 (file)
@@ -192,17 +192,24 @@ memmove ( void *dest, const void *src, size_t len ) {
 }
 
 #define __HAVE_ARCH_MEMSET
-static inline void * memset(void *s, int c,size_t count)
-{
-int d0, d1;
-__asm__ __volatile__(
-       "cld\n\t"
-       "rep\n\t"
-       "stosb"
-       : "=&c" (d0), "=&D" (d1)
-       :"a" (c),"1" (s),"0" (count)
-       :"memory");
-return s;
+
+/**
+ * Fill memory region
+ *
+ * @v dest             Destination address
+ * @v fill             Fill pattern
+ * @v len              Length
+ * @ret dest           Destination address
+ */
+static inline void * memset ( void *dest, int fill, size_t len ) {
+       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