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 v7] String: Add support for __memcmpeq() ABI on all targets
Date: Thu, 21 Oct 2021 16:04:35 -0500	[thread overview]
Message-ID: <CAFUsyfKqhsONLtDYarOGB6oW5XeY3GvhWHTFKfNq30A5PCpC=w@mail.gmail.com> (raw)
In-Reply-To: <CAMe9rOqKLsKwb5Kbco4hTXCGagEt_HLLL3x8oBoxzLuL0J=j_A@mail.gmail.com>

On Thu, Oct 21, 2021 at 3:01 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Thu, Oct 21, 2021 at 12:58 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
> >
> > On Thu, Oct 21, 2021 at 2:28 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> > >
> > > On Wed, Sep 29, 2021 at 10:17:43AM -0500, GNU C Library wrote:
> > > > No bug.
> > > >
> > > > This commit adds support for __memcmpeq() as a new ABI for all
> > > > targets. In this commit __memcmpeq() is implemented only as an alias
> > > > to the corresponding targets memcmp() implementation. __memcmpeq() is
> > > > added as a new symbol starting with GLIBC_2.35 and defined in string.h
> > > > with comments explaining its behavior. Basic tests that it is callable
> > > > and works where added in string/tester.c
> > > >
> > > > As discussed in the proposal "Add new ABI '__memcmpeq()' to libc"
> > > > __memcmpeq() is essentially a reserved namespace for bcmp(). The means
> > > > is shares the same specifications as memcmp() except the return value
> > > > for non-equal byte sequences is any non-zero value. This is less
> > > > strict than memcmp()'s return value specification and can be better
> > > > optimized when a boolean return is all that is needed.
> > > >
> > > > __memcmpeq() is meant to only be called by compilers if they can prove
> > > > that the return value of a memcmp() call is only used for its boolean
> > > > value.
> > > >
> > > > All tests in string/tester.c passed. As well build succeeds on
> > > > x86_64-linux-gnu target.
> > > > ---
> > > >  string/Versions                                  |  3 +++
> > > >  string/memcmp.c                                  |  2 ++
> > > >  string/string.h                                  | 16 ++++++++++++++++
> > > >  string/tester.c                                  | 16 ++++++++++++++++
> > > >  sysdeps/aarch64/memcmp.S                         |  2 ++
> > > >  sysdeps/csky/abiv2/memcmp.S                      |  1 +
> > > >  sysdeps/i386/i686/memcmp.S                       |  2 ++
> > > >  sysdeps/i386/i686/multiarch/memcmp.c             |  1 +
> > > >  sysdeps/i386/memcmp.S                            |  2 ++
> > > >  sysdeps/ia64/memcmp.S                            |  1 +
> > > >  sysdeps/mach/hurd/i386/libc.abilist              |  1 +
> > > >  sysdeps/powerpc/powerpc32/405/memcmp.S           |  1 +
> > > >  sysdeps/powerpc/powerpc32/power4/memcmp.S        |  1 +
> > > >  sysdeps/powerpc/powerpc32/power7/memcmp.S        |  1 +
> > > >  sysdeps/powerpc/powerpc64/le/power10/memcmp.S    |  1 +
> > > >  sysdeps/powerpc/powerpc64/power4/memcmp.S        |  1 +
> > > >  sysdeps/powerpc/powerpc64/power7/memcmp.S        |  1 +
> > > >  sysdeps/powerpc/powerpc64/power8/memcmp.S        |  1 +
> > > >  sysdeps/s390/memcmp-z900.S                       |  1 +
> > > >  sysdeps/s390/memcmp.c                            |  1 +
> > > >  sysdeps/sparc/sparc64/memcmp.S                   |  2 ++
> > > >  sysdeps/unix/sysv/linux/aarch64/libc.abilist     |  1 +
> > > >  sysdeps/unix/sysv/linux/alpha/libc.abilist       |  1 +
> > > >  sysdeps/unix/sysv/linux/arc/libc.abilist         |  1 +
> > > >  sysdeps/unix/sysv/linux/arm/be/libc.abilist      |  1 +
> > > >  sysdeps/unix/sysv/linux/arm/le/libc.abilist      |  1 +
> > > >  sysdeps/unix/sysv/linux/csky/libc.abilist        |  1 +
> > > >  sysdeps/unix/sysv/linux/hppa/libc.abilist        |  1 +
> > > >  sysdeps/unix/sysv/linux/i386/libc.abilist        |  1 +
> > > >  sysdeps/unix/sysv/linux/ia64/libc.abilist        |  1 +
> > > >  .../unix/sysv/linux/m68k/coldfire/libc.abilist   |  1 +
> > > >  sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist |  1 +
> > > >  .../unix/sysv/linux/microblaze/be/libc.abilist   |  1 +
> > > >  .../unix/sysv/linux/microblaze/le/libc.abilist   |  1 +
> > > >  .../unix/sysv/linux/mips/mips32/fpu/libc.abilist |  1 +
> > > >  .../sysv/linux/mips/mips32/nofpu/libc.abilist    |  1 +
> > > >  .../unix/sysv/linux/mips/mips64/n32/libc.abilist |  1 +
> > > >  .../unix/sysv/linux/mips/mips64/n64/libc.abilist |  1 +
> > > >  sysdeps/unix/sysv/linux/nios2/libc.abilist       |  1 +
> > > >  .../linux/powerpc/powerpc32/fpu/libc.abilist     |  1 +
> > > >  .../linux/powerpc/powerpc32/nofpu/libc.abilist   |  1 +
> > > >  .../sysv/linux/powerpc/powerpc64/be/libc.abilist |  1 +
> > > >  .../sysv/linux/powerpc/powerpc64/le/libc.abilist |  1 +
> > > >  sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist  |  1 +
> > > >  sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist  |  1 +
> > > >  .../unix/sysv/linux/s390/s390-32/libc.abilist    |  1 +
> > > >  .../unix/sysv/linux/s390/s390-64/libc.abilist    |  1 +
> > > >  sysdeps/unix/sysv/linux/sh/be/libc.abilist       |  1 +
> > > >  sysdeps/unix/sysv/linux/sh/le/libc.abilist       |  1 +
> > > >  .../unix/sysv/linux/sparc/sparc32/libc.abilist   |  1 +
> > > >  .../unix/sysv/linux/sparc/sparc64/libc.abilist   |  1 +
> > > >  sysdeps/unix/sysv/linux/x86_64/64/libc.abilist   |  1 +
> > > >  sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist  |  1 +
> > > >  sysdeps/x86_64/memcmp.S                          |  2 ++
> > > >  sysdeps/x86_64/multiarch/memcmp.c                |  2 ++
> > > >  55 files changed, 94 insertions(+)
> > > >
> > > > diff --git a/string/Versions b/string/Versions
> > > > index 298ecd401a..864c4cf7a4 100644
> > > > --- a/string/Versions
> > > > +++ b/string/Versions
> > > > @@ -89,4 +89,7 @@ libc {
> > > >      sigdescr_np; sigabbrev_np;
> > > >      strerrordesc_np; strerrorname_np;
> > > >    }
> > > > +  GLIBC_2.35 {
> > > > +    __memcmpeq;
> > > > +  }
> > > >  }
> > > > diff --git a/string/memcmp.c b/string/memcmp.c
> > > > index 9b46d7a905..5020be00e0 100644
> > > > --- a/string/memcmp.c
> > > > +++ b/string/memcmp.c
> > > > @@ -358,4 +358,6 @@ libc_hidden_builtin_def(memcmp)
> > > >  #ifdef weak_alias
> > > >  # undef bcmp
> > > >  weak_alias (memcmp, bcmp)
> > > > +# undef __memcmpeq
> > > > +weak_alias (memcmp, __memcmpeq)
> > > >  #endif
> > > > diff --git a/string/string.h b/string/string.h
> > > > index 04e1b7067d..d0b714f836 100644
> > > > --- a/string/string.h
> > > > +++ b/string/string.h
> > > > @@ -64,6 +64,22 @@ extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
> > > >  extern int memcmp (const void *__s1, const void *__s2, size_t __n)
> > > >       __THROW __attribute_pure__ __nonnull ((1, 2));
> > > >
> > > > +/* Compare N bytes of S1 and S2.  Return zero if S1 and S2 are equal.
> > > > +   Return some non-zero value otherwise.
> > > > +
> > > > +   Essentially __memcmpeq has the exact same semantics as memcmp
> > > > +   except the return value is less constrained.  memcmp is always a
> > > > +   correct implementation of __memcmpeq.  As well !!memcmp, -memcmp,
> > > > +   or bcmp are correct implementations.
> > > > +
> > > > +   __memcmpeq is meant to be used by compilers when memcmp return is
> > > > +   only used for its bolean value.
> > > > +
> > > > +   __memcmpeq is declared only for use by compilers.  Programs should
> > > > +   continue to use memcmp.  */
> > > > +extern int __memcmpeq (const void *__s1, const void *__s2, size_t __n)
> > > > +     __THROW __attribute_pure__ __nonnull ((1, 2));
> > >
> > > Please add an internal one in include/string.h so that it can be called
> > > within libc.so bypassing PLT.  Find one place in glibc where __memcmpeq
> > > can be used and use it.
> >
> > Usage outside of a test? It is currently used directly in string/tester.c
> >
>
> A standalone test, which can test all IFUNC implementations, is needed.

I added a test-memcmpeq.c file but it doesn't go through all the ifunc versions
available. I.e on x86_64 the output of test-memcmpeq.out is:

```
                        __memcmpeq simple_memcmp
```

whereas test-memcmp.out is:

```
                        simple_memcmp __memcmp_avx2_movbe
__memcmp_evex_movbe __memcmp_sse4_1 __memcmp_ssse3 __memcmp_sse2
```

Is there something else I need to be adding in addition to the
weak_alias / hidden def to run all of the ifunc variations?

>
> --
> H.J.

  reply	other threads:[~2021-10-21 21:04 UTC|newest]

Thread overview: 106+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-27 20:38 [PATCH v1] " Noah Goldstein
2021-09-27 20:43 ` Joseph Myers
2021-09-27 21:06   ` Noah Goldstein
2021-09-27 21:06 ` [PATCH v2] " Noah Goldstein
2021-09-27 21:52   ` Joseph Myers
2021-09-28  1:24     ` Noah Goldstein
2021-09-28  1:24 ` [PATCH v3] " Noah Goldstein
2021-09-28  8:15   ` Andreas Schwab
2021-09-28 16:47     ` Noah Goldstein
2021-09-28  8:40   ` Florian Weimer
2021-09-28 16:47     ` Noah Goldstein
2021-09-28 16:51       ` Florian Weimer
2021-09-28 16:46 ` [PATCH v4] " Noah Goldstein
2021-09-28 16:50 ` [PATCH v5] " Noah Goldstein
2021-09-28 16:53 ` [PATCH v6] " Noah Goldstein
2021-09-29  8:36   ` Florian Weimer
2021-09-29 15:17     ` Noah Goldstein
2021-09-29  8:52   ` Andreas Schwab
2021-09-29  9:18     ` Florian Weimer
2021-09-29  9:31       ` Andreas Schwab
2021-09-29  9:44         ` Florian Weimer
2021-09-28 16:57 ` [PATCH v1] " Noah Goldstein
2021-09-29 15:17 ` [PATCH v7] " Noah Goldstein
2021-09-30 19:31   ` Noah Goldstein
2021-10-11  2:33   ` Noah Goldstein
2021-10-18 14:47     ` Noah Goldstein
2021-10-21 19:28   ` H.J. Lu
2021-10-21 19:58     ` Noah Goldstein
2021-10-21 20:00       ` H.J. Lu
2021-10-21 21:04         ` Noah Goldstein [this message]
2021-10-21 20:02       ` Adhemerval Zanella
2021-10-21 20:23         ` Noah Goldstein
2021-10-21 20:26           ` Adhemerval Zanella
2021-10-21 19:33   ` Adhemerval Zanella
2021-10-21 20:01     ` Noah Goldstein
2021-10-21 20:06       ` Adhemerval Zanella
2021-10-21 21:18         ` Florian Weimer
2021-10-21 20:07       ` H.J. Lu
2021-10-21 20:11         ` Noah Goldstein
2021-10-21 22:38 ` [PATCH v8 1/3] " Noah Goldstein
2021-10-21 22:38   ` [PATCH v8 2/3] String: Add hidden defs for __memcmpeq() to enable internal usage Noah Goldstein
2021-10-21 22:52     ` H.J. Lu
2021-10-21 23:08       ` Joseph Myers
2021-10-21 23:10         ` H.J. Lu
2021-10-21 23:14           ` Joseph Myers
2021-10-21 23:39             ` Noah Goldstein
2021-10-21 23:45               ` Noah Goldstein
2021-10-22  0:19                 ` Joseph Myers
2021-10-22  0:40                   ` H.J. Lu
2021-10-25 16:41                     ` Joseph Myers
2021-10-22  0:18               ` Joseph Myers
2021-10-21 22:38   ` [PATCH v8 3/3] String: Add tests for __memcmpeq Noah Goldstein
2021-10-21 22:57     ` H.J. Lu
2021-10-21 23:47       ` Noah Goldstein
2021-10-22  0:41         ` H.J. Lu
2021-10-22  1:01           ` Noah Goldstein
2021-10-21 22:50   ` [PATCH v8 1/3] String: Add support for __memcmpeq() ABI on all targets H.J. Lu
2021-10-21 23:42     ` Noah Goldstein
2021-10-22  2:38       ` H.J. Lu
2021-10-22  4:04         ` Noah Goldstein
2021-10-22  5:49 ` [PATCH v9 " Noah Goldstein
2021-10-22 12:38   ` H.J. Lu
2021-10-22 16:07     ` Noah Goldstein
2021-10-22 17:19   ` Noah Goldstein
2021-10-22 17:40     ` Noah Goldstein
2021-10-22 17:44       ` H.J. Lu
2021-10-22 18:09         ` Noah Goldstein
2021-10-22 18:33           ` H.J. Lu
2021-10-22  5:49 ` [PATCH v9 2/3] String: Add hidden defs for __memcmpeq() to enable internal usage Noah Goldstein
2021-10-22 12:44   ` H.J. Lu
2021-10-22  5:49 ` [PATCH v9 3/3] String: Add tests for __memcmpeq Noah Goldstein
2021-10-22 12:42   ` H.J. Lu
2021-10-22 16:06 ` [PATCH v10 1/4] String: Add support for __memcmpeq() ABI on all targets Noah Goldstein
2021-10-22 16:06   ` [PATCH v10 2/4] String: Add hidden defs for __memcmpeq() to enable internal usage Noah Goldstein
2021-10-22 16:06   ` [PATCH v10 3/4] String: Add tests for __memcmpeq Noah Goldstein
2021-10-22 16:06   ` [PATCH v10 4/4] NEWS: Add item " Noah Goldstein
2021-10-22 16:12     ` H.J. Lu
2021-10-22 16:12   ` [PATCH v10 1/4] String: Add support for __memcmpeq() ABI on all targets H.J. Lu
2021-10-22 16:18     ` Noah Goldstein
2021-10-22 18:37 ` [PATCH v11 " Noah Goldstein
2021-10-22 18:37 ` [PATCH v11 2/4] String: Add hidden defs for __memcmpeq() to enable internal usage Noah Goldstein
2021-10-22 18:37 ` [PATCH v11 3/4] String: Add tests for __memcmpeq Noah Goldstein
2021-10-22 18:37 ` [PATCH v11 4/4] NEWS: Add item " Noah Goldstein
2021-10-22 19:46 ` [PATCH v12 1/4] String: Add support for __memcmpeq() ABI on all targets Noah Goldstein
2021-10-22 19:46   ` [PATCH v12 2/4] String: Add hidden defs for __memcmpeq() to enable internal usage Noah Goldstein
2021-10-22 19:46   ` [PATCH v12 3/4] String: Add tests for __memcmpeq Noah Goldstein
2021-10-22 19:46   ` [PATCH v12 4/4] NEWS: Add item " Noah Goldstein
2021-10-22 20:28   ` [PATCH v12 1/4] String: Add support for __memcmpeq() ABI on all targets H.J. Lu
2021-10-22 20:33     ` Noah Goldstein
2021-10-22 20:45       ` H.J. Lu
2021-10-22 21:24         ` Noah Goldstein
2021-10-22 21:23 ` [PATCH v13 " Noah Goldstein
2021-10-22 21:23   ` [PATCH v13 2/4] String: Add hidden defs for __memcmpeq() to enable internal usage Noah Goldstein
2021-10-22 21:23   ` [PATCH v13 3/4] String: Add tests for __memcmpeq Noah Goldstein
2021-10-22 21:23   ` [PATCH v13 4/4] NEWS: Add item " Noah Goldstein
2021-10-23 23:23   ` [PATCH v13 1/4] String: Add support for __memcmpeq() ABI on all targets Noah Goldstein
2021-10-23 23:24 ` [PATCH v14 " Noah Goldstein
2021-10-23 23:24   ` [PATCH v14 2/4] String: Add hidden defs for __memcmpeq() to enable internal usage Noah Goldstein
2021-10-26 18:56     ` H.J. Lu
2021-10-23 23:24   ` [PATCH v14 3/4] String: Add tests for __memcmpeq Noah Goldstein
2021-10-26 18:57     ` H.J. Lu
2021-10-23 23:24   ` [PATCH v14 4/4] NEWS: Add item " Noah Goldstein
2021-10-26 18:58     ` H.J. Lu
2021-10-25  2:45   ` [PATCH v14 1/4] String: Add support for __memcmpeq() ABI on all targets Noah Goldstein
2021-10-26 18:55   ` H.J. Lu
2021-10-26 22:29     ` 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='CAFUsyfKqhsONLtDYarOGB6oW5XeY3GvhWHTFKfNq30A5PCpC=w@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).