arch/arm/include/asm/string.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
The current logic to split the 64-bit argument into its 32-bit halves is
byte-order specific and a bit clunky. Use a union instead which is
easier to read and works in all cases.
GCC still generates the same machine code.
While at it, rename the arguments of the __memset64() prototype to
actually reflect their semantics.
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
arch/arm/include/asm/string.h | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/arch/arm/include/asm/string.h b/arch/arm/include/asm/string.h
index c35250c4991b..96fc6cf460ec 100644
--- a/arch/arm/include/asm/string.h
+++ b/arch/arm/include/asm/string.h
@@ -39,13 +39,17 @@ static inline void *memset32(uint32_t *p, uint32_t v, __kernel_size_t n)
}
#define __HAVE_ARCH_MEMSET64
-extern void *__memset64(uint64_t *, uint32_t low, __kernel_size_t, uint32_t hi);
+extern void *__memset64(uint64_t *, uint32_t first, __kernel_size_t, uint32_t second);
static inline void *memset64(uint64_t *p, uint64_t v, __kernel_size_t n)
{
- if (IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN))
- return __memset64(p, v, n * 8, v >> 32);
- else
- return __memset64(p, v >> 32, n * 8, v);
+ union {
+ uint64_t val;
+ struct {
+ uint32_t first, second;
+ };
+ } word = { .val = v };
+
+ return __memset64(p, word.first, n * 8, word.second);
}
/*
---
base-commit: 37a93dd5c49b5fda807fd204edf2547c3493319c
change-id: 20260212-arm-memset64-cleanup-c470af232e87
Best regards,
--
Thomas Weißschuh <thomas.weissschuh@linutronix.de>
On Thu, 12 Feb 2026 at 23:39, Thomas Weißschuh
<thomas.weissschuh@linutronix.de> wrote:
>
> The current logic to split the 64-bit argument into its 32-bit halves is
> byte-order specific and a bit clunky. Use a union instead which is
> easier to read and works in all cases.
>
> GCC still generates the same machine code.
>
> While at it, rename the arguments of the __memset64() prototype to
> actually reflect their semantics.
I'll just apply this directly since I suggested this change, and I'm
doing some architecture patches - like your alpha fix for a missing
argument - and pulls right now anyway.
Linus
© 2016 - 2026 Red Hat, Inc.