From: "H. Peter Anvin" <hpa@zytor.com>
To: Uros Bizjak <ubizjak@gmail.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
torvalds@linux-foundation.org
Subject: Re: [PATCH -tip 1/3] x86/asm/32: Modernize memset() functions
Date: Tue, 06 May 2025 10:54:35 -0700 [thread overview]
Message-ID: <F66E73EB-7237-439F-8408-C0C39B1CE2D2@zytor.com> (raw)
In-Reply-To: <20250506165227.158932-1-ubizjak@gmail.com>
On May 6, 2025 9:52:06 AM PDT, Uros Bizjak <ubizjak@gmail.com> wrote:
>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;
> }
>
> /*
So __auto_type is spelled "auto" in newer C versions, but "auto" was a (completely useless!) keyword going all the way back to K&R C. Can anyone think of a reason why we don't do:
#define auto __auto_type
... and just start using the modern keyword right away?
-hpa
next prev parent reply other threads:[~2025-05-06 17:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` H. Peter Anvin [this message]
2025-05-06 18:22 ` [PATCH -tip 1/3] x86/asm/32: Modernize memset() functions Linus Torvalds
2025-05-07 0:31 ` H. Peter Anvin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=F66E73EB-7237-439F-8408-C0C39B1CE2D2@zytor.com \
--to=hpa@zytor.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=ubizjak@gmail.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.