arrfab / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh1375235-5.patch

147e83
From f69ff8906aeb1c4fd762bc9964f8a261963c30d5 Mon Sep 17 00:00:00 2001
147e83
From: Stefan Liebler <stli@linux.vnet.ibm.com>
147e83
Date: Thu, 27 Jul 2017 10:53:58 +0200
147e83
Subject: [PATCH 05/10] S390: Move utf8-utf32-z9.c to multiarch folder and use
147e83
 s390_libc_ifunc_expr macro.
147e83
147e83
upstream-commit 5ea9ce3749007348a8d12e8eef9e0ccc6fd90aec
147e83
147e83
The utf8-utf32-z9.c iconv module is using ifunc and thus the ifunc part should
147e83
be in multiarch folder.  Otherwise ifunc is used even if you configure
147e83
with --disable-multi-arch.
147e83
147e83
This patch moves the ifunc resolvers to the new file
147e83
sysdeps/s390/multiarch/utf8-utf32-z9.c. The resolvers are now implemented
147e83
with s390_libc_ifunc_expr macro instead of using gcc attribute ifunc directly.
147e83
147e83
The ifunc versions are implemented in sysdeps/s390/utf8-utf32-z9.c.
147e83
Each version is only implemented if needed or supported.  Therefore there is
147e83
a block at beginning of the file which selects the versions which should be
147e83
defined depending on support for multiarch, vector-support and used minimum
147e83
architecture level.  This block defines HAVE_[FROM|TO]_[C|CU|VX] to 1 or 0.
147e83
The code below is rearranged and surrounded
147e83
by #if HAVE_[FROM|TO]_[C|CU|VX] == 1.  There is no functional change.
147e83
147e83
The cu instructions are z9 zarch instructions.  As the major distros are
147e83
already using the newer z196 as architecture level set, those instructions
147e83
can be used as fallback version instead of the c-code.  This behaviour is
147e83
decided at compile time via HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT.
147e83
147e83
ChangeLog:
147e83
147e83
	* sysdeps/s390/multiarch/utf8-utf32-z9.c: New File.
147e83
	* sysdeps/s390/utf8-utf32-z9.c: Move ifunc resolvers to multiarch
147e83
	folder and define ifunc versions depending on HAVE_[FROM|TO]_[C|CU|VX].
147e83
	(HAVE_FROM_C, HAVE_FROM_CU, HAVE_FROM_VX, HAVE_TO_C, HAVE_TO_VX,
147e83
	FROM_LOOP_DEFAULT, FROM_LOOP_C, FROM_LOOP_CU, FROM_LOOP_VX,
147e83
	TO_LOOP_DEFAULT, TO_LOOP_C, TO_LOOP_VX): New Define.
147e83
---
147e83
 sysdeps/s390/multiarch/utf8-utf32-z9.c |  48 ++++++++
147e83
 sysdeps/s390/utf8-utf32-z9.c           | 215 +++++++++++++++++----------------
147e83
 2 files changed, 160 insertions(+), 103 deletions(-)
147e83
 create mode 100644 sysdeps/s390/multiarch/utf8-utf32-z9.c
147e83
147e83
diff --git a/sysdeps/s390/multiarch/utf8-utf32-z9.c b/sysdeps/s390/multiarch/utf8-utf32-z9.c
147e83
new file mode 100644
147e83
index 0000000..faf1f46
147e83
--- /dev/null
147e83
+++ b/sysdeps/s390/multiarch/utf8-utf32-z9.c
147e83
@@ -0,0 +1,48 @@
147e83
+/* Conversion between UTF-8 and UTF-32 - multiarch s390 version.
147e83
+
147e83
+   Copyright (C) 2017 Free Software Foundation, Inc.
147e83
+   This file is part of the GNU C Library.
147e83
+
147e83
+   The GNU C Library is free software; you can redistribute it and/or
147e83
+   modify it under the terms of the GNU Lesser General Public
147e83
+   License as published by the Free Software Foundation; either
147e83
+   version 2.1 of the License, or (at your option) any later version.
147e83
+
147e83
+   The GNU C Library is distributed in the hope that it will be useful,
147e83
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
147e83
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
147e83
+   Lesser General Public License for more details.
147e83
+
147e83
+   You should have received a copy of the GNU Lesser General Public
147e83
+   License along with the GNU C Library; if not, see
147e83
+   <http://www.gnu.org/licenses/>.  */
147e83
+
147e83
+#include <sysdeps/s390/utf8-utf32-z9.c>
147e83
+#include <ifunc-resolve.h>
147e83
+
147e83
+#undef FROM_LOOP
147e83
+#define FROM_LOOP	__from_utf8_loop
147e83
+#undef TO_LOOP
147e83
+#define TO_LOOP		__to_utf8_loop
147e83
+
147e83
+#define _SINGLE_NAME(NAME) NAME##_single
147e83
+#define SINGLE_NAME(NAME) _SINGLE_NAME(NAME)
147e83
+strong_alias (SINGLE_NAME (FROM_LOOP_DEFAULT), SINGLE_NAME (FROM_LOOP))
147e83
+strong_alias (SINGLE_NAME (TO_LOOP_DEFAULT), SINGLE_NAME (TO_LOOP))
147e83
+
147e83
+/* Generate ifunc'ed loop functions for FROM/TO_LOOP.  */
147e83
+s390_libc_ifunc_expr (FROM_LOOP_DEFAULT, FROM_LOOP,
147e83
+		      (HAVE_FROM_VX && (hwcap & HWCAP_S390_VX))
147e83
+		      ? FROM_LOOP_VX
147e83
+		      : (HAVE_FROM_CU && (hwcap & HWCAP_S390_ZARCH
147e83
+					  && hwcap & HWCAP_S390_HIGH_GPRS
147e83
+					  && hwcap & HWCAP_S390_ETF3EH))
147e83
+			? FROM_LOOP_CU
147e83
+			: FROM_LOOP_DEFAULT);
147e83
+
147e83
+s390_libc_ifunc_expr (TO_LOOP_DEFAULT, TO_LOOP,
147e83
+		      (HAVE_TO_VX && (hwcap & HWCAP_S390_VX))
147e83
+		      ? TO_LOOP_VX
147e83
+		      : TO_LOOP_DEFAULT);
147e83
+
147e83
+#include <iconv/skeleton.c>
147e83
diff --git a/sysdeps/s390/utf8-utf32-z9.c b/sysdeps/s390/utf8-utf32-z9.c
147e83
index efae745..e06d11e 100644
147e83
--- a/sysdeps/s390/utf8-utf32-z9.c
147e83
+++ b/sysdeps/s390/utf8-utf32-z9.c
147e83
@@ -27,8 +27,35 @@
147e83
 #include <dlfcn.h>
147e83
 #include <stdint.h>
147e83
 #include <unistd.h>
147e83
-#include <dl-procinfo.h>
147e83
 #include <gconv.h>
147e83
+#include <string.h>
147e83
+
147e83
+/* Select which versions should be defined depending on support
147e83
+   for multiarch, vector and used minimum architecture level.  */
147e83
+#ifdef HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT
147e83
+# define HAVE_FROM_C		0
147e83
+# define FROM_LOOP_DEFAULT	FROM_LOOP_CU
147e83
+#else
147e83
+# define HAVE_FROM_C		1
147e83
+# define FROM_LOOP_DEFAULT	FROM_LOOP_C
147e83
+#endif
147e83
+
147e83
+#define HAVE_TO_C		1
147e83
+#define TO_LOOP_DEFAULT		TO_LOOP_C
147e83
+
147e83
+#if defined HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT || defined USE_MULTIARCH
147e83
+# define HAVE_FROM_CU		1
147e83
+#else
147e83
+# define HAVE_FROM_CU		0
147e83
+#endif
147e83
+
147e83
+#if defined HAVE_S390_VX_ASM_SUPPORT && defined USE_MULTIARCH
147e83
+# define HAVE_FROM_VX		1
147e83
+# define HAVE_TO_VX		1
147e83
+#else
147e83
+# define HAVE_FROM_VX		0
147e83
+# define HAVE_TO_VX		0
147e83
+#endif
147e83
 
147e83
 #if defined HAVE_S390_VX_GCC_SUPPORT
147e83
 # define ASM_CLOBBER_VR(NR) , NR
147e83
@@ -48,8 +75,8 @@
147e83
 #define MIN_NEEDED_FROM		1
147e83
 #define MAX_NEEDED_FROM		6
147e83
 #define MIN_NEEDED_TO		4
147e83
-#define FROM_LOOP		__from_utf8_loop
147e83
-#define TO_LOOP			__to_utf8_loop
147e83
+#define FROM_LOOP		FROM_LOOP_DEFAULT
147e83
+#define TO_LOOP			TO_LOOP_DEFAULT
147e83
 #define FROM_DIRECTION		(dir == from_utf8)
147e83
 #define ONE_DIRECTION           0
147e83
 
147e83
@@ -303,12 +330,9 @@ gconv_end (struct __gconv_step *data)
147e83
     STANDARD_FROM_LOOP_ERR_HANDLER (i);					\
147e83
   }
147e83
 
147e83
-/* This hardware routine uses the Convert UTF8 to UTF32 (cu14) instruction.  */
147e83
-#define BODY_FROM_ETF3EH BODY_FROM_HW (HARDWARE_CONVERT ("cu14 %0, %1, 1"))
147e83
-
147e83
-
147e83
+#if HAVE_FROM_C == 1
147e83
 /* The software routine is copied from gconv_simple.c.  */
147e83
-#define BODY_FROM_C							\
147e83
+# define BODY_FROM_C							\
147e83
   {									\
147e83
     /* Next input byte.  */						\
147e83
     uint32_t ch = *inptr;						\
147e83
@@ -408,7 +432,50 @@ gconv_end (struct __gconv_step *data)
147e83
     outptr += sizeof (uint32_t);					\
147e83
   }
147e83
 
147e83
-#define HW_FROM_VX							\
147e83
+/* These definitions apply to the UTF-8 to UTF-32 direction.  The
147e83
+   software implementation for UTF-8 still supports multibyte
147e83
+   characters up to 6 bytes whereas the hardware variant does not.  */
147e83
+# define MIN_NEEDED_INPUT	MIN_NEEDED_FROM
147e83
+# define MAX_NEEDED_INPUT	MAX_NEEDED_FROM
147e83
+# define MIN_NEEDED_OUTPUT	MIN_NEEDED_TO
147e83
+# define FROM_LOOP_C		__from_utf8_loop_c
147e83
+# define LOOPFCT		FROM_LOOP_C
147e83
+
147e83
+# define LOOP_NEED_FLAGS
147e83
+
147e83
+# define STORE_REST		STORE_REST_COMMON
147e83
+# define UNPACK_BYTES		UNPACK_BYTES_COMMON
147e83
+# define CLEAR_STATE		CLEAR_STATE_COMMON
147e83
+# define BODY			BODY_FROM_C
147e83
+# include <iconv/loop.c>
147e83
+#else
147e83
+# define FROM_LOOP_C		NULL
147e83
+#endif /* HAVE_FROM_C != 1  */
147e83
+
147e83
+#if HAVE_FROM_CU == 1
147e83
+/* This hardware routine uses the Convert UTF8 to UTF32 (cu14) instruction.  */
147e83
+# define BODY_FROM_ETF3EH BODY_FROM_HW (HARDWARE_CONVERT ("cu14 %0, %1, 1"))
147e83
+
147e83
+/* Generate loop-function with hardware utf-convert instruction.  */
147e83
+# define MIN_NEEDED_INPUT	MIN_NEEDED_FROM
147e83
+# define MAX_NEEDED_INPUT	MAX_NEEDED_FROM
147e83
+# define MIN_NEEDED_OUTPUT	MIN_NEEDED_TO
147e83
+# define FROM_LOOP_CU		__from_utf8_loop_etf3eh
147e83
+# define LOOPFCT		FROM_LOOP_CU
147e83
+
147e83
+# define LOOP_NEED_FLAGS
147e83
+
147e83
+# define STORE_REST		STORE_REST_COMMON
147e83
+# define UNPACK_BYTES		UNPACK_BYTES_COMMON
147e83
+# define CLEAR_STATE		CLEAR_STATE_COMMON
147e83
+# define BODY			BODY_FROM_ETF3EH
147e83
+# include <iconv/loop.c>
147e83
+#else
147e83
+# define FROM_LOOP_CU		NULL
147e83
+#endif /* HAVE_FROM_CU != 1  */
147e83
+
147e83
+#if HAVE_FROM_VX == 1
147e83
+# define HW_FROM_VX							\
147e83
   {									\
147e83
     register const unsigned char* pInput asm ("8") = inptr;		\
147e83
     register size_t inlen asm ("9") = inend - inptr;			\
147e83
@@ -500,45 +567,14 @@ gconv_end (struct __gconv_step *data)
147e83
     inptr = pInput;							\
147e83
     outptr = pOutput;							\
147e83
   }
147e83
-#define BODY_FROM_VX BODY_FROM_HW (HW_FROM_VX)
147e83
+# define BODY_FROM_VX BODY_FROM_HW (HW_FROM_VX)
147e83
 
147e83
-/* These definitions apply to the UTF-8 to UTF-32 direction.  The
147e83
-   software implementation for UTF-8 still supports multibyte
147e83
-   characters up to 6 bytes whereas the hardware variant does not.  */
147e83
-#define MIN_NEEDED_INPUT	MIN_NEEDED_FROM
147e83
-#define MAX_NEEDED_INPUT	MAX_NEEDED_FROM
147e83
-#define MIN_NEEDED_OUTPUT	MIN_NEEDED_TO
147e83
-#define LOOPFCT			__from_utf8_loop_c
147e83
-
147e83
-#define LOOP_NEED_FLAGS
147e83
-
147e83
-#define STORE_REST		STORE_REST_COMMON
147e83
-#define UNPACK_BYTES		UNPACK_BYTES_COMMON
147e83
-#define CLEAR_STATE		CLEAR_STATE_COMMON
147e83
-#define BODY			BODY_FROM_C
147e83
-#include <iconv/loop.c>
147e83
-
147e83
-
147e83
-/* Generate loop-function with hardware utf-convert instruction.  */
147e83
-#define MIN_NEEDED_INPUT	MIN_NEEDED_FROM
147e83
-#define MAX_NEEDED_INPUT	MAX_NEEDED_FROM
147e83
-#define MIN_NEEDED_OUTPUT	MIN_NEEDED_TO
147e83
-#define LOOPFCT			__from_utf8_loop_etf3eh
147e83
-
147e83
-#define LOOP_NEED_FLAGS
147e83
-
147e83
-#define STORE_REST		STORE_REST_COMMON
147e83
-#define UNPACK_BYTES		UNPACK_BYTES_COMMON
147e83
-#define CLEAR_STATE		CLEAR_STATE_COMMON
147e83
-#define BODY			BODY_FROM_ETF3EH
147e83
-#include <iconv/loop.c>
147e83
-
147e83
-#if defined HAVE_S390_VX_ASM_SUPPORT
147e83
-/* Generate loop-function with hardware vector instructions.  */
147e83
+/* Generate loop-function with hardware vector and utf-convert instructions.  */
147e83
 # define MIN_NEEDED_INPUT	MIN_NEEDED_FROM
147e83
 # define MAX_NEEDED_INPUT	MAX_NEEDED_FROM
147e83
 # define MIN_NEEDED_OUTPUT	MIN_NEEDED_TO
147e83
-# define LOOPFCT		__from_utf8_loop_vx
147e83
+# define FROM_LOOP_VX		__from_utf8_loop_vx
147e83
+# define LOOPFCT		FROM_LOOP_VX
147e83
 
147e83
 # define LOOP_NEED_FLAGS
147e83
 
147e83
@@ -547,33 +583,13 @@ gconv_end (struct __gconv_step *data)
147e83
 # define CLEAR_STATE		CLEAR_STATE_COMMON
147e83
 # define BODY			BODY_FROM_VX
147e83
 # include <iconv/loop.c>
147e83
-#endif
147e83
-
147e83
-
147e83
-/* Generate ifunc'ed loop function.  */
147e83
-__typeof(__from_utf8_loop_c)
147e83
-__attribute__ ((ifunc ("__from_utf8_loop_resolver")))
147e83
-__from_utf8_loop;
147e83
-
147e83
-static void *
147e83
-__from_utf8_loop_resolver (unsigned long int dl_hwcap)
147e83
-{
147e83
-#if defined HAVE_S390_VX_ASM_SUPPORT
147e83
-  if (dl_hwcap & HWCAP_S390_VX)
147e83
-    return __from_utf8_loop_vx;
147e83
-  else
147e83
-#endif
147e83
-  if (dl_hwcap & HWCAP_S390_ZARCH && dl_hwcap & HWCAP_S390_HIGH_GPRS
147e83
-      && dl_hwcap & HWCAP_S390_ETF3EH)
147e83
-    return __from_utf8_loop_etf3eh;
147e83
-  else
147e83
-    return __from_utf8_loop_c;
147e83
-}
147e83
-
147e83
-strong_alias (__from_utf8_loop_c_single, __from_utf8_loop_single)
147e83
+#else
147e83
+# define FROM_LOOP_VX		NULL
147e83
+#endif /* HAVE_FROM_VX != 1  */
147e83
 
147e83
+#if HAVE_TO_C == 1
147e83
 /* The software routine mimics the S/390 cu41 instruction.  */
147e83
-#define BODY_TO_C						\
147e83
+# define BODY_TO_C						\
147e83
   {								\
147e83
     uint32_t wc = *((const uint32_t *) inptr);			\
147e83
 								\
147e83
@@ -657,8 +673,22 @@ strong_alias (__from_utf8_loop_c_single, __from_utf8_loop_single)
147e83
     inptr += 4;							\
147e83
   }
147e83
 
147e83
+/* Generate loop-function with software routing.  */
147e83
+# define MIN_NEEDED_INPUT	MIN_NEEDED_TO
147e83
+# define MIN_NEEDED_OUTPUT	MIN_NEEDED_FROM
147e83
+# define MAX_NEEDED_OUTPUT	MAX_NEEDED_FROM
147e83
+# define TO_LOOP_C		__to_utf8_loop_c
147e83
+# define LOOPFCT		TO_LOOP_C
147e83
+# define BODY			BODY_TO_C
147e83
+# define LOOP_NEED_FLAGS
147e83
+# include <iconv/loop.c>
147e83
+#else
147e83
+# define TO_LOOP_C		NULL
147e83
+#endif /* HAVE_TO_C != 1  */
147e83
+
147e83
+#if HAVE_TO_VX == 1
147e83
 /* The hardware routine uses the S/390 vector instructions.  */
147e83
-#define BODY_TO_VX							\
147e83
+# define BODY_TO_VX							\
147e83
   {									\
147e83
     size_t inlen = inend - inptr;					\
147e83
     size_t outlen = outend - outptr;					\
147e83
@@ -820,43 +850,22 @@ strong_alias (__from_utf8_loop_c_single, __from_utf8_loop_single)
147e83
     STANDARD_TO_LOOP_ERR_HANDLER (4);					\
147e83
   }
147e83
 
147e83
-/* Generate loop-function with software routing.  */
147e83
-#define MIN_NEEDED_INPUT	MIN_NEEDED_TO
147e83
-#define MIN_NEEDED_OUTPUT	MIN_NEEDED_FROM
147e83
-#define MAX_NEEDED_OUTPUT	MAX_NEEDED_FROM
147e83
-#define LOOPFCT			__to_utf8_loop_c
147e83
-#define BODY			BODY_TO_C
147e83
-#define LOOP_NEED_FLAGS
147e83
-#include <iconv/loop.c>
147e83
-
147e83
-#if defined HAVE_S390_VX_ASM_SUPPORT
147e83
-/* Generate loop-function with hardware vector and utf-convert instructions.  */
147e83
+/* Generate loop-function with hardware vector instructions.  */
147e83
 # define MIN_NEEDED_INPUT	MIN_NEEDED_TO
147e83
 # define MIN_NEEDED_OUTPUT	MIN_NEEDED_FROM
147e83
 # define MAX_NEEDED_OUTPUT	MAX_NEEDED_FROM
147e83
-# define LOOPFCT		__to_utf8_loop_vx
147e83
+# define TO_LOOP_VX		__to_utf8_loop_vx
147e83
+# define LOOPFCT		TO_LOOP_VX
147e83
 # define BODY			BODY_TO_VX
147e83
 # define LOOP_NEED_FLAGS
147e83
 # include <iconv/loop.c>
147e83
+#else
147e83
+# define TO_LOOP_VX		NULL
147e83
+#endif /* HAVE_TO_VX != 1  */
147e83
+
147e83
+/* This file also exists in sysdeps/s390/multiarch/ which
147e83
+   generates ifunc resolvers for FROM/TO_LOOP functions
147e83
+   and includes iconv/skeleton.c afterwards.  */
147e83
+#if ! defined USE_MULTIARCH
147e83
+# include <iconv/skeleton.c>
147e83
 #endif
147e83
-
147e83
-/* Generate ifunc'ed loop function.  */
147e83
-__typeof(__to_utf8_loop_c)
147e83
-__attribute__ ((ifunc ("__to_utf8_loop_resolver")))
147e83
-__to_utf8_loop;
147e83
-
147e83
-static void *
147e83
-__to_utf8_loop_resolver (unsigned long int dl_hwcap)
147e83
-{
147e83
-#if defined HAVE_S390_VX_ASM_SUPPORT
147e83
-  if (dl_hwcap & HWCAP_S390_VX)
147e83
-    return __to_utf8_loop_vx;
147e83
-  else
147e83
-#endif
147e83
-    return __to_utf8_loop_c;
147e83
-}
147e83
-
147e83
-strong_alias (__to_utf8_loop_c_single, __to_utf8_loop_single)
147e83
-
147e83
-
147e83
-#include <iconv/skeleton.c>
147e83
-- 
147e83
1.8.3.1
147e83