|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v3 2/4] x86/asm, x86/boot: expose inline memcmp
Move the inline memcmp function currently only available in 'boot/string.c'
and its users (eg, 'boot/compressed/string.c' and 'purgatory/purgatory.ro')
into the inline string functions header <asm/string_inline.h> to be reused.
Note that the inline memcmp() returns 0/1, not -1/0/1 as regular memcmp()
(reported by David Laight <david.laight.linux@xxxxxxxxx>), which is not
caused or changed by this commit; this will be addressed separately.
Signed-off-by: Mauricio Faria de Oliveira <mfo@xxxxxxxxxx>
---
arch/x86/boot/string.c | 6 ++----
arch/x86/include/asm/string_inline.h | 11 +++++++++++
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c
index
ac0f900ebc47efa81c92e1bb2010ea41677899c4..544681d046c3f87101309ffaca0c90512a244856
100644
--- a/arch/x86/boot/string.c
+++ b/arch/x86/boot/string.c
@@ -15,6 +15,7 @@
#include <linux/errno.h>
#include <linux/limits.h>
#include <asm/asm.h>
+#include <asm/string_inline.h>
#include "ctype.h"
#include "string.h"
@@ -31,10 +32,7 @@
int memcmp(const void *s1, const void *s2, size_t len)
{
- bool diff;
- asm("repe cmpsb"
- : "=@ccnz" (diff), "+D" (s1), "+S" (s2), "+c" (len));
- return diff;
+ return __inline_memcmp(s1, s2, len);
}
/*
diff --git a/arch/x86/include/asm/string_inline.h
b/arch/x86/include/asm/string_inline.h
index
ffcfa6583d2bc7b91d078888518d0e80248af940..91ed89bfdfa9b148002441e94f48039b17f70391
100644
--- a/arch/x86/include/asm/string_inline.h
+++ b/arch/x86/include/asm/string_inline.h
@@ -23,4 +23,15 @@ static __always_inline void *__inline_memset(void *s, int v,
size_t n)
return ret;
}
+/* Note: this memcmp() returns 0/1, not -1/0/1 as regular memcmp(). */
+static __always_inline int __inline_memcmp(const void *s1, const void *s2,
size_t len)
+{
+ bool diff;
+
+ asm("repe cmpsb"
+ : "=@ccnz" (diff), "+D" (s1), "+S" (s2), "+c" (len));
+
+ return diff;
+}
+
#endif /* _ASM_X86_STRING_INLINE_H */
--
2.51.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |