aboutsummaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2012-11-04 22:58:42 +0000
committerMichael Brown <mcb30@ipxe.org>2012-11-12 16:58:49 +0000
commitf8ece72fc9b441c8a72635558a18bca98b211081 (patch)
tree091e50ec22c151a1c12628a3b17ed57f0c33c112 /src/arch
parent61c6af3f0b64b711f4a104aedad036a3d12093eb (diff)
downloadipxe-f8ece72fc9b441c8a72635558a18bca98b211081.zip
ipxe-f8ece72fc9b441c8a72635558a18bca98b211081.tar.gz
ipxe-f8ece72fc9b441c8a72635558a18bca98b211081.tar.bz2
[libc] Remove unnecessary "cld" instruction from memset()
Saving is one byte per call to memset(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/x86/include/bits/string.h29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/arch/x86/include/bits/string.h b/src/arch/x86/include/bits/string.h
index f0d3c96..5736295 100644
--- a/src/arch/x86/include/bits/string.h
+++ b/src/arch/x86/include/bits/string.h
@@ -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