From 782a64743fc11499a87aa8402202633460d0e29b Mon Sep 17 00:00:00 2001 From: Packit Date: Aug 21 2020 09:20:56 +0000 Subject: Apply patch glibc-rh1659438-27.patch patch_name: glibc-rh1659438-27.patch location_in_specfile: 120 present_in_specfile: true --- diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 8bb396f..c54bb82 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -47,5 +47,6 @@ sysdep_routines += bzero memset memset-z900 \ strncat strncat-vx strncat-c \ strcmp strcmp-vx strcmp-z900 \ strncmp strncmp-vx strncmp-c \ - strchr strchr-vx strchr-c + strchr strchr-vx strchr-c \ + strchrnul strchrnul-vx strchrnul-c endif diff --git a/sysdeps/s390/ifunc-strchrnul.h b/sysdeps/s390/ifunc-strchrnul.h new file mode 100644 index 0000000..cac817e --- /dev/null +++ b/sysdeps/s390/ifunc-strchrnul.h @@ -0,0 +1,52 @@ +/* strchrnul variant information on S/390 version. + Copyright (C) 2018 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_STRCHRNUL_IFUNC 1 +#else +# define HAVE_STRCHRNUL_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_STRCHRNUL_IFUNC_AND_VX_SUPPORT HAVE_STRCHRNUL_IFUNC +#else +# define HAVE_STRCHRNUL_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define STRCHRNUL_DEFAULT STRCHRNUL_Z13 +# define HAVE_STRCHRNUL_C 0 +# define HAVE_STRCHRNUL_Z13 1 +#else +# define STRCHRNUL_DEFAULT STRCHRNUL_C +# define HAVE_STRCHRNUL_C 1 +# define HAVE_STRCHRNUL_Z13 HAVE_STRCHRNUL_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_STRCHRNUL_C +# define STRCHRNUL_C __strchrnul_c +#else +# define STRCHRNUL_C NULL +#endif + +#if HAVE_STRCHRNUL_Z13 +# define STRCHRNUL_Z13 __strchrnul_vx +#else +# define STRCHRNUL_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index a8e9d0a..999a979 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),string) -sysdep_routines += strchrnul strchrnul-vx strchrnul-c \ - strrchr strrchr-vx strrchr-c \ +sysdep_routines += strrchr strrchr-vx strrchr-c \ strspn strspn-vx strspn-c \ strpbrk strpbrk-vx strpbrk-c \ strcspn strcspn-vx strcspn-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index e809ca3..0a47ffe 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -37,6 +37,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -307,6 +308,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_STRCHR_IFUNC */ +#if HAVE_STRCHRNUL_IFUNC + IFUNC_IMPL (i, name, strchrnul, +# if HAVE_STRCHRNUL_Z13 + IFUNC_IMPL_ADD (array, i, strchrnul, + dl_hwcap & HWCAP_S390_VX, STRCHRNUL_Z13) +# endif +# if HAVE_STRCHRNUL_C + IFUNC_IMPL_ADD (array, i, strchrnul, 1, STRCHRNUL_C) +# endif + ) +#endif /* HAVE_STRCHRNUL_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -337,7 +350,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_VX_IMPL (wcschr); - IFUNC_VX_IMPL (strchrnul); IFUNC_VX_IMPL (wcschrnul); IFUNC_VX_IMPL (strrchr); diff --git a/sysdeps/s390/multiarch/strchrnul-c.c b/sysdeps/s390/multiarch/strchrnul-c.c deleted file mode 100644 index 020cebc..0000000 --- a/sysdeps/s390/multiarch/strchrnul-c.c +++ /dev/null @@ -1,26 +0,0 @@ -/* Default strchrnul implementation for S/390. - Copyright (C) 2015-2018 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 - . */ - -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define STRCHRNUL __strchrnul_c -# define __strchrnul STRCHRNUL -# undef weak_alias -# define weak_alias(name, alias) - -# include -#endif diff --git a/sysdeps/s390/multiarch/strchrnul-vx.S b/sysdeps/s390/multiarch/strchrnul-vx.S deleted file mode 100644 index d561825..0000000 --- a/sysdeps/s390/multiarch/strchrnul-vx.S +++ /dev/null @@ -1,93 +0,0 @@ -/* Vector optimized 32/64 bit S/390 version of strchrnul. - Copyright (C) 2015-2018 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 - . */ - -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) - -# include "sysdep.h" -# include "asm-syntax.h" - - .text - -/* char *strchrnul (const char *s, int c) - Returns pointer to first c or to \0 if c not found. - - Register usage: - -r1=tmp - -r2=s and return pointer - -r3=c - -r4=tmp - -r5=current_len - -v16=part of s - -v18=vector with c replicated in every byte -*/ -ENTRY(__strchrnul_vx) - .machine "z13" - .machinemode "zarch_nohighgprs" - - vlbb %v16,0(%r2),6 /* Load s until next 4k-byte boundary. */ - lcbb %r1,0(%r2),6 /* Get bytes to 4k-byte boundary or 16. */ - - lghi %r5,0 /* current_len = 0. */ - - vlvgb %v18,%r3,0 /* Generate vector which elements are all c. - If c > 255, c will be truncated. */ - vrepb %v18,%v18,0 - - vfeezbs %v16,%v16,%v18 /* Find element equal with zero search. */ - vlgvb %r4,%v16,7 /* Load byte index of character or zero. */ - clrjl %r4,%r1,.Lfound /* Return if c/zero is in loaded bytes. */ - - /* Align s to 16 byte. */ - risbgn %r4,%r2,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15. */ - lghi %r5,16 /* current_len = 16. */ - slr %r5,%r4 /* Compute bytes to 16bytes boundary. */ - - /* Find c/zero in 16byte aligned loop */ -.Lloop: - vl %v16,0(%r5,%r2) /* Load s */ - vfeezbs %v16,%v16,%v18 /* Find element equal with zero search. */ - jno .Lfound /* Found c/zero (cc=0|1|2). */ - vl %v16,16(%r5,%r2) - vfeezbs %v16,%v16,%v18 - jno .Lfound16 - vl %v16,32(%r5,%r2) - vfeezbs %v16,%v16,%v18 - jno .Lfound32 - vl %v16,48(%r5,%r2) - vfeezbs %v16,%v16,%v18 - jno .Lfound48 - - aghi %r5,64 - j .Lloop /* No character and no zero -> loop. */ - - /* Found character or zero */ -.Lfound48: - aghi %r5,16 -.Lfound32: - aghi %r5,16 -.Lfound16: - aghi %r5,16 -.Lfound: - vlgvb %r1,%v16,7 /* Load byte index of character. */ - algr %r5,%r1 - la %r2,0(%r5,%r2) /* Return pointer to character. */ - -.Lend: - br %r14 -END(__strchrnul_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ diff --git a/sysdeps/s390/multiarch/strchrnul.c b/sysdeps/s390/multiarch/strchrnul.c deleted file mode 100644 index 62dfc6b..0000000 --- a/sysdeps/s390/multiarch/strchrnul.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Multiple versions of strchrnul. - Copyright (C) 2015-2018 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 - . */ - -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# include -# include - -s390_vx_libc_ifunc (__strchrnul) -weak_alias (__strchrnul, strchrnul) - -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ diff --git a/sysdeps/s390/strchrnul-c.c b/sysdeps/s390/strchrnul-c.c new file mode 100644 index 0000000..585273f --- /dev/null +++ b/sysdeps/s390/strchrnul-c.c @@ -0,0 +1,30 @@ +/* Default strchrnul implementation for S/390. + Copyright (C) 2015-2018 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 + . */ + +#include + +#if HAVE_STRCHRNUL_C +# if HAVE_STRCHRNUL_IFUNC +# define STRCHRNUL STRCHRNUL_C +# define __strchrnul STRCHRNUL +# undef weak_alias +# define weak_alias(name, alias) +# endif + +# include +#endif diff --git a/sysdeps/s390/strchrnul-vx.S b/sysdeps/s390/strchrnul-vx.S new file mode 100644 index 0000000..0cd587b --- /dev/null +++ b/sysdeps/s390/strchrnul-vx.S @@ -0,0 +1,101 @@ +/* Vector optimized 32/64 bit S/390 version of strchrnul. + Copyright (C) 2015-2018 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 + . */ + +#include + +#if HAVE_STRCHRNUL_Z13 + +# include "sysdep.h" +# include "asm-syntax.h" + + .text + +/* char *strchrnul (const char *s, int c) + Returns pointer to first c or to \0 if c not found. + + Register usage: + -r1=tmp + -r2=s and return pointer + -r3=c + -r4=tmp + -r5=current_len + -v16=part of s + -v18=vector with c replicated in every byte +*/ +ENTRY(STRCHRNUL_Z13) + .machine "z13" + .machinemode "zarch_nohighgprs" + + vlbb %v16,0(%r2),6 /* Load s until next 4k-byte boundary. */ + lcbb %r1,0(%r2),6 /* Get bytes to 4k-byte boundary or 16. */ + + lghi %r5,0 /* current_len = 0. */ + + vlvgb %v18,%r3,0 /* Generate vector which elements are all c. + If c > 255, c will be truncated. */ + vrepb %v18,%v18,0 + + vfeezbs %v16,%v16,%v18 /* Find element equal with zero search. */ + vlgvb %r4,%v16,7 /* Load byte index of character or zero. */ + clrjl %r4,%r1,.Lfound /* Return if c/zero is in loaded bytes. */ + + /* Align s to 16 byte. */ + risbgn %r4,%r2,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15. */ + lghi %r5,16 /* current_len = 16. */ + slr %r5,%r4 /* Compute bytes to 16bytes boundary. */ + + /* Find c/zero in 16byte aligned loop */ +.Lloop: + vl %v16,0(%r5,%r2) /* Load s */ + vfeezbs %v16,%v16,%v18 /* Find element equal with zero search. */ + jno .Lfound /* Found c/zero (cc=0|1|2). */ + vl %v16,16(%r5,%r2) + vfeezbs %v16,%v16,%v18 + jno .Lfound16 + vl %v16,32(%r5,%r2) + vfeezbs %v16,%v16,%v18 + jno .Lfound32 + vl %v16,48(%r5,%r2) + vfeezbs %v16,%v16,%v18 + jno .Lfound48 + + aghi %r5,64 + j .Lloop /* No character and no zero -> loop. */ + + /* Found character or zero */ +.Lfound48: + aghi %r5,16 +.Lfound32: + aghi %r5,16 +.Lfound16: + aghi %r5,16 +.Lfound: + vlgvb %r1,%v16,7 /* Load byte index of character. */ + algr %r5,%r1 + la %r2,0(%r5,%r2) /* Return pointer to character. */ + +.Lend: + br %r14 +END(STRCHRNUL_Z13) + +# if ! HAVE_STRCHRNUL_IFUNC +strong_alias (STRCHRNUL_Z13, __strchrnul) +weak_alias (__strchrnul, strchrnul) +# endif + +#endif /* HAVE_STRCHRNUL_Z13 */ diff --git a/sysdeps/s390/strchrnul.c b/sysdeps/s390/strchrnul.c new file mode 100644 index 0000000..e9fefe1 --- /dev/null +++ b/sysdeps/s390/strchrnul.c @@ -0,0 +1,39 @@ +/* Multiple versions of strchrnul. + Copyright (C) 2015-2018 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 + . */ + +#include + +#if HAVE_STRCHRNUL_IFUNC +# include +# include + +# if HAVE_STRCHRNUL_C +extern __typeof (__strchrnul) STRCHRNUL_C attribute_hidden; +# endif + +# if HAVE_STRCHRNUL_Z13 +extern __typeof (__strchrnul) STRCHRNUL_Z13 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__strchrnul, __strchrnul, + (HAVE_STRCHRNUL_Z13 && (hwcap & HWCAP_S390_VX)) + ? STRCHRNUL_Z13 + : STRCHRNUL_DEFAULT + ) +weak_alias (__strchrnul, strchrnul) +#endif /* HAVE_STRCHRNUL_IFUNC */