public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v3] string: Add support for __memsetzero on all targets
@ 2022-02-14 19:08 H.J. Lu
  2022-02-14 23:56 ` Noah Goldstein
  0 siblings, 1 reply; 3+ messages in thread
From: H.J. Lu @ 2022-02-14 19:08 UTC (permalink / raw)
  To: libc-alpha

Changes in v3:

1. Change __memsetzero to return "void *", instead of "void", so that
compiler can replace all memset calls with 0 input with __memsetzero.
2. Add memsetzero.c to implement the generic __memsetzero.
3. x86-64: Replace IFUNC bzero with IFUNC __memsetzero and make bzero
an alias of __memsetzero.

---
To optimize for data erase, add

void *__memsetzero (void *s, size_t n);

with the default implementation:

void *
__memsetzero (void *s, size_t len)
{
  return memset (s, '\0', len);
}

If __memsetzero is available, compilers can generate call to __memsetzero
to erase data, instead of memset.

Tested with build-many-glibcs.py and natively on x86-64, x32 and i686.
---
 NEWS                                          |  3 +-
 include/string.h                              |  1 +
 string/Makefile                               |  2 +
 string/Versions                               |  3 ++
 string/memsetzero.c                           | 27 ++++++++++++
 string/string.h                               |  3 ++
 string/test-memset.c                          | 27 +++++++++++-
 string/test-memsetzero.c                      | 19 ++++++++
 sysdeps/mach/hurd/i386/libc.abilist           |  1 +
 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 +
 .../sysv/linux/m68k/coldfire/libc.abilist     |  1 +
 .../unix/sysv/linux/m68k/m680x0/libc.abilist  |  1 +
 .../sysv/linux/microblaze/be/libc.abilist     |  1 +
 .../sysv/linux/microblaze/le/libc.abilist     |  1 +
 .../sysv/linux/mips/mips32/fpu/libc.abilist   |  1 +
 .../sysv/linux/mips/mips32/nofpu/libc.abilist |  1 +
 .../sysv/linux/mips/mips64/n32/libc.abilist   |  1 +
 .../sysv/linux/mips/mips64/n64/libc.abilist   |  1 +
 sysdeps/unix/sysv/linux/nios2/libc.abilist    |  1 +
 sysdeps/unix/sysv/linux/or1k/libc.abilist     |  1 +
 .../linux/powerpc/powerpc32/fpu/libc.abilist  |  1 +
 .../powerpc/powerpc32/nofpu/libc.abilist      |  1 +
 .../linux/powerpc/powerpc64/be/libc.abilist   |  1 +
 .../linux/powerpc/powerpc64/le/libc.abilist   |  1 +
 .../unix/sysv/linux/riscv/rv32/libc.abilist   |  1 +
 .../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 +
 .../sysv/linux/sparc/sparc32/libc.abilist     |  1 +
 .../sysv/linux/sparc/sparc64/libc.abilist     |  1 +
 .../unix/sysv/linux/x86_64/64/libc.abilist    |  1 +
 .../unix/sysv/linux/x86_64/x32/libc.abilist   |  1 +
 sysdeps/x86_64/memset.S                       | 11 ++---
 sysdeps/x86_64/memsetzero.S                   |  1 +
 sysdeps/x86_64/multiarch/Makefile             |  1 -
 sysdeps/x86_64/multiarch/ifunc-impl-list.c    | 44 +++++++++----------
 .../memset-avx2-unaligned-erms-rtm.S          |  2 +-
 .../multiarch/memset-avx2-unaligned-erms.S    |  6 +--
 .../multiarch/memset-avx512-unaligned-erms.S  |  2 +-
 .../multiarch/memset-evex-unaligned-erms.S    |  2 +-
 .../multiarch/memset-sse2-unaligned-erms.S    |  2 +-
 .../multiarch/memset-vec-unaligned-erms.S     | 22 +++++-----
 .../multiarch/{bzero.c => memsetzero.c}       | 22 +++++++---
 53 files changed, 180 insertions(+), 54 deletions(-)
 create mode 100644 string/memsetzero.c
 create mode 100644 string/test-memsetzero.c
 create mode 100644 sysdeps/x86_64/memsetzero.S
 rename sysdeps/x86_64/multiarch/{bzero.c => memsetzero.c} (85%)

diff --git a/NEWS b/NEWS
index 626eeabf5d..ae66e4146e 100644
--- a/NEWS
+++ b/NEWS
@@ -9,7 +9,8 @@ Version 2.36
 
 Major new features:
 
-  [Add new features here]
+* ABI support for a new function '__memsetzero'. '__memsetzero' is meant
+  to be used by compilers to erase data.
 
 Deprecated and removed features, and other changes affecting compatibility:
 
diff --git a/include/string.h b/include/string.h
index 21f641a413..608928ac65 100644
--- a/include/string.h
+++ b/include/string.h
@@ -113,6 +113,7 @@ libc_hidden_proto (__strsep_g)
 libc_hidden_proto (strnlen)
 libc_hidden_proto (__strnlen)
 libc_hidden_proto (__memcmpeq)
+libc_hidden_proto (__memsetzero)
 libc_hidden_proto (memmem)
 extern __typeof (memmem) __memmem;
 libc_hidden_proto (__memmem)
diff --git a/string/Makefile b/string/Makefile
index 641e062bbb..c5b0c329c5 100644
--- a/string/Makefile
+++ b/string/Makefile
@@ -69,6 +69,7 @@ routines := \
   mempcpy \
   memrchr \
   memset \
+  memsetzero \
   rawmemchr \
   sigabbrev_np \
   sigdescr_np \
@@ -145,6 +146,7 @@ tests := \
   test-mempcpy \
   test-memrchr \
   test-memset \
+  test-memsetzero \
   test-rawmemchr \
   test-sig_np \
   test-stpcpy \
diff --git a/string/Versions b/string/Versions
index 864c4cf7a4..0abd7262c5 100644
--- a/string/Versions
+++ b/string/Versions
@@ -92,4 +92,7 @@ libc {
   GLIBC_2.35 {
     __memcmpeq;
   }
+  GLIBC_2.36 {
+    __memsetzero;
+  }
 }
diff --git a/string/memsetzero.c b/string/memsetzero.c
new file mode 100644
index 0000000000..8a7f6b82ec
--- /dev/null
+++ b/string/memsetzero.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 2022 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <string.h>
+
+/* Set N bytes of S to 0.  */
+void *
+__memsetzero (void *s, size_t len)
+{
+  return memset (s, '\0', len);
+}
+
+libc_hidden_def (__memsetzero)
diff --git a/string/string.h b/string/string.h
index d494a1d5f9..559f421268 100644
--- a/string/string.h
+++ b/string/string.h
@@ -60,6 +60,9 @@ extern void *memccpy (void *__restrict __dest, const void *__restrict __src,
 /* Set N bytes of S to C.  */
 extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
 
+/* Set N bytes of S to 0.  */
+extern void *__memsetzero (void *__s, size_t __n) __THROW __nonnull ((1));
+
 /* Compare N bytes of S1 and S2.  */
 extern int memcmp (const void *__s1, const void *__s2, size_t __n)
      __THROW __attribute_pure__ __nonnull ((1, 2));
diff --git a/string/test-memset.c b/string/test-memset.c
index 8498b1bc97..6d0ec57447 100644
--- a/string/test-memset.c
+++ b/string/test-memset.c
@@ -23,6 +23,8 @@
 # else
 #  define TEST_NAME "bzero"
 # endif
+#elif defined TEST_MEMSETZERO
+# define TEST_NAME "__memsetzero"
 #else
 # ifndef WIDE
 #  define TEST_NAME "memset"
@@ -76,6 +78,17 @@ builtin_bzero (char *s, size_t n)
 {
   __builtin_bzero (s, n);
 }
+#elif defined TEST_MEMSETZERO
+typedef void *(*proto_t) (char *, size_t);
+
+void *
+simple_memsetzero (char *s, size_t n)
+{
+  return SIMPLE_MEMSET (s, 0, n);
+}
+
+IMPL (__memsetzero, 1)
+IMPL (simple_memsetzero, 0)
 #else
 typedef CHAR *(*proto_t) (CHAR *, int, size_t);
 
@@ -120,7 +133,11 @@ do_one_test (impl_t *impl, CHAR *s, int c __attribute ((unused)), size_t n)
       || buf[0] != sentinel
       || buf[n + 1] != sentinel)
 #else
+# ifdef TEST_MEMSETZERO
+  CHAR *res = CALL (impl, s, n);
+# else
   CHAR *res = CALL (impl, s, c, n);
+# endif
   if (res != s
       || SIMPLE_MEMSET (tstbuf, c, n) != tstbuf
       || MEMCMP (s, tstbuf, n) != 0
@@ -170,10 +187,14 @@ do_random_tests (void)
 	align = size - len;
       if ((random () & 7) == 0)
 	align &= ~63;
+# ifdef TEST_MEMSETZERO
+      c = 0;
+# else
       if ((random () & 7) == 0)
 	c = 0;
       else
 	c = random () & BIG_CHAR;
+# endif
       o = random () & BIG_CHAR;
       if (o == c)
 	o = (c + 1) & BIG_CHAR;
@@ -197,7 +218,11 @@ do_random_tests (void)
 	      if (p[i + align] == c)
 		p[i + align] = o;
 	    }
+# ifdef TEST_MEMSETZERO
+	  res = (UCHAR *) CALL (impl, (CHAR *) p + align, len);
+# else
 	  res = (UCHAR *) CALL (impl, (CHAR *) p + align, c, len);
+# endif
 	  if (res != p + align)
 	    {
 	      error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %d, %zd) %p != %p",
@@ -246,7 +271,7 @@ test_main (void)
     printf ("\t%s", impl->name);
   putchar ('\n');
 
-#ifndef TEST_BZERO
+#if !defined TEST_BZERO && !defined TEST_MEMSETZERO
   for (c = -65; c <= 130; c += 65)
 #endif
     {
diff --git a/string/test-memsetzero.c b/string/test-memsetzero.c
new file mode 100644
index 0000000000..074501065f
--- /dev/null
+++ b/string/test-memsetzero.c
@@ -0,0 +1,19 @@
+/* Test and measure __memsetzero functions.
+   Copyright (C) 2022 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+#define TEST_MEMSETZERO
+#include "test-memset.c"
diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist
index 4dc87e9061..9a39a5c342 100644
--- a/sysdeps/mach/hurd/i386/libc.abilist
+++ b/sysdeps/mach/hurd/i386/libc.abilist
@@ -2289,6 +2289,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 close_range F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
index 1b63d9e447..68b86b22c9 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
@@ -2616,3 +2616,4 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
index e7e4cf7d2a..1714ca23fe 100644
--- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
@@ -2713,6 +2713,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/arc/libc.abilist b/sysdeps/unix/sysv/linux/arc/libc.abilist
index bc3d228e31..8891587282 100644
--- a/sysdeps/unix/sysv/linux/arc/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arc/libc.abilist
@@ -2377,3 +2377,4 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
index db7039c4ab..4adeec6ca6 100644
--- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
@@ -496,6 +496,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
 GLIBC_2.4 _Exit F
 GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
 GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
index d2add4fb49..1b2573e690 100644
--- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
@@ -493,6 +493,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
 GLIBC_2.4 _Exit F
 GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
 GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist
index 355d72a30c..f3dab9746f 100644
--- a/sysdeps/unix/sysv/linux/csky/libc.abilist
+++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
@@ -2652,3 +2652,4 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
index 3df39bb28c..21e22081fe 100644
--- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
@@ -2601,6 +2601,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
index c4da358f80..43b37f2ef1 100644
--- a/sysdeps/unix/sysv/linux/i386/libc.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
@@ -2785,6 +2785,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist
index 241bac70ea..2ee6184fab 100644
--- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
@@ -2551,6 +2551,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
index 78bf372b72..fc43c9d49c 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
@@ -497,6 +497,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
 GLIBC_2.4 _Exit F
 GLIBC_2.4 _IO_2_1_stderr_ D 0x98
 GLIBC_2.4 _IO_2_1_stdin_ D 0x98
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
index 00df5c901f..f0e94f92bd 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
@@ -2728,6 +2728,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
index e8118569c3..7b309378da 100644
--- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
@@ -2701,3 +2701,4 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
index c0d2373e64..6d414b32dc 100644
--- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
@@ -2698,3 +2698,4 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
index 2d0fd04f54..0c12abffa1 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
@@ -2693,6 +2693,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
index e39ccfb312..1876d86269 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
@@ -2691,6 +2691,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
index 1e900f86e4..301941d0cc 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
@@ -2699,6 +2699,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
index 9145ba7931..906491a531 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
@@ -2602,6 +2602,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
index e95d60d926..13b9299c87 100644
--- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
@@ -2740,3 +2740,4 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
diff --git a/sysdeps/unix/sysv/linux/or1k/libc.abilist b/sysdeps/unix/sysv/linux/or1k/libc.abilist
index ca934e374b..3cc2db60a5 100644
--- a/sysdeps/unix/sysv/linux/or1k/libc.abilist
+++ b/sysdeps/unix/sysv/linux/or1k/libc.abilist
@@ -2123,3 +2123,4 @@ GLIBC_2.35 wprintf F
 GLIBC_2.35 write F
 GLIBC_2.35 writev F
 GLIBC_2.35 wscanf F
+GLIBC_2.36 __memsetzero F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
index 3820b9f235..fab9acf53f 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
@@ -2755,6 +2755,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
index 464dc27fcd..fd2d98b1e6 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
@@ -2788,6 +2788,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
index 2f7e58747f..24b8f2ad81 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
@@ -2510,6 +2510,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
index 4f3043d913..50a36c4e52 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
@@ -2812,3 +2812,4 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
index 84b6ac815a..da5f3f83e0 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
@@ -2379,3 +2379,4 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
index 4d5c19c56a..f8477073b2 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
@@ -2579,3 +2579,4 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
index 7c5ee8d569..92a70e2473 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
@@ -2753,6 +2753,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
index 50de0b46cf..8dfb6ccdc5 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
@@ -2547,6 +2547,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
index 66fba013ca..3c7c4b79d6 100644
--- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
@@ -2608,6 +2608,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
index 38703f8aa0..48b4993fb6 100644
--- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
@@ -2605,6 +2605,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
index 6df55eb765..011b7cda7e 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
@@ -2748,6 +2748,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
index b90569d881..b1156d801e 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
@@ -2574,6 +2574,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
index e88b0f101f..d7c7667768 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
@@ -2525,6 +2525,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
index e0755272eb..67619a0d9a 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
@@ -2631,3 +2631,4 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 __memsetzero F
diff --git a/sysdeps/x86_64/memset.S b/sysdeps/x86_64/memset.S
index af26e9cedc..d1ed63c554 100644
--- a/sysdeps/x86_64/memset.S
+++ b/sysdeps/x86_64/memset.S
@@ -1,4 +1,4 @@
-/* memset/bzero -- set memory area to CH/0
+/* memset/__memsetzero -- set memory area to CH/0
    Optimized version for x86-64.
    Copyright (C) 2002-2022 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
@@ -35,7 +35,7 @@
   punpcklwd %xmm0, %xmm0; \
   pshufd $0, %xmm0, %xmm0
 
-# define BZERO_ZERO_VEC0() \
+# define MEMSETZERO_ZERO_VEC0() \
   pxor %xmm0, %xmm0
 
 # define WMEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
@@ -56,8 +56,8 @@
 # define MEMSET_SYMBOL(p,s)	memset
 #endif
 
-#ifndef BZERO_SYMBOL
-# define BZERO_SYMBOL(p,s)	__bzero
+#ifndef MEMSETZERO_SYMBOL
+# define MEMSETZERO_SYMBOL(p,s)	__memsetzero
 #endif
 
 #ifndef WMEMSET_SYMBOL
@@ -70,7 +70,8 @@
 libc_hidden_builtin_def (memset)
 
 #if IS_IN (libc)
-weak_alias (__bzero, bzero)
+weak_alias (__memsetzero, bzero)
+strong_alias (__memsetzero, __bzero)
 libc_hidden_def (__wmemset)
 weak_alias (__wmemset, wmemset)
 libc_hidden_weak (wmemset)
diff --git a/sysdeps/x86_64/memsetzero.S b/sysdeps/x86_64/memsetzero.S
new file mode 100644
index 0000000000..f96d567fd8
--- /dev/null
+++ b/sysdeps/x86_64/memsetzero.S
@@ -0,0 +1 @@
+/* Implemented in memset.S.  */
diff --git a/sysdeps/x86_64/multiarch/Makefile b/sysdeps/x86_64/multiarch/Makefile
index e7b413edad..4274bfdd0d 100644
--- a/sysdeps/x86_64/multiarch/Makefile
+++ b/sysdeps/x86_64/multiarch/Makefile
@@ -1,7 +1,6 @@
 ifeq ($(subdir),string)
 
 sysdep_routines += \
-  bzero \
   memchr-avx2 \
   memchr-avx2-rtm \
   memchr-evex \
diff --git a/sysdeps/x86_64/multiarch/ifunc-impl-list.c b/sysdeps/x86_64/multiarch/ifunc-impl-list.c
index a594f4176e..2144cf58c0 100644
--- a/sysdeps/x86_64/multiarch/ifunc-impl-list.c
+++ b/sysdeps/x86_64/multiarch/ifunc-impl-list.c
@@ -300,46 +300,46 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
 			      __memset_avx512_no_vzeroupper)
 	     )
 
-  /* Support sysdeps/x86_64/multiarch/bzero.c.  */
-  IFUNC_IMPL (i, name, bzero,
-	      IFUNC_IMPL_ADD (array, i, bzero, 1,
-			      __bzero_sse2_unaligned)
-	      IFUNC_IMPL_ADD (array, i, bzero, 1,
-			      __bzero_sse2_unaligned_erms)
-	      IFUNC_IMPL_ADD (array, i, bzero,
+  /* Support sysdeps/x86_64/multiarch/memsetzero.c.  */
+  IFUNC_IMPL (i, name, __memsetzero,
+	      IFUNC_IMPL_ADD (array, i, __memsetzero, 1,
+			      __memsetzero_sse2_unaligned)
+	      IFUNC_IMPL_ADD (array, i, __memsetzero, 1,
+			      __memsetzero_sse2_unaligned_erms)
+	      IFUNC_IMPL_ADD (array, i, __memsetzero,
 			      CPU_FEATURE_USABLE (AVX2),
-			      __bzero_avx2_unaligned)
-	      IFUNC_IMPL_ADD (array, i, bzero,
+			      __memsetzero_avx2_unaligned)
+	      IFUNC_IMPL_ADD (array, i, __memsetzero,
 			      CPU_FEATURE_USABLE (AVX2),
-			      __bzero_avx2_unaligned_erms)
-	      IFUNC_IMPL_ADD (array, i, bzero,
+			      __memsetzero_avx2_unaligned_erms)
+	      IFUNC_IMPL_ADD (array, i, __memsetzero,
 			      (CPU_FEATURE_USABLE (AVX2)
 			       && CPU_FEATURE_USABLE (RTM)),
-			      __bzero_avx2_unaligned_rtm)
-	      IFUNC_IMPL_ADD (array, i, bzero,
+			      __memsetzero_avx2_unaligned_rtm)
+	      IFUNC_IMPL_ADD (array, i, __memsetzero,
 			      (CPU_FEATURE_USABLE (AVX2)
 			       && CPU_FEATURE_USABLE (RTM)),
-			      __bzero_avx2_unaligned_erms_rtm)
-	      IFUNC_IMPL_ADD (array, i, bzero,
+			      __memsetzero_avx2_unaligned_erms_rtm)
+	      IFUNC_IMPL_ADD (array, i, __memsetzero,
 			      (CPU_FEATURE_USABLE (AVX512VL)
 			       && CPU_FEATURE_USABLE (AVX512BW)
 			       && CPU_FEATURE_USABLE (BMI2)),
-			      __bzero_evex_unaligned)
-	      IFUNC_IMPL_ADD (array, i, bzero,
+			      __memsetzero_evex_unaligned)
+	      IFUNC_IMPL_ADD (array, i, __memsetzero,
 			      (CPU_FEATURE_USABLE (AVX512VL)
 			       && CPU_FEATURE_USABLE (AVX512BW)
 			       && CPU_FEATURE_USABLE (BMI2)),
-			      __bzero_evex_unaligned_erms)
-	      IFUNC_IMPL_ADD (array, i, bzero,
+			      __memsetzero_evex_unaligned_erms)
+	      IFUNC_IMPL_ADD (array, i, __memsetzero,
 			      (CPU_FEATURE_USABLE (AVX512VL)
 			       && CPU_FEATURE_USABLE (AVX512BW)
 			       && CPU_FEATURE_USABLE (BMI2)),
-			      __bzero_avx512_unaligned_erms)
-	      IFUNC_IMPL_ADD (array, i, bzero,
+			      __memsetzero_avx512_unaligned_erms)
+	      IFUNC_IMPL_ADD (array, i, __memsetzero,
 			      (CPU_FEATURE_USABLE (AVX512VL)
 			       && CPU_FEATURE_USABLE (AVX512BW)
 			       && CPU_FEATURE_USABLE (BMI2)),
-			      __bzero_avx512_unaligned)
+			      __memsetzero_avx512_unaligned)
 	     )
 
   /* Support sysdeps/x86_64/multiarch/rawmemchr.c.  */
diff --git a/sysdeps/x86_64/multiarch/memset-avx2-unaligned-erms-rtm.S b/sysdeps/x86_64/multiarch/memset-avx2-unaligned-erms-rtm.S
index 5a5ee6f672..a3da136a09 100644
--- a/sysdeps/x86_64/multiarch/memset-avx2-unaligned-erms-rtm.S
+++ b/sysdeps/x86_64/multiarch/memset-avx2-unaligned-erms-rtm.S
@@ -5,7 +5,7 @@
 
 #define SECTION(p) p##.avx.rtm
 #define MEMSET_SYMBOL(p,s)	p##_avx2_##s##_rtm
-#define BZERO_SYMBOL(p,s)	p##_avx2_##s##_rtm
+#define MEMSETZERO_SYMBOL(p,s)	p##_avx2_##s##_rtm
 #define WMEMSET_SYMBOL(p,s)	p##_avx2_##s##_rtm
 
 #include "memset-avx2-unaligned-erms.S"
diff --git a/sysdeps/x86_64/multiarch/memset-avx2-unaligned-erms.S b/sysdeps/x86_64/multiarch/memset-avx2-unaligned-erms.S
index a093a2831f..7df4c7ae7c 100644
--- a/sysdeps/x86_64/multiarch/memset-avx2-unaligned-erms.S
+++ b/sysdeps/x86_64/multiarch/memset-avx2-unaligned-erms.S
@@ -14,7 +14,7 @@
   vmovd d, %xmm0; \
   movq r, %rax;
 
-# define BZERO_ZERO_VEC0() \
+# define MEMSETZERO_ZERO_VEC0() \
   vpxor %xmm0, %xmm0, %xmm0
 
 # define WMEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
@@ -32,8 +32,8 @@
 # ifndef MEMSET_SYMBOL
 #  define MEMSET_SYMBOL(p,s)	p##_avx2_##s
 # endif
-# ifndef BZERO_SYMBOL
-#  define BZERO_SYMBOL(p,s)	p##_avx2_##s
+# ifndef MEMSETZERO_SYMBOL
+#  define MEMSETZERO_SYMBOL(p,s) p##_avx2_##s
 # endif
 # ifndef WMEMSET_SYMBOL
 #  define WMEMSET_SYMBOL(p,s)	p##_avx2_##s
diff --git a/sysdeps/x86_64/multiarch/memset-avx512-unaligned-erms.S b/sysdeps/x86_64/multiarch/memset-avx512-unaligned-erms.S
index 727c92133a..cf0f27424c 100644
--- a/sysdeps/x86_64/multiarch/memset-avx512-unaligned-erms.S
+++ b/sysdeps/x86_64/multiarch/memset-avx512-unaligned-erms.S
@@ -19,7 +19,7 @@
   vpbroadcastb d, %VEC0; \
   movq r, %rax
 
-# define BZERO_ZERO_VEC0() \
+# define MEMSETZERO_ZERO_VEC0() \
   vpxorq %XMM0, %XMM0, %XMM0
 
 # define WMEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
diff --git a/sysdeps/x86_64/multiarch/memset-evex-unaligned-erms.S b/sysdeps/x86_64/multiarch/memset-evex-unaligned-erms.S
index 5d8fa78f05..96ffa0a29e 100644
--- a/sysdeps/x86_64/multiarch/memset-evex-unaligned-erms.S
+++ b/sysdeps/x86_64/multiarch/memset-evex-unaligned-erms.S
@@ -19,7 +19,7 @@
   vpbroadcastb d, %VEC0; \
   movq r, %rax
 
-# define BZERO_ZERO_VEC0() \
+# define MEMSETZERO_ZERO_VEC0() \
   vpxorq %XMM0, %XMM0, %XMM0
 
 # define WMEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
diff --git a/sysdeps/x86_64/multiarch/memset-sse2-unaligned-erms.S b/sysdeps/x86_64/multiarch/memset-sse2-unaligned-erms.S
index 329c58ee46..eb1f5a4928 100644
--- a/sysdeps/x86_64/multiarch/memset-sse2-unaligned-erms.S
+++ b/sysdeps/x86_64/multiarch/memset-sse2-unaligned-erms.S
@@ -22,7 +22,7 @@
 
 #if IS_IN (libc)
 # define MEMSET_SYMBOL(p,s)	p##_sse2_##s
-# define BZERO_SYMBOL(p,s)	MEMSET_SYMBOL (p, s)
+# define MEMSETZERO_SYMBOL(p,s)	MEMSET_SYMBOL (p, s)
 # define WMEMSET_SYMBOL(p,s)	p##_sse2_##s
 
 # ifdef SHARED
diff --git a/sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S b/sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
index 785fee1d57..3db1b3f7d5 100644
--- a/sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
+++ b/sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
@@ -1,4 +1,4 @@
-/* memset/bzero with unaligned store and rep stosb
+/* memset/__memsetzero with unaligned store and rep stosb
    Copyright (C) 2016-2022 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -26,8 +26,8 @@
 
 #include <sysdep.h>
 
-#ifndef BZERO_SYMBOL
-# define BZERO_SYMBOL(p,s)		MEMSET_SYMBOL (p, s)
+#ifndef MEMSETZERO_SYMBOL
+# define MEMSETZERO_SYMBOL(p,s)		MEMSET_SYMBOL (p, s)
 #endif
 
 #ifndef MEMSET_CHK_SYMBOL
@@ -134,9 +134,9 @@ ENTRY (WMEMSET_SYMBOL (__wmemset, unaligned))
 END (WMEMSET_SYMBOL (__wmemset, unaligned))
 #endif
 
-ENTRY (BZERO_SYMBOL(__bzero, unaligned))
+ENTRY (MEMSETZERO_SYMBOL(__memsetzero, unaligned))
 #if VEC_SIZE > 16
-	BZERO_ZERO_VEC0 ()
+	MEMSETZERO_ZERO_VEC0 ()
 #endif
 	mov	%RDI_LP, %RAX_LP
 	mov	%RSI_LP, %RDX_LP
@@ -149,7 +149,7 @@ ENTRY (BZERO_SYMBOL(__bzero, unaligned))
 	xorl	%esi, %esi
 #endif
 #if VEC_SIZE <= 16
-	BZERO_ZERO_VEC0 ()
+	MEMSETZERO_ZERO_VEC0 ()
 #endif
 	cmp	$(VEC_SIZE * 2), %RDX_LP
 	ja	L(more_2x_vec)
@@ -157,7 +157,7 @@ ENTRY (BZERO_SYMBOL(__bzero, unaligned))
 	VMOVU	%VEC(0), (%rdi)
 	VMOVU	%VEC(0), (VEC_SIZE * -1)(%rdi, %rdx)
 	VZEROUPPER_RETURN
-END (BZERO_SYMBOL(__bzero, unaligned))
+END (MEMSETZERO_SYMBOL(__memsetzero, unaligned))
 
 #if defined SHARED && IS_IN (libc)
 ENTRY_CHK (MEMSET_CHK_SYMBOL (__memset_chk, unaligned))
@@ -216,9 +216,9 @@ END (__memset_erms)
 END (MEMSET_SYMBOL (__memset, erms))
 # endif
 
-ENTRY_P2ALIGN (BZERO_SYMBOL(__bzero, unaligned_erms), 6)
+ENTRY_P2ALIGN (MEMSETZERO_SYMBOL(__memsetzero, unaligned_erms), 6)
 # if VEC_SIZE > 16
-	BZERO_ZERO_VEC0 ()
+	MEMSETZERO_ZERO_VEC0 ()
 # endif
 	mov	%RDI_LP, %RAX_LP
 	mov	%RSI_LP, %RDX_LP
@@ -231,7 +231,7 @@ ENTRY_P2ALIGN (BZERO_SYMBOL(__bzero, unaligned_erms), 6)
 	xorl	%esi, %esi
 # endif
 # if VEC_SIZE <= 16
-	BZERO_ZERO_VEC0 ()
+	MEMSETZERO_ZERO_VEC0 ()
 # endif
 	cmp	$(VEC_SIZE * 2), %RDX_LP
 	ja	L(stosb_more_2x_vec)
@@ -239,7 +239,7 @@ ENTRY_P2ALIGN (BZERO_SYMBOL(__bzero, unaligned_erms), 6)
 	VMOVU	%VEC(0), (%rdi)
 	VMOVU	%VEC(0), (VEC_SIZE * -1)(%rdi, %rdx)
 	VZEROUPPER_RETURN
-END (BZERO_SYMBOL(__bzero, unaligned_erms))
+END (MEMSETZERO_SYMBOL(__memsetzero, unaligned_erms))
 
 # if defined SHARED && IS_IN (libc)
 ENTRY_CHK (MEMSET_CHK_SYMBOL (__memset_chk, unaligned_erms))
diff --git a/sysdeps/x86_64/multiarch/bzero.c b/sysdeps/x86_64/multiarch/memsetzero.c
similarity index 85%
rename from sysdeps/x86_64/multiarch/bzero.c
rename to sysdeps/x86_64/multiarch/memsetzero.c
index 58a14b2c33..ae4f0209fc 100644
--- a/sysdeps/x86_64/multiarch/bzero.c
+++ b/sysdeps/x86_64/multiarch/memsetzero.c
@@ -1,4 +1,4 @@
-/* Multiple versions of bzero.
+/* Multiple versions of __memsetzero.
    All versions must be listed in ifunc-impl-list.c.
    Copyright (C) 2022 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
@@ -19,11 +19,11 @@
 
 /* Define multiple versions only for the definition in libc.  */
 #if IS_IN (libc)
-# define __bzero __redirect___bzero
+# define __memsetzero __redirect___memsetzero
 # include <string.h>
-# undef __bzero
+# undef __memsetzero
 
-# define SYMBOL_NAME __bzero
+# define SYMBOL_NAME __memsetzero
 # include <init-arch.h>
 
 extern __typeof (REDIRECT_NAME) OPTIMIZE1 (sse2_unaligned)
@@ -100,7 +100,17 @@ IFUNC_SELECTOR (void)
   return OPTIMIZE1 (sse2_unaligned);
 }
 
-libc_ifunc_redirected (__redirect___bzero, __bzero, IFUNC_SELECTOR ());
+libc_ifunc_redirected (__redirect___memsetzero, __memsetzero,
+		       IFUNC_SELECTOR ());
 
-weak_alias (__bzero, bzero)
+/* NB: bzero returns void and __memsetzero returns void *.  */
+asm (".weak bzero");
+asm ("bzero = __memsetzero");
+asm (".global __bzero");
+asm ("__bzero = __memsetzero");
+
+# ifdef SHARED
+__hidden_ver1 (__memsetzero, __GI___memsetzero, __redirect___memsetzero)
+  __attribute__ ((visibility ("hidden"))) __attribute_copy__ (__memsetzero);
+# endif
 #endif
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-02-15  0:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-14 19:08 [PATCH v3] string: Add support for __memsetzero on all targets H.J. Lu
2022-02-14 23:56 ` Noah Goldstein
2022-02-15  0:01   ` H.J. Lu

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).