077c9d
commit 12f0dcb8da2c7c74d673583ec3286c0354273f52
077c9d
Author: Stefan Liebler <stli@linux.ibm.com>
077c9d
Date:   Tue Dec 18 13:57:25 2018 +0100
077c9d
077c9d
    S390: Refactor gconv_simple ifunc handling.
077c9d
    
077c9d
    The ifunc handling for various __gconv_transform_* functions
077c9d
    which are using IFUNC on s390x are adjusted in order to omit ifunc
077c9d
    if the minimum architecture level already supports newer CPUs by default.
077c9d
    Instead those functions are just an alias to the vector variants.
077c9d
    
077c9d
    Furthermore the ifunc-macro s390_libc_ifunc_expr is now used instead of
077c9d
    s390_vx_libc_ifunc.
077c9d
    
077c9d
    ChangeLog:
077c9d
    
077c9d
            * sysdeps/s390/multiarch/gconv_simple.c (ICONV_VX_IFUNC):
077c9d
            Define macro dependent on HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT.
077c9d
077c9d
diff --git a/sysdeps/s390/multiarch/gconv_simple.c b/sysdeps/s390/multiarch/gconv_simple.c
077c9d
index aaa1ebf74acf4dde..078d992c13eb548c 100644
077c9d
--- a/sysdeps/s390/multiarch/gconv_simple.c
077c9d
+++ b/sysdeps/s390/multiarch/gconv_simple.c
077c9d
@@ -27,17 +27,18 @@
077c9d
 
077c9d
 # define ICONV_C_NAME(NAME) __##NAME##_c
077c9d
 # define ICONV_VX_NAME(NAME) __##NAME##_vx
077c9d
-# define ICONV_VX_IFUNC(FUNC)						\
077c9d
-  extern __typeof (ICONV_C_NAME (FUNC)) __##FUNC;			\
077c9d
-  s390_vx_libc_ifunc (__##FUNC)						\
077c9d
-  int FUNC (struct __gconv_step *step, struct __gconv_step_data *data,	\
077c9d
-	    const unsigned char **inptrp, const unsigned char *inend,	\
077c9d
-	    unsigned char **outbufstart, size_t *irreversible,		\
077c9d
-	    int do_flush, int consume_incomplete)			\
077c9d
-  {									\
077c9d
-    return __##FUNC (step, data, inptrp, inend,outbufstart,		\
077c9d
-		     irreversible, do_flush, consume_incomplete);	\
077c9d
-  }
077c9d
+# ifdef HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT
077c9d
+/* We support z13 instructions by default -> Just use the vector variant.  */
077c9d
+#  define ICONV_VX_IFUNC(FUNC) strong_alias (ICONV_VX_NAME (FUNC), FUNC)
077c9d
+# else
077c9d
+/* We have to use ifunc to determine if z13 instructions are supported.  */
077c9d
+#  define ICONV_VX_IFUNC(FUNC)						\
077c9d
+  s390_libc_ifunc_expr (ICONV_C_NAME (FUNC), FUNC,			\
077c9d
+			(hwcap & HWCAP_S390_VX)				\
077c9d
+			? ICONV_VX_NAME (FUNC)				\
077c9d
+			: ICONV_C_NAME (FUNC)				\
077c9d
+			)
077c9d
+# endif
077c9d
 # define ICONV_VX_SINGLE(NAME)						\
077c9d
   static __typeof (NAME##_single) __##NAME##_vx_single __attribute__((alias(#NAME "_single")));
077c9d