Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ARM: clean up the memset64() C wrapper

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.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Thomas Weißschuh and committed by
Linus Torvalds
b52343d1 cd7a5651

+9 -5
+9 -5
arch/arm/include/asm/string.h
··· 39 39 } 40 40 41 41 #define __HAVE_ARCH_MEMSET64 42 - extern void *__memset64(uint64_t *, uint32_t low, __kernel_size_t, uint32_t hi); 42 + extern void *__memset64(uint64_t *, uint32_t first, __kernel_size_t, uint32_t second); 43 43 static inline void *memset64(uint64_t *p, uint64_t v, __kernel_size_t n) 44 44 { 45 - if (IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN)) 46 - return __memset64(p, v, n * 8, v >> 32); 47 - else 48 - return __memset64(p, v >> 32, n * 8, v); 45 + union { 46 + uint64_t val; 47 + struct { 48 + uint32_t first, second; 49 + }; 50 + } word = { .val = v }; 51 + 52 + return __memset64(p, word.first, n * 8, word.second); 49 53 } 50 54 51 55 /*