@@ -14,7 +14,14 @@ sysdep_noprof += _mcount
endif
ifeq ($(subdir),string)
-sysdep_routines += strcasecmp_l-nonascii strncase_l-nonascii
+sysdep_routines += \
+ strcasecmp_l-nonascii \
+ strcspn-generic \
+ strncase_l-nonascii \
+ strpbrk-generic \
+ strspn-generic \
+ varshift \
+# sysdep_routines
gen-as-const-headers += locale-defines.sym
tests += \
tst-rsi-strlen
@@ -533,6 +533,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
/* Support sysdeps/x86_64/multiarch/strcspn.c. */
IFUNC_IMPL (i, name, strcspn,
+ /* All implementations of strcspn are built at all ISA
+ levels. */
IFUNC_IMPL_ADD (array, i, strcspn, CPU_FEATURE_USABLE (SSE4_2),
__strcspn_sse42)
IFUNC_IMPL_ADD (array, i, strcspn, 1, __strcspn_generic))
@@ -609,6 +611,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
/* Support sysdeps/x86_64/multiarch/strpbrk.c. */
IFUNC_IMPL (i, name, strpbrk,
+ /* All implementations of strpbrk are built at all ISA
+ levels. */
IFUNC_IMPL_ADD (array, i, strpbrk, CPU_FEATURE_USABLE (SSE4_2),
__strpbrk_sse42)
IFUNC_IMPL_ADD (array, i, strpbrk, 1, __strpbrk_generic))
@@ -616,6 +620,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
/* Support sysdeps/x86_64/multiarch/strspn.c. */
IFUNC_IMPL (i, name, strspn,
+ /* All implementations of strspn are built at all ISA
+ levels. */
IFUNC_IMPL_ADD (array, i, strspn, CPU_FEATURE_USABLE (SSE4_2),
__strspn_sse42)
IFUNC_IMPL_ADD (array, i, strspn, 1, __strspn_generic))
@@ -31,7 +31,7 @@ IFUNC_SELECTOR (void)
there is no other optimized implementation keep using. If an
optimized fallback is added add a X86_ISA_CPU_FEATURE_ARCH_P
(cpu_features, Slow_SSE4_2) check. */
- if (CPU_FEATURE_USABLE_P (cpu_features, SSE4_2))
+ if (X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, SSE4_2))
return OPTIMIZE (sse42);
return OPTIMIZE (generic);
new file mode 100644
@@ -0,0 +1,18 @@
+/* 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 "../strcspn.c"
@@ -16,8 +16,10 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#if IS_IN (libc)
-
+/* We always need to build this implementation as strcspn-sse4 needs
+ to be able to fallback to it. */
+#include <isa-level.h>
+#if IS_IN (libc) || MINIMUM_X86_ISA_LEVEL >= 2
# include <sysdep.h>
# define STRCSPN __strcspn_generic
@@ -16,7 +16,7 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#if IS_IN (libc)
+#if IS_IN (libc) || MINIMUM_X86_ISA_LEVEL >= 2
# include <nmmintrin.h>
# include <string.h>
@@ -54,9 +54,11 @@
when either CFlag or ZFlag is 1. If CFlag == 1, ECX has the offset
X for case 1. */
+# ifndef STRCSPN
+# define STRCSPN __strcspn_sse42
+# endif
# ifndef STRCSPN_GENERIC
# define STRCSPN_GENERIC __strcspn_generic
-# define STRCSPN_SSE42 __strcspn_sse42
# endif
# ifdef USE_AS_STRPBRK
@@ -80,7 +82,7 @@ char *
size_t
# endif
__attribute__ ((section (".text.sse4.2")))
-STRCSPN_SSE42 (const char *s, const char *a)
+STRCSPN (const char *s, const char *a)
{
if (*a == 0)
RETURN (NULL, strlen (s));
@@ -16,8 +16,11 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#if IS_IN (libc)
+/* We always need to build this implementation as strpbrk-sse4 needs
+ to be able to fallback to it. */
+#include <isa-level.h>
+#if IS_IN (libc) || MINIMUM_X86_ISA_LEVEL >= 2
# include <sysdep.h>
# define STRPBRK __strpbrk_generic
@@ -16,7 +16,11 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
+#ifndef STRPBRK
+# define STRPBRK __strpbrk_sse42
+#endif
+
#define USE_AS_STRPBRK
#define STRCSPN_GENERIC __strpbrk_generic
-#define STRCSPN_SSE42 __strpbrk_sse42
+#define STRCSPN STRPBRK
#include "strcspn-sse4.c"
@@ -16,13 +16,16 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#if IS_IN (libc)
-
+/* We always need to build this implementation as strspn-sse4 needs to
+ be able to fallback to it. */
+#include <isa-level.h>
+#if IS_IN (libc) || MINIMUM_X86_ISA_LEVEL >= 2
# include <sysdep.h>
# define STRSPN __strspn_generic
# undef libc_hidden_builtin_def
# define libc_hidden_builtin_def(STRSPN)
+
#endif
#include <string/strspn.c>
@@ -53,10 +53,13 @@
extern size_t __strspn_generic (const char *, const char *) attribute_hidden;
+#ifndef STRSPN
+# define STRSPN __strspn_sse42
+#endif
size_t
__attribute__ ((section (".text.sse4.2")))
-__strspn_sse42 (const char *s, const char *a)
+STRSPN (const char *s, const char *a)
{
if (*a == 0)
return 0;
new file mode 100644
@@ -0,0 +1,25 @@
+/* Hook for build strcspn-generic for non-multiarch build. Needed for
+ the ISA level >= 2 because strcspn-sse4 has a dependency on
+ strcspn-generic.
+ 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 <isa-level.h>
+
+#if MINIMUM_X86_ISA_LEVEL >= 2
+# include "multiarch/strcspn-generic.c"
+#endif
new file mode 100644
@@ -0,0 +1,27 @@
+/* strcspn hook for non-multiarch and RTLD build.
+ 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 <isa-level.h>
+
+#if MINIMUM_X86_ISA_LEVEL == 1
+#include <string/strcspn.c>
+#else
+#define STRCSPN strcspn
+#include "multiarch/strcspn-sse4.c"
+libc_hidden_builtin_def (strcspn)
+#endif
new file mode 100644
@@ -0,0 +1,25 @@
+/* Hook for build strpbrk-generic for non-multiarch build. Needed for
+ the ISA level >= 2 because strpbrk-sse4 has a dependency on
+ strpbrk-generic.
+ 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 <isa-level.h>
+
+#if MINIMUM_X86_ISA_LEVEL >= 2
+# include "multiarch/strpbrk-generic.c"
+#endif
new file mode 100644
@@ -0,0 +1,27 @@
+/* strpbrk hook for non-multiarch and RTLD build.
+ 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 <isa-level.h>
+
+#if MINIMUM_X86_ISA_LEVEL == 1
+#include <string/strpbrk.c>
+#else
+#define STRPBRK strpbrk
+#include "multiarch/strpbrk-sse4.c"
+libc_hidden_builtin_def (strpbrk)
+#endif
new file mode 100644
@@ -0,0 +1,26 @@
+/* Hook for build strspn-generic for non-multiarch build. Needed for
+ the ISA level >= 2 because strspn-sse4 has a dependency on
+ strspn-generic.
+ 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 <isa-level.h>
+
+#if MINIMUM_X86_ISA_LEVEL >= 2
+# include "multiarch/strspn-generic.c"
+#endif
new file mode 100644
@@ -0,0 +1,27 @@
+/* strspn hook for non-multiarch and RTLD build.
+ 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 <isa-level.h>
+
+#if MINIMUM_X86_ISA_LEVEL == 1
+#include <string/strspn.c>
+#else
+#define STRSPN strspn
+#include "multiarch/strspn-sse4.c"
+libc_hidden_builtin_def (strspn)
+#endif
new file mode 100644
@@ -0,0 +1,26 @@
+/* Hook for build varshift for non-multiarch build. Needed for the
+ ISA level >= 2 because strspn-sse4, strcspn-sse4, and strpbrk-sse4
+ all have a dependency on varshift.c.
+ 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 <isa-level.h>
+
+#if MINIMUM_X86_ISA_LEVEL >= 2
+# include "multiarch/varshift.c"
+#endif