]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
S390: Refactor strchrnul ifunc handling.
authorStefan Liebler <stli@linux.ibm.com>
Tue, 18 Dec 2018 12:57:14 +0000 (13:57 +0100)
committerStefan Liebler <stli@linux.ibm.com>
Tue, 18 Dec 2018 12:57:14 +0000 (13:57 +0100)
The ifunc handling for strchrnul is adjusted in order to omit ifunc
variants if those will never be used as the minimum architecture level
already supports newer CPUs by default.

ChangeLog:

* sysdeps/s390/multiarch/Makefile
(sysdep_routines): Remove strchrnul variants.
* sysdeps/s390/Makefile (sysdep_routines): Add strchrnul variants.
* sysdeps/s390/multiarch/ifunc-impl-list.c
(__libc_ifunc_impl_list): Refactor ifunc handling for strchrnul.
* sysdeps/s390/multiarch/strchrnul-c.c: Move to ...
* sysdeps/s390/strchrnul-c.c: ... here and adjust ifunc handling.
* sysdeps/s390/multiarch/strchrnul-vx.S: Move to ...
* sysdeps/s390/strchrnul-vx.S: ... here and adjust ifunc handling.
* sysdeps/s390/multiarch/strchrnul.c: Move to ...
* sysdeps/s390/strchrnul.c: ... here and adjust ifunc handling.
* sysdeps/s390/ifunc-strchrnul.h: New file.

ChangeLog
sysdeps/s390/Makefile
sysdeps/s390/ifunc-strchrnul.h [new file with mode: 0644]
sysdeps/s390/multiarch/Makefile
sysdeps/s390/multiarch/ifunc-impl-list.c
sysdeps/s390/strchrnul-c.c [moved from sysdeps/s390/multiarch/strchrnul-c.c with 81% similarity]
sysdeps/s390/strchrnul-vx.S [moved from sysdeps/s390/multiarch/strchrnul-vx.S with 91% similarity]
sysdeps/s390/strchrnul.c [moved from sysdeps/s390/multiarch/strchrnul.c with 67% similarity]

index 7673d4b6a15f34346e039fefd30fe477dfe3eb5d..7431a8e767bdb62268c2b2bc63dc6aaec8b0983b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2018-12-18  Stefan Liebler  <stli@linux.ibm.com>
+
+       * sysdeps/s390/multiarch/Makefile
+       (sysdep_routines): Remove strchrnul variants.
+       * sysdeps/s390/Makefile (sysdep_routines): Add strchrnul variants.
+       * sysdeps/s390/multiarch/ifunc-impl-list.c
+       (__libc_ifunc_impl_list): Refactor ifunc handling for strchrnul.
+       * sysdeps/s390/multiarch/strchrnul-c.c: Move to ...
+       * sysdeps/s390/strchrnul-c.c: ... here and adjust ifunc handling.
+       * sysdeps/s390/multiarch/strchrnul-vx.S: Move to ...
+       * sysdeps/s390/strchrnul-vx.S: ... here and adjust ifunc handling.
+       * sysdeps/s390/multiarch/strchrnul.c: Move to ...
+       * sysdeps/s390/strchrnul.c: ... here and adjust ifunc handling.
+       * sysdeps/s390/ifunc-strchrnul.h: New file.
+
 2018-12-18  Stefan Liebler  <stli@linux.ibm.com>
 
        * sysdeps/s390/multiarch/Makefile
index 59d6e845db705ad29271b4c484823538e44b5858..07ec5e969fd4e6b02b2f0c984229a47e8f76ab8b 100644 (file)
@@ -70,5 +70,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 (file)
index 0000000..cac817e
--- /dev/null
@@ -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
+   <http://www.gnu.org/licenses/>.  */
+
+#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
index a8e9d0acd9ebf98672ee9bbae138f5b645682553..999a979fee1417b2d454070d2a95604b3aac8541 100644 (file)
@@ -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 \
index e809ca3bacb18aa93aa47a52d346dc216715e0a9..0a47ffeac3492b3efa2ebfdead31ba4cd447c748 100644 (file)
@@ -37,6 +37,7 @@
 #include <ifunc-strcmp.h>
 #include <ifunc-strncmp.h>
 #include <ifunc-strchr.h>
+#include <ifunc-strchrnul.h>
 
 /* 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);
similarity index 81%
rename from sysdeps/s390/multiarch/strchrnul-c.c
rename to sysdeps/s390/strchrnul-c.c
index 020cebcf3e275b078ce79a5e5a73f13adebb6a5f..585273f5de8b82bcc1190918fb28fc4de7770bb0 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#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 <ifunc-strchrnul.h>
+
+#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 <string/strchrnul.c>
 #endif
similarity index 91%
rename from sysdeps/s390/multiarch/strchrnul-vx.S
rename to sysdeps/s390/strchrnul-vx.S
index d561825e0432458c3eb7ba0f8bed1812c185e488..0cd587bc32cf811f79431c502c9439412ef2a608 100644 (file)
@@ -16,7 +16,9 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
+#include <ifunc-strchrnul.h>
+
+#if HAVE_STRCHRNUL_Z13
 
 # include "sysdep.h"
 # include "asm-syntax.h"
@@ -35,7 +37,7 @@
    -v16=part of s
    -v18=vector with c replicated in every byte
 */
-ENTRY(__strchrnul_vx)
+ENTRY(STRCHRNUL_Z13)
        .machine "z13"
        .machinemode "zarch_nohighgprs"
 
@@ -89,5 +91,11 @@ ENTRY(__strchrnul_vx)
 
 .Lend:
        br      %r14
-END(__strchrnul_vx)
-#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */
+END(STRCHRNUL_Z13)
+
+# if ! HAVE_STRCHRNUL_IFUNC
+strong_alias (STRCHRNUL_Z13, __strchrnul)
+weak_alias (__strchrnul, strchrnul)
+# endif
+
+#endif /* HAVE_STRCHRNUL_Z13  */
similarity index 67%
rename from sysdeps/s390/multiarch/strchrnul.c
rename to sysdeps/s390/strchrnul.c
index 62dfc6bd90638b602c8fb2fae5489c9492733c2a..e9fefe1bdc77f0387cabc1ac36c035e8208905f8 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
+#include <ifunc-strchrnul.h>
+
+#if HAVE_STRCHRNUL_IFUNC
 # include <string.h>
 # include <ifunc-resolve.h>
 
-s390_vx_libc_ifunc (__strchrnul)
-weak_alias (__strchrnul, strchrnul)
+# if HAVE_STRCHRNUL_C
+extern __typeof (__strchrnul) STRCHRNUL_C attribute_hidden;
+# endif
 
-#else
-# include <string/strchrnul.c>
-#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */
+# 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  */