public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Noah Goldstein <goldstein.w.n@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH] x86-64: Make bcmp an alias of __memcmpeq
Date: Sun, 6 Feb 2022 13:34:09 -0600	[thread overview]
Message-ID: <CAFUsyfKnYFMwce64hJWnLV6knt15uxeXZzWtjk1WMkej0e7ueg@mail.gmail.com> (raw)
In-Reply-To: <20220206192615.1313474-1-hjl.tools@gmail.com>

On Sun, Feb 6, 2022 at 1:26 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> ---
>  sysdeps/x86_64/memcmp.S                | 2 +-
>  sysdeps/x86_64/multiarch/memcmp-sse2.S | 6 ++++--
>  sysdeps/x86_64/multiarch/memcmp.c      | 2 --
>  sysdeps/x86_64/multiarch/memcmpeq.c    | 2 ++
>  4 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/sysdeps/x86_64/memcmp.S b/sysdeps/x86_64/memcmp.S
> index e02a53ea1e..2768d45f10 100644
> --- a/sysdeps/x86_64/memcmp.S
> +++ b/sysdeps/x86_64/memcmp.S
> @@ -405,8 +405,8 @@ END(memcmp)
>
>  #ifdef USE_AS_MEMCMPEQ
>  libc_hidden_def (memcmp)
> -#else
>  # undef bcmp
>  weak_alias (memcmp, bcmp)
> +#else
>  libc_hidden_builtin_def (memcmp)
>  #endif
> diff --git a/sysdeps/x86_64/multiarch/memcmp-sse2.S b/sysdeps/x86_64/multiarch/memcmp-sse2.S
> index e10555638d..d825c13ede 100644
> --- a/sysdeps/x86_64/multiarch/memcmp-sse2.S
> +++ b/sysdeps/x86_64/multiarch/memcmp-sse2.S
> @@ -29,8 +29,10 @@
>  #  define libc_hidden_def(ignored)
>  # endif
>
> -# undef weak_alias
> -# define weak_alias(ignored1, ignored2)
> +# ifdef USE_MULTIARCH
> +#  undef weak_alias
> +#  define weak_alias(ignored1, ignored2)
> +# endif
>
>  # undef strong_alias
>  # define strong_alias(ignored1, ignored2)
> diff --git a/sysdeps/x86_64/multiarch/memcmp.c b/sysdeps/x86_64/multiarch/memcmp.c
> index 7757d1ec4e..bae29d8dad 100644
> --- a/sysdeps/x86_64/multiarch/memcmp.c
> +++ b/sysdeps/x86_64/multiarch/memcmp.c
> @@ -27,8 +27,6 @@
>  # include "ifunc-memcmp.h"
>
>  libc_ifunc_redirected (__redirect_memcmp, memcmp, IFUNC_SELECTOR ());
> -# undef bcmp
> -weak_alias (memcmp, bcmp)
>
>  # ifdef SHARED
>  __hidden_ver1 (memcmp, __GI_memcmp, __redirect_memcmp)
> diff --git a/sysdeps/x86_64/multiarch/memcmpeq.c b/sysdeps/x86_64/multiarch/memcmpeq.c
> index aa1c8ad4de..45cb6bad5b 100644
> --- a/sysdeps/x86_64/multiarch/memcmpeq.c
> +++ b/sysdeps/x86_64/multiarch/memcmpeq.c
> @@ -27,6 +27,8 @@
>  # include "ifunc-memcmpeq.h"
>
>  libc_ifunc_redirected (__redirect___memcmpeq, __memcmpeq, IFUNC_SELECTOR ());
> +# undef bcmp
> +weak_alias (__memcmpeq, bcmp)
>
>  # ifdef SHARED
>  __hidden_ver1 (__memcmpeq, __GI___memcmpeq, __redirect___memcmpeq)
> --
> 2.34.1
>

Are we sure this is safe? One of the original rationales for adding
'__memcmpeq' as
a new interface instead of just optimizing 'bcmp' was that users may
be relying on
the fact that 'bcmp' has historically returned the LT/GT of the comparison.

As well, if we are going to change 'bcmp' should we do it for all
architectures so that
its consistent?

  reply	other threads:[~2022-02-06 19:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-06 19:26 H.J. Lu
2022-02-06 19:34 ` Noah Goldstein [this message]
2022-02-06 19:57   ` H.J. Lu
2022-02-06 20:16     ` Noah Goldstein

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=CAFUsyfKnYFMwce64hJWnLV6knt15uxeXZzWtjk1WMkej0e7ueg@mail.gmail.com \
    --to=goldstein.w.n@gmail.com \
    --cc=hjl.tools@gmail.com \
    --cc=libc-alpha@sourceware.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).