[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v9 2/5] x86/asm, x86/boot: expose inline memcmp()



On Sat, Aug 22, 2026 at 03:33:18PM -0300, Mauricio Faria de Oliveira wrote:
> Move the inline memcmp function currently only available in 'boot/string.c'
> into the shared string function header <asm/shared/string.h> to be reused.
> 
> This is not done through <asm/string.h> to avoid pulling unnecessary code
> in 'boot/string.c' that causes build errors in 'boot/compressed/string.c'
> and 'purgatory/purgatory.ro'.

Please drop those '' quotes - it is perfectly clear that those are .c files.

> No functional changes.
> 
> Signed-off-by: Mauricio Faria de Oliveira <mfo@xxxxxxxxxx>
> 
> ---
> 
> Thanks to David Laight for noticing the return value difference between
> inline and regular memcmp().
> ---
>  arch/x86/boot/string.c               | 13 ++-----------
>  arch/x86/include/asm/shared/string.h | 26 ++++++++++++++++++++++++++
>  2 files changed, 28 insertions(+), 11 deletions(-)

...

> diff --git a/arch/x86/include/asm/shared/string.h 
> b/arch/x86/include/asm/shared/string.h
> new file mode 100644
> index 
> 0000000000000000000000000000000000000000..06c1d5e5013e4d59cfb49866d10e164362d2c4cc
> --- /dev/null
> +++ b/arch/x86/include/asm/shared/string.h
> @@ -0,0 +1,26 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _ASM_X86_SHARED_STRING_H
> +#define _ASM_X86_SHARED_STRING_H
> +
> +/*
> + * This inline memcmp() returns 0 (equal) or 1 (not equal).
> + * The regular memcmp() returns <0 (less than), 0 (equal), or >0 (greater 
> than)
> + * to indicate ordering as well.

No need to overdo it:

        Returns:        0 (equal)
                        1 (not equal)

In contrast, the regular memcmp() follows glibc return value semantics.


-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.