[PATCH v8 2/4] x86/asm: group inline string functions

From: Mauricio Faria de Oliveira

Date: Thu Jul 23 2026 - 19:14:56 EST


Group the __inline string functions in the same header.

Use <asm/shared/string.h> since __inline_memcmp() must remain there for use
by arch/x86/boot/string.c.

No functional changes.

Signed-off-by: Mauricio Faria de Oliveira <mfo@xxxxxxxxxx>
---
arch/x86/include/asm/shared/string.h | 21 +++++++++++++++++++++
arch/x86/include/asm/string.h | 21 +--------------------
2 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/arch/x86/include/asm/shared/string.h b/arch/x86/include/asm/shared/string.h
index 66a446168fd1e9914b9e00540269f555abe4738d..68b4e5a509d9758271bf203382b62dd0943274c8 100644
--- a/arch/x86/include/asm/shared/string.h
+++ b/arch/x86/include/asm/shared/string.h
@@ -2,6 +2,27 @@
#ifndef _ASM_X86_SHARED_STRING_H
#define _ASM_X86_SHARED_STRING_H

+static __always_inline void *__inline_memcpy(void *to, const void *from, size_t len)
+{
+ void *ret = to;
+
+ asm volatile("rep movsb"
+ : "+D" (to), "+S" (from), "+c" (len)
+ : : "memory");
+ return ret;
+}
+
+static __always_inline void *__inline_memset(void *s, int v, size_t n)
+{
+ void *ret = s;
+
+ asm volatile("rep stosb"
+ : "+D" (s), "+c" (n)
+ : "a" ((uint8_t)v)
+ : "memory");
+ return ret;
+}
+
/*
* This inline memcmp() returns 0 (equal) or 1 (not equal).
* The regular memcmp() returns <0 (less than), 0 (equal), or >0 (greater than)
diff --git a/arch/x86/include/asm/string.h b/arch/x86/include/asm/string.h
index 9cb5aae7fba9ffcf0f5af8f939d30467750ccaa9..dbf59f0d4cca71e2ddce0d8764aeec8782236669 100644
--- a/arch/x86/include/asm/string.h
+++ b/arch/x86/include/asm/string.h
@@ -8,25 +8,6 @@
# include <asm/string_64.h>
#endif

-static __always_inline void *__inline_memcpy(void *to, const void *from, size_t len)
-{
- void *ret = to;
-
- asm volatile("rep movsb"
- : "+D" (to), "+S" (from), "+c" (len)
- : : "memory");
- return ret;
-}
-
-static __always_inline void *__inline_memset(void *s, int v, size_t n)
-{
- void *ret = s;
-
- asm volatile("rep stosb"
- : "+D" (s), "+c" (n)
- : "a" ((uint8_t)v)
- : "memory");
- return ret;
-}
+#include <asm/shared/string.h>

#endif /* _ASM_X86_STRING_H */

--
2.47.3