The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH -tip 1/3] x86/asm/32: Modernize memset() functions
@ 2025-05-06 16:52 Uros Bizjak
  2025-05-06 16:52 ` [PATCH -tip 2/3] x86/asm/32: Modernize __constant_memcpy() Uros Bizjak
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Uros Bizjak @ 2025-05-06 16:52 UTC (permalink / raw)
  To: x86, linux-kernel
  Cc: Uros Bizjak, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, H. Peter Anvin

Use inout "+" constraint modifier where appropriate and declare
temporary variable using __auto_type, similar to what x86_64 does.

No functional changes intended.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
 arch/x86/include/asm/string_32.h | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/arch/x86/include/asm/string_32.h b/arch/x86/include/asm/string_32.h
index e9cce169bb4c..9152d2c0f60e 100644
--- a/arch/x86/include/asm/string_32.h
+++ b/arch/x86/include/asm/string_32.h
@@ -164,12 +164,12 @@ extern void *memchr(const void *cs, int c, size_t count);
 
 static inline void *__memset_generic(void *s, char c, size_t count)
 {
-	int d0, d1;
+	const __auto_type s0 = s;
 	asm volatile("rep stosb"
-		     : "=&c" (d0), "=&D" (d1)
-		     : "a" (c), "1" (s), "0" (count)
+		     : "+D" (s), "+c" (count)
+		     : "a" (c)
 		     : "memory");
-	return s;
+	return s0;
 }
 
 /* we might want to write optimized versions of these later */
@@ -197,23 +197,23 @@ extern void *memset(void *, int, size_t);
 #define __HAVE_ARCH_MEMSET16
 static inline void *memset16(uint16_t *s, uint16_t v, size_t n)
 {
-	int d0, d1;
+	const __auto_type s0 = s;
 	asm volatile("rep stosw"
-		     : "=&c" (d0), "=&D" (d1)
-		     : "a" (v), "1" (s), "0" (n)
+		     : "+D" (s), "+c" (n)
+		     : "a" (v)
 		     : "memory");
-	return s;
+	return s0;
 }
 
 #define __HAVE_ARCH_MEMSET32
 static inline void *memset32(uint32_t *s, uint32_t v, size_t n)
 {
-	int d0, d1;
+	const __auto_type s0 = s;
 	asm volatile("rep stosl"
-		     : "=&c" (d0), "=&D" (d1)
-		     : "a" (v), "1" (s), "0" (n)
+		     : "+D" (s), "+c" (n)
+		     : "a" (v)
 		     : "memory");
-	return s;
+	return s0;
 }
 
 /*
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-05-07 21:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-06 16:52 [PATCH -tip 1/3] x86/asm/32: Modernize memset() functions Uros Bizjak
2025-05-06 16:52 ` [PATCH -tip 2/3] x86/asm/32: Modernize __constant_memcpy() Uros Bizjak
2025-05-06 16:52 ` [PATCH -tip 3/3] x86/asm/32: Modernize _memcpy() Uros Bizjak
2025-05-06 17:34   ` Uros Bizjak
2025-05-07 20:28     ` David Laight
2025-05-07 21:29       ` Uros Bizjak
2025-05-06 17:54 ` [PATCH -tip 1/3] x86/asm/32: Modernize memset() functions H. Peter Anvin
2025-05-06 18:22   ` Linus Torvalds
2025-05-07  0:31     ` H. Peter Anvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox