This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.25-244-g5ea9ce3


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  5ea9ce3749007348a8d12e8eef9e0ccc6fd90aec (commit)
       via  85286aaf1dd7216a64964752d147c5ce3c4067d0 (commit)
       via  df6cc7ee3b2e032c6c62cedd30b1c0fefbb43018 (commit)
       via  51213e2b8d89164527131f3bf6c5946b811c5e3e (commit)
      from  44e4b889ab0e0497567c8983ad25a78798a3ab51 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=5ea9ce3749007348a8d12e8eef9e0ccc6fd90aec

commit 5ea9ce3749007348a8d12e8eef9e0ccc6fd90aec
Author: Stefan Liebler <stli@linux.vnet.ibm.com>
Date:   Fri Apr 21 15:30:00 2017 +0200

    S390: Move utf8-utf32-z9.c to multiarch folder and use s390_libc_ifunc_expr macro.
    
    The utf8-utf32-z9.c iconv module is using ifunc and thus the ifunc part should
    be in multiarch folder.  Otherwise ifunc is used even if you configure
    with --disable-multi-arch.
    
    This patch moves the ifunc resolvers to the new file
    sysdeps/s390/multiarch/utf8-utf32-z9.c. The resolvers are now implemented
    with s390_libc_ifunc_expr macro instead of using gcc attribute ifunc directly.
    
    The ifunc versions are implemented in sysdeps/s390/utf8-utf32-z9.c.
    Each version is only implemented if needed or supported.  Therefore there is
    a block at beginning of the file which selects the versions which should be
    defined depending on support for multiarch, vector-support and used minimum
    architecture level.  This block defines HAVE_[FROM|TO]_[C|CU|VX] to 1 or 0.
    The code below is rearranged and surrounded
    by #if HAVE_[FROM|TO]_[C|CU|VX] == 1.  There is no functional change.
    
    The cu instructions are z9 zarch instructions.  As the major distros are
    already using the newer z196 as architecture level set, those instructions
    can be used as fallback version instead of the c-code.  This behaviour is
    decided at compile time via HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT.
    
    ChangeLog:
    
    	* sysdeps/s390/multiarch/utf8-utf32-z9.c: New File.
    	* sysdeps/s390/utf8-utf32-z9.c: Move ifunc resolvers to multiarch
    	folder and define ifunc versions depending on HAVE_[FROM|TO]_[C|CU|VX].
    	(HAVE_FROM_C, HAVE_FROM_CU, HAVE_FROM_VX, HAVE_TO_C, HAVE_TO_VX,
    	FROM_LOOP_DEFAULT, FROM_LOOP_C, FROM_LOOP_CU, FROM_LOOP_VX,
    	TO_LOOP_DEFAULT, TO_LOOP_C, TO_LOOP_VX): New Define.

diff --git a/ChangeLog b/ChangeLog
index 74de162..38a281d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2017-04-21  Stefan Liebler  <stli@linux.vnet.ibm.com>
 
+	* sysdeps/s390/multiarch/utf8-utf32-z9.c: New File.
+	* sysdeps/s390/utf8-utf32-z9.c: Move ifunc resolvers to multiarch
+	folder and define ifunc versions depending on HAVE_[FROM|TO]_[C|CU|VX].
+	(HAVE_FROM_C, HAVE_FROM_CU, HAVE_FROM_VX, HAVE_TO_C, HAVE_TO_VX,
+	FROM_LOOP_DEFAULT, FROM_LOOP_C, FROM_LOOP_CU, FROM_LOOP_VX,
+	TO_LOOP_DEFAULT, TO_LOOP_C, TO_LOOP_VX): New Define.
+
+2017-04-21  Stefan Liebler  <stli@linux.vnet.ibm.com>
+
 	* sysdeps/s390/multiarch/utf16-utf32-z9.c: New File.
 	* sysdeps/s390/utf16-utf32-z9.c: Move ifunc resolvers to multiarch
 	folder and define ifunc versions depending on HAVE_[FROM|TO]_[C|VX].
diff --git a/sysdeps/s390/multiarch/utf8-utf32-z9.c b/sysdeps/s390/multiarch/utf8-utf32-z9.c
new file mode 100644
index 0000000..faf1f46
--- /dev/null
+++ b/sysdeps/s390/multiarch/utf8-utf32-z9.c
@@ -0,0 +1,48 @@
+/* Conversion between UTF-8 and UTF-32 - multiarch s390 version.
+
+   Copyright (C) 2017 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/>.  */
+
+#include <sysdeps/s390/utf8-utf32-z9.c>
+#include <ifunc-resolve.h>
+
+#undef FROM_LOOP
+#define FROM_LOOP	__from_utf8_loop
+#undef TO_LOOP
+#define TO_LOOP		__to_utf8_loop
+
+#define _SINGLE_NAME(NAME) NAME##_single
+#define SINGLE_NAME(NAME) _SINGLE_NAME(NAME)
+strong_alias (SINGLE_NAME (FROM_LOOP_DEFAULT), SINGLE_NAME (FROM_LOOP))
+strong_alias (SINGLE_NAME (TO_LOOP_DEFAULT), SINGLE_NAME (TO_LOOP))
+
+/* Generate ifunc'ed loop functions for FROM/TO_LOOP.  */
+s390_libc_ifunc_expr (FROM_LOOP_DEFAULT, FROM_LOOP,
+		      (HAVE_FROM_VX && (hwcap & HWCAP_S390_VX))
+		      ? FROM_LOOP_VX
+		      : (HAVE_FROM_CU && (hwcap & HWCAP_S390_ZARCH
+					  && hwcap & HWCAP_S390_HIGH_GPRS
+					  && hwcap & HWCAP_S390_ETF3EH))
+			? FROM_LOOP_CU
+			: FROM_LOOP_DEFAULT);
+
+s390_libc_ifunc_expr (TO_LOOP_DEFAULT, TO_LOOP,
+		      (HAVE_TO_VX && (hwcap & HWCAP_S390_VX))
+		      ? TO_LOOP_VX
+		      : TO_LOOP_DEFAULT);
+
+#include <iconv/skeleton.c>
diff --git a/sysdeps/s390/utf8-utf32-z9.c b/sysdeps/s390/utf8-utf32-z9.c
index 6d8be42..57572fa 100644
--- a/sysdeps/s390/utf8-utf32-z9.c
+++ b/sysdeps/s390/utf8-utf32-z9.c
@@ -27,8 +27,35 @@
 #include <dlfcn.h>
 #include <stdint.h>
 #include <unistd.h>
-#include <dl-procinfo.h>
 #include <gconv.h>
+#include <string.h>
+
+/* Select which versions should be defined depending on support
+   for multiarch, vector and used minimum architecture level.  */
+#ifdef HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT
+# define HAVE_FROM_C		0
+# define FROM_LOOP_DEFAULT	FROM_LOOP_CU
+#else
+# define HAVE_FROM_C		1
+# define FROM_LOOP_DEFAULT	FROM_LOOP_C
+#endif
+
+#define HAVE_TO_C		1
+#define TO_LOOP_DEFAULT		TO_LOOP_C
+
+#if defined HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT || defined USE_MULTIARCH
+# define HAVE_FROM_CU		1
+#else
+# define HAVE_FROM_CU		0
+#endif
+
+#if defined HAVE_S390_VX_ASM_SUPPORT && defined USE_MULTIARCH
+# define HAVE_FROM_VX		1
+# define HAVE_TO_VX		1
+#else
+# define HAVE_FROM_VX		0
+# define HAVE_TO_VX		0
+#endif
 
 #if defined HAVE_S390_VX_GCC_SUPPORT
 # define ASM_CLOBBER_VR(NR) , NR
@@ -48,8 +75,8 @@
 #define MIN_NEEDED_FROM		1
 #define MAX_NEEDED_FROM		6
 #define MIN_NEEDED_TO		4
-#define FROM_LOOP		__from_utf8_loop
-#define TO_LOOP			__to_utf8_loop
+#define FROM_LOOP		FROM_LOOP_DEFAULT
+#define TO_LOOP			TO_LOOP_DEFAULT
 #define FROM_DIRECTION		(dir == from_utf8)
 #define ONE_DIRECTION           0
 
@@ -303,12 +330,9 @@ gconv_end (struct __gconv_step *data)
     STANDARD_FROM_LOOP_ERR_HANDLER (i);					\
   }
 
-/* This hardware routine uses the Convert UTF8 to UTF32 (cu14) instruction.  */
-#define BODY_FROM_ETF3EH BODY_FROM_HW (HARDWARE_CONVERT ("cu14 %0, %1, 1"))
-
-
+#if HAVE_FROM_C == 1
 /* The software routine is copied from gconv_simple.c.  */
-#define BODY_FROM_C							\
+# define BODY_FROM_C							\
   {									\
     /* Next input byte.  */						\
     uint32_t ch = *inptr;						\
@@ -408,7 +432,50 @@ gconv_end (struct __gconv_step *data)
     outptr += sizeof (uint32_t);					\
   }
 
-#define HW_FROM_VX							\
+/* These definitions apply to the UTF-8 to UTF-32 direction.  The
+   software implementation for UTF-8 still supports multibyte
+   characters up to 6 bytes whereas the hardware variant does not.  */
+# define MIN_NEEDED_INPUT	MIN_NEEDED_FROM
+# define MAX_NEEDED_INPUT	MAX_NEEDED_FROM
+# define MIN_NEEDED_OUTPUT	MIN_NEEDED_TO
+# define FROM_LOOP_C		__from_utf8_loop_c
+# define LOOPFCT		FROM_LOOP_C
+
+# define LOOP_NEED_FLAGS
+
+# define STORE_REST		STORE_REST_COMMON
+# define UNPACK_BYTES		UNPACK_BYTES_COMMON
+# define CLEAR_STATE		CLEAR_STATE_COMMON
+# define BODY			BODY_FROM_C
+# include <iconv/loop.c>
+#else
+# define FROM_LOOP_C		NULL
+#endif /* HAVE_FROM_C != 1  */
+
+#if HAVE_FROM_CU == 1
+/* This hardware routine uses the Convert UTF8 to UTF32 (cu14) instruction.  */
+# define BODY_FROM_ETF3EH BODY_FROM_HW (HARDWARE_CONVERT ("cu14 %0, %1, 1"))
+
+/* Generate loop-function with hardware utf-convert instruction.  */
+# define MIN_NEEDED_INPUT	MIN_NEEDED_FROM
+# define MAX_NEEDED_INPUT	MAX_NEEDED_FROM
+# define MIN_NEEDED_OUTPUT	MIN_NEEDED_TO
+# define FROM_LOOP_CU		__from_utf8_loop_etf3eh
+# define LOOPFCT		FROM_LOOP_CU
+
+# define LOOP_NEED_FLAGS
+
+# define STORE_REST		STORE_REST_COMMON
+# define UNPACK_BYTES		UNPACK_BYTES_COMMON
+# define CLEAR_STATE		CLEAR_STATE_COMMON
+# define BODY			BODY_FROM_ETF3EH
+# include <iconv/loop.c>
+#else
+# define FROM_LOOP_CU		NULL
+#endif /* HAVE_FROM_CU != 1  */
+
+#if HAVE_FROM_VX == 1
+# define HW_FROM_VX							\
   {									\
     register const unsigned char* pInput asm ("8") = inptr;		\
     register size_t inlen asm ("9") = inend - inptr;			\
@@ -500,45 +567,14 @@ gconv_end (struct __gconv_step *data)
     inptr = pInput;							\
     outptr = pOutput;							\
   }
-#define BODY_FROM_VX BODY_FROM_HW (HW_FROM_VX)
+# define BODY_FROM_VX BODY_FROM_HW (HW_FROM_VX)
 
-/* These definitions apply to the UTF-8 to UTF-32 direction.  The
-   software implementation for UTF-8 still supports multibyte
-   characters up to 6 bytes whereas the hardware variant does not.  */
-#define MIN_NEEDED_INPUT	MIN_NEEDED_FROM
-#define MAX_NEEDED_INPUT	MAX_NEEDED_FROM
-#define MIN_NEEDED_OUTPUT	MIN_NEEDED_TO
-#define LOOPFCT			__from_utf8_loop_c
-
-#define LOOP_NEED_FLAGS
-
-#define STORE_REST		STORE_REST_COMMON
-#define UNPACK_BYTES		UNPACK_BYTES_COMMON
-#define CLEAR_STATE		CLEAR_STATE_COMMON
-#define BODY			BODY_FROM_C
-#include <iconv/loop.c>
-
-
-/* Generate loop-function with hardware utf-convert instruction.  */
-#define MIN_NEEDED_INPUT	MIN_NEEDED_FROM
-#define MAX_NEEDED_INPUT	MAX_NEEDED_FROM
-#define MIN_NEEDED_OUTPUT	MIN_NEEDED_TO
-#define LOOPFCT			__from_utf8_loop_etf3eh
-
-#define LOOP_NEED_FLAGS
-
-#define STORE_REST		STORE_REST_COMMON
-#define UNPACK_BYTES		UNPACK_BYTES_COMMON
-#define CLEAR_STATE		CLEAR_STATE_COMMON
-#define BODY			BODY_FROM_ETF3EH
-#include <iconv/loop.c>
-
-#if defined HAVE_S390_VX_ASM_SUPPORT
-/* Generate loop-function with hardware vector instructions.  */
+/* Generate loop-function with hardware vector and utf-convert instructions.  */
 # define MIN_NEEDED_INPUT	MIN_NEEDED_FROM
 # define MAX_NEEDED_INPUT	MAX_NEEDED_FROM
 # define MIN_NEEDED_OUTPUT	MIN_NEEDED_TO
-# define LOOPFCT		__from_utf8_loop_vx
+# define FROM_LOOP_VX		__from_utf8_loop_vx
+# define LOOPFCT		FROM_LOOP_VX
 
 # define LOOP_NEED_FLAGS
 
@@ -547,33 +583,13 @@ gconv_end (struct __gconv_step *data)
 # define CLEAR_STATE		CLEAR_STATE_COMMON
 # define BODY			BODY_FROM_VX
 # include <iconv/loop.c>
-#endif
-
-
-/* Generate ifunc'ed loop function.  */
-__typeof(__from_utf8_loop_c)
-__attribute__ ((ifunc ("__from_utf8_loop_resolver")))
-__from_utf8_loop;
-
-static void *
-__from_utf8_loop_resolver (unsigned long int dl_hwcap)
-{
-#if defined HAVE_S390_VX_ASM_SUPPORT
-  if (dl_hwcap & HWCAP_S390_VX)
-    return __from_utf8_loop_vx;
-  else
-#endif
-  if (dl_hwcap & HWCAP_S390_ZARCH && dl_hwcap & HWCAP_S390_HIGH_GPRS
-      && dl_hwcap & HWCAP_S390_ETF3EH)
-    return __from_utf8_loop_etf3eh;
-  else
-    return __from_utf8_loop_c;
-}
-
-strong_alias (__from_utf8_loop_c_single, __from_utf8_loop_single)
+#else
+# define FROM_LOOP_VX		NULL
+#endif /* HAVE_FROM_VX != 1  */
 
+#if HAVE_TO_C == 1
 /* The software routine mimics the S/390 cu41 instruction.  */
-#define BODY_TO_C						\
+# define BODY_TO_C						\
   {								\
     uint32_t wc = *((const uint32_t *) inptr);			\
 								\
@@ -657,8 +673,22 @@ strong_alias (__from_utf8_loop_c_single, __from_utf8_loop_single)
     inptr += 4;							\
   }
 
+/* Generate loop-function with software routing.  */
+# define MIN_NEEDED_INPUT	MIN_NEEDED_TO
+# define MIN_NEEDED_OUTPUT	MIN_NEEDED_FROM
+# define MAX_NEEDED_OUTPUT	MAX_NEEDED_FROM
+# define TO_LOOP_C		__to_utf8_loop_c
+# define LOOPFCT		TO_LOOP_C
+# define BODY			BODY_TO_C
+# define LOOP_NEED_FLAGS
+# include <iconv/loop.c>
+#else
+# define TO_LOOP_C		NULL
+#endif /* HAVE_TO_C != 1  */
+
+#if HAVE_TO_VX == 1
 /* The hardware routine uses the S/390 vector instructions.  */
-#define BODY_TO_VX							\
+# define BODY_TO_VX							\
   {									\
     size_t inlen = inend - inptr;					\
     size_t outlen = outend - outptr;					\
@@ -820,43 +850,22 @@ strong_alias (__from_utf8_loop_c_single, __from_utf8_loop_single)
     STANDARD_TO_LOOP_ERR_HANDLER (4);					\
   }
 
-/* Generate loop-function with software routing.  */
-#define MIN_NEEDED_INPUT	MIN_NEEDED_TO
-#define MIN_NEEDED_OUTPUT	MIN_NEEDED_FROM
-#define MAX_NEEDED_OUTPUT	MAX_NEEDED_FROM
-#define LOOPFCT			__to_utf8_loop_c
-#define BODY			BODY_TO_C
-#define LOOP_NEED_FLAGS
-#include <iconv/loop.c>
-
-#if defined HAVE_S390_VX_ASM_SUPPORT
-/* Generate loop-function with hardware vector and utf-convert instructions.  */
+/* Generate loop-function with hardware vector instructions.  */
 # define MIN_NEEDED_INPUT	MIN_NEEDED_TO
 # define MIN_NEEDED_OUTPUT	MIN_NEEDED_FROM
 # define MAX_NEEDED_OUTPUT	MAX_NEEDED_FROM
-# define LOOPFCT		__to_utf8_loop_vx
+# define TO_LOOP_VX		__to_utf8_loop_vx
+# define LOOPFCT		TO_LOOP_VX
 # define BODY			BODY_TO_VX
 # define LOOP_NEED_FLAGS
 # include <iconv/loop.c>
+#else
+# define TO_LOOP_VX		NULL
+#endif /* HAVE_TO_VX != 1  */
+
+/* This file also exists in sysdeps/s390/multiarch/ which
+   generates ifunc resolvers for FROM/TO_LOOP functions
+   and includes iconv/skeleton.c afterwards.  */
+#if ! defined USE_MULTIARCH
+# include <iconv/skeleton.c>
 #endif
-
-/* Generate ifunc'ed loop function.  */
-__typeof(__to_utf8_loop_c)
-__attribute__ ((ifunc ("__to_utf8_loop_resolver")))
-__to_utf8_loop;
-
-static void *
-__to_utf8_loop_resolver (unsigned long int dl_hwcap)
-{
-#if defined HAVE_S390_VX_ASM_SUPPORT
-  if (dl_hwcap & HWCAP_S390_VX)
-    return __to_utf8_loop_vx;
-  else
-#endif
-    return __to_utf8_loop_c;
-}
-
-strong_alias (__to_utf8_loop_c_single, __to_utf8_loop_single)
-
-
-#include <iconv/skeleton.c>

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=85286aaf1dd7216a64964752d147c5ce3c4067d0

commit 85286aaf1dd7216a64964752d147c5ce3c4067d0
Author: Stefan Liebler <stli@linux.vnet.ibm.com>
Date:   Fri Apr 21 15:30:00 2017 +0200

    S390: Move utf16-utf32-z9.c to multiarch folder and use s390_libc_ifunc_expr macro.
    
    The utf16-utf32-z9.c iconv module is using ifunc and thus the ifunc part should
    be in multiarch folder.  Otherwise ifunc is used even if you configure
    with --disable-multi-arch.
    
    This patch moves the ifunc resolvers to the new file
    sysdeps/s390/multiarch/utf16-utf32-z9.c. The resolvers are now implemented
    with s390_libc_ifunc_expr macro instead of using gcc attribute ifunc directly.
    
    The ifunc versions are implemented in sysdeps/s390/utf16-utf32-z9.c.
    Each version is only implemented if needed or supported.  Therefore there is
    a block at beginning of the file which selects the versions which should be
    defined depending on support for multiarch, vector-support and used minimum
    architecture level.  This block defines HAVE_[FROM|TO]_[C|VX] to 1 or 0.
    The code below is rearranged and surrounded
    by #if HAVE_[FROM|TO]_[C|VX] == 1.  There is no functional change.
    
    ChangeLog:
    
    	* sysdeps/s390/multiarch/utf16-utf32-z9.c: New File.
    	* sysdeps/s390/utf16-utf32-z9.c: Move ifunc resolvers to multiarch
    	folder and define ifunc versions depending on HAVE_[FROM|TO]_[C|VX].
    	(HAVE_FROM_C, HAVE_FROM_VX, HAVE_TO_C, HAVE_TO_VX, FROM_LOOP_DEFAULT,
    	FROM_LOOP_C, FROM_LOOP_VX, TO_LOOP_DEFAULT, TO_LOOP_C, TO_LOOP_VX):
    	New Define.

diff --git a/ChangeLog b/ChangeLog
index dd0e081..74de162 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2017-04-21  Stefan Liebler  <stli@linux.vnet.ibm.com>
 
+	* sysdeps/s390/multiarch/utf16-utf32-z9.c: New File.
+	* sysdeps/s390/utf16-utf32-z9.c: Move ifunc resolvers to multiarch
+	folder and define ifunc versions depending on HAVE_[FROM|TO]_[C|VX].
+	(HAVE_FROM_C, HAVE_FROM_VX, HAVE_TO_C, HAVE_TO_VX, FROM_LOOP_DEFAULT,
+	FROM_LOOP_C, FROM_LOOP_VX, TO_LOOP_DEFAULT, TO_LOOP_C, TO_LOOP_VX):
+	New Define.
+
+2017-04-21  Stefan Liebler  <stli@linux.vnet.ibm.com>
+
 	* sysdeps/s390/multiarch/utf8-utf16-z9.c: New File.
 	* sysdeps/s390/utf8-utf16-z9.c: Move ifunc resolvers to multiarch
 	folder and define ifunc versions depending on HAVE_[FROM|TO]_[C|CU|VX].
diff --git a/sysdeps/s390/multiarch/utf16-utf32-z9.c b/sysdeps/s390/multiarch/utf16-utf32-z9.c
new file mode 100644
index 0000000..6e64169
--- /dev/null
+++ b/sysdeps/s390/multiarch/utf16-utf32-z9.c
@@ -0,0 +1,44 @@
+/* Conversion between UTF-16 and UTF-32 BE/internal - multiarch s390 version.
+
+   Copyright (C) 2017 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/>.  */
+
+#include <sysdeps/s390/utf16-utf32-z9.c>
+#include <ifunc-resolve.h>
+
+#undef FROM_LOOP
+#define FROM_LOOP	__from_utf16_loop
+#undef TO_LOOP
+#define TO_LOOP		__to_utf16_loop
+
+#define _SINGLE_NAME(NAME) NAME##_single
+#define SINGLE_NAME(NAME) _SINGLE_NAME(NAME)
+strong_alias (SINGLE_NAME (FROM_LOOP_DEFAULT), SINGLE_NAME (FROM_LOOP))
+strong_alias (SINGLE_NAME (TO_LOOP_DEFAULT), SINGLE_NAME (TO_LOOP))
+
+/* Generate ifunc'ed loop functions for FROM/TO_LOOP.  */
+s390_libc_ifunc_expr (FROM_LOOP_DEFAULT, FROM_LOOP,
+		      (HAVE_FROM_VX && (hwcap & HWCAP_S390_VX))
+		      ? FROM_LOOP_VX
+		      : FROM_LOOP_DEFAULT);
+
+s390_libc_ifunc_expr (TO_LOOP_DEFAULT, TO_LOOP,
+		      (HAVE_TO_VX && (hwcap & HWCAP_S390_VX))
+		      ? TO_LOOP_VX
+		      : TO_LOOP_DEFAULT);
+
+#include <iconv/skeleton.c>
diff --git a/sysdeps/s390/utf16-utf32-z9.c b/sysdeps/s390/utf16-utf32-z9.c
index 8b0b1b3..7a174ea 100644
--- a/sysdeps/s390/utf16-utf32-z9.c
+++ b/sysdeps/s390/utf16-utf32-z9.c
@@ -27,8 +27,23 @@
 #include <dlfcn.h>
 #include <stdint.h>
 #include <unistd.h>
-#include <dl-procinfo.h>
 #include <gconv.h>
+#include <string.h>
+
+/* Select which versions should be defined depending on support
+   for multiarch, vector and used minimum architecture level.  */
+#define HAVE_FROM_C		1
+#define FROM_LOOP_DEFAULT	FROM_LOOP_C
+#define HAVE_TO_C		1
+#define TO_LOOP_DEFAULT		TO_LOOP_C
+
+#if defined HAVE_S390_VX_ASM_SUPPORT && defined USE_MULTIARCH
+# define HAVE_FROM_VX		1
+# define HAVE_TO_VX		1
+#else
+# define HAVE_FROM_VX		0
+# define HAVE_TO_VX		0
+#endif
 
 #if defined HAVE_S390_VX_GCC_SUPPORT
 # define ASM_CLOBBER_VR(NR) , NR
@@ -53,8 +68,8 @@
 #define MIN_NEEDED_FROM		2
 #define MAX_NEEDED_FROM		4
 #define MIN_NEEDED_TO		4
-#define FROM_LOOP		__from_utf16_loop
-#define TO_LOOP			__to_utf16_loop
+#define FROM_LOOP		FROM_LOOP_DEFAULT
+#define TO_LOOP			TO_LOOP_DEFAULT
 #define FROM_DIRECTION		(dir == from_utf16)
 #define ONE_DIRECTION           0
 
@@ -174,9 +189,10 @@ gconv_end (struct __gconv_step *data)
 
 /* Conversion function from UTF-16 to UTF-32 internal/BE.  */
 
+#if HAVE_FROM_C == 1
 /* The software routine is copied from utf-16.c (minus bytes
    swapping).  */
-#define BODY_FROM_C							\
+# define BODY_FROM_C							\
   {									\
     uint16_t u1 = get16 (inptr);					\
 									\
@@ -220,7 +236,22 @@ gconv_end (struct __gconv_step *data)
     outptr += 4;							\
   }
 
-#define BODY_FROM_VX							\
+
+/* Generate loop-function with software routing.  */
+# define MIN_NEEDED_INPUT	MIN_NEEDED_FROM
+# define MAX_NEEDED_INPUT	MAX_NEEDED_FROM
+# define MIN_NEEDED_OUTPUT	MIN_NEEDED_TO
+# define FROM_LOOP_C		__from_utf16_loop_c
+# define LOOPFCT		FROM_LOOP_C
+# define LOOP_NEED_FLAGS
+# define BODY			BODY_FROM_C
+# include <iconv/loop.c>
+#else
+# define FROM_LOOP_C		NULL
+#endif /* HAVE_FROM_C != 1  */
+
+#if HAVE_FROM_VX == 1
+# define BODY_FROM_VX							\
   {									\
     size_t inlen = inend - inptr;					\
     size_t outlen = outend - outptr;					\
@@ -255,7 +286,7 @@ gconv_end (struct __gconv_step *data)
 		  /* Setup to check for ch >= 0xd800 && ch <= 0xdfff. (v30, v31)  */ \
 		  "9:  .short 0xd800,0xdfff,0x0,0x0,0x0,0x0,0x0,0x0\n\t" \
 		  "    .short 0xa000,0xc000,0x0,0x0,0x0,0x0,0x0,0x0\n\t" \
-		  /* At least on uint16_t is in range of surrogates.	\
+		  /* At least one uint16_t is in range of surrogates.	\
 		     Store the preceding chars.  */			\
 		  "10: vlgvb %[R_TMP],%%v19,7\n\t"			\
 		  "    vuplhh %%v17,%%v16\n\t"				\
@@ -351,52 +382,26 @@ gconv_end (struct __gconv_step *data)
   }
 
 
-/* Generate loop-function with software routing.  */
-#define MIN_NEEDED_INPUT	MIN_NEEDED_FROM
-#define MAX_NEEDED_INPUT	MAX_NEEDED_FROM
-#define MIN_NEEDED_OUTPUT	MIN_NEEDED_TO
-#if defined HAVE_S390_VX_ASM_SUPPORT
-# define LOOPFCT		__from_utf16_loop_c
-# define LOOP_NEED_FLAGS
-# define BODY			BODY_FROM_C
-# include <iconv/loop.c>
-
 /* Generate loop-function with hardware vector instructions.  */
 # define MIN_NEEDED_INPUT	MIN_NEEDED_FROM
 # define MAX_NEEDED_INPUT	MAX_NEEDED_FROM
 # define MIN_NEEDED_OUTPUT	MIN_NEEDED_TO
-# define LOOPFCT		__from_utf16_loop_vx
+# define FROM_LOOP_VX		__from_utf16_loop_vx
+# define LOOPFCT		FROM_LOOP_VX
 # define LOOP_NEED_FLAGS
 # define BODY			BODY_FROM_VX
 # include <iconv/loop.c>
-
-/* Generate ifunc'ed loop function.  */
-__typeof(__from_utf16_loop_c)
-__attribute__ ((ifunc ("__from_utf16_loop_resolver")))
-__from_utf16_loop;
-
-static void *
-__from_utf16_loop_resolver (unsigned long int dl_hwcap)
-{
-  if (dl_hwcap & HWCAP_S390_VX)
-    return __from_utf16_loop_vx;
-  else
-    return __from_utf16_loop_c;
-}
-
-strong_alias (__from_utf16_loop_c_single, __from_utf16_loop_single)
 #else
-# define LOOPFCT		FROM_LOOP
-# define LOOP_NEED_FLAGS
-# define BODY			BODY_FROM_C
-# include <iconv/loop.c>
-#endif
+# define FROM_LOOP_VX		NULL
+#endif /* HAVE_FROM_VX != 1  */
+
 
 /* Conversion from UTF-32 internal/BE to UTF-16.  */
 
+#if HAVE_TO_C == 1
 /* The software routine is copied from utf-16.c (minus bytes
    swapping).  */
-#define BODY_TO_C							\
+# define BODY_TO_C							\
   {									\
     uint32_t c = get32 (inptr);						\
 									\
@@ -439,7 +444,21 @@ strong_alias (__from_utf16_loop_c_single, __from_utf16_loop_single)
     inptr += 4;								\
   }
 
-#define BODY_TO_VX							\
+/* Generate loop-function with software routing.  */
+# define MIN_NEEDED_INPUT	MIN_NEEDED_TO
+# define MIN_NEEDED_OUTPUT	MIN_NEEDED_FROM
+# define MAX_NEEDED_OUTPUT	MAX_NEEDED_FROM
+# define TO_LOOP_C		__to_utf16_loop_c
+# define LOOPFCT		TO_LOOP_C
+# define LOOP_NEED_FLAGS
+# define BODY			BODY_TO_C
+# include <iconv/loop.c>
+#else
+# define TO_LOOP_C		NULL
+#endif /* HAVE_TO_C != 1  */
+
+#if HAVE_TO_VX == 1
+# define BODY_TO_VX							\
   {									\
     size_t inlen = inend - inptr;					\
     size_t outlen = outend - outptr;					\
@@ -563,43 +582,22 @@ strong_alias (__from_utf16_loop_c_single, __from_utf16_loop_single)
     STANDARD_TO_LOOP_ERR_HANDLER (4);					\
   }
 
-/* Generate loop-function with software routing.  */
-#define MIN_NEEDED_INPUT	MIN_NEEDED_TO
-#define MIN_NEEDED_OUTPUT	MIN_NEEDED_FROM
-#define MAX_NEEDED_OUTPUT	MAX_NEEDED_FROM
-#define LOOPFCT			__to_utf16_loop_c
-#define LOOP_NEED_FLAGS
-#define BODY			BODY_TO_C
-#include <iconv/loop.c>
-
-#if defined HAVE_S390_VX_ASM_SUPPORT
 /* Generate loop-function with hardware vector instructions.  */
 # define MIN_NEEDED_INPUT	MIN_NEEDED_TO
 # define MIN_NEEDED_OUTPUT	MIN_NEEDED_FROM
 # define MAX_NEEDED_OUTPUT	MAX_NEEDED_FROM
-# define LOOPFCT		__to_utf16_loop_vx
+# define TO_LOOP_VX		__to_utf16_loop_vx
+# define LOOPFCT		TO_LOOP_VX
 # define LOOP_NEED_FLAGS
 # define BODY			BODY_TO_VX
 # include <iconv/loop.c>
+#else
+# define TO_LOOP_VX		NULL
+#endif /* HAVE_TO_VX != 1  */
+
+/* This file also exists in sysdeps/s390/multiarch/ which
+   generates ifunc resolvers for FROM/TO_LOOP functions
+   and includes iconv/skeleton.c afterwards.  */
+#if ! defined USE_MULTIARCH
+# include <iconv/skeleton.c>
 #endif
-
-/* Generate ifunc'ed loop function.  */
-__typeof(__to_utf16_loop_c)
-__attribute__ ((ifunc ("__to_utf16_loop_resolver")))
-__to_utf16_loop;
-
-static void *
-__to_utf16_loop_resolver (unsigned long int dl_hwcap)
-{
-#if defined HAVE_S390_VX_ASM_SUPPORT
-  if (dl_hwcap & HWCAP_S390_VX)
-    return __to_utf16_loop_vx;
-  else
-#endif
-    return __to_utf16_loop_c;
-}
-
-strong_alias (__to_utf16_loop_c_single, __to_utf16_loop_single)
-
-
-#include <iconv/skeleton.c>

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=df6cc7ee3b2e032c6c62cedd30b1c0fefbb43018

commit df6cc7ee3b2e032c6c62cedd30b1c0fefbb43018
Author: Stefan Liebler <stli@linux.vnet.ibm.com>
Date:   Fri Apr 21 15:30:00 2017 +0200

    S390: Move utf8-utf16-z9.c to multiarch folder and use s390_libc_ifunc_expr macro.
    
    The utf8-utf16-z9.c iconv module is using ifunc and thus the ifunc part should
    be in multiarch folder.  Otherwise ifunc is used even if you configure
    with --disable-multi-arch.
    
    This patch moves the ifunc resolvers to the new file
    sysdeps/s390/multiarch/utf8-utf16-z9.c. The resolvers are now implemented
    with s390_libc_ifunc_expr macro instead of using gcc attribute ifunc directly.
    
    The ifunc versions are implemented in sysdeps/s390/utf8-utf16-z9.c.
    Each version is only implemented if needed or supported.  Therefore there is
    a block at beginning of the file which selects the versions which should be
    defined depending on support for multiarch, vector-support and used minimum
    architecture level.  This block defines HAVE_[FROM|TO]_[C|CU|VX] to 1 or 0.
    The code below is rearranged and surrounded
    by #if HAVE_[FROM|TO]_[C|CU|VX] == 1.  There is no functional change.
    
    The cu instructions are z9 zarch instructions.  As the major distros are
    already using the newer z196 as architecture level set, those instructions
    can be used as fallback version instead of the c-code.  This behaviour is
    decided at compile time via HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT.
    
    ChangeLog:
    
    	* sysdeps/s390/multiarch/utf8-utf16-z9.c: New File.
    	* sysdeps/s390/utf8-utf16-z9.c: Move ifunc resolvers to multiarch
    	folder and define ifunc versions depending on HAVE_[FROM|TO]_[C|CU|VX].
    	(HAVE_FROM_C, HAVE_FROM_CU, HAVE_FROM_VX, HAVE_TO_C, HAVE_TO_VX,
    	FROM_LOOP_DEFAULT, FROM_LOOP_C, FROM_LOOP_CU, FROM_LOOP_VX,
    	TO_LOOP_DEFAULT, TO_LOOP_C, TO_LOOP_VX): New Define.

diff --git a/ChangeLog b/ChangeLog
index 12bf100..dd0e081 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2017-04-21  Stefan Liebler  <stli@linux.vnet.ibm.com>
 
+	* sysdeps/s390/multiarch/utf8-utf16-z9.c: New File.
+	* sysdeps/s390/utf8-utf16-z9.c: Move ifunc resolvers to multiarch
+	folder and define ifunc versions depending on HAVE_[FROM|TO]_[C|CU|VX].
+	(HAVE_FROM_C, HAVE_FROM_CU, HAVE_FROM_VX, HAVE_TO_C, HAVE_TO_VX,
+	FROM_LOOP_DEFAULT, FROM_LOOP_C, FROM_LOOP_CU, FROM_LOOP_VX,
+	TO_LOOP_DEFAULT, TO_LOOP_C, TO_LOOP_VX): New Define.
+
+2017-04-21  Stefan Liebler  <stli@linux.vnet.ibm.com>
+
 	* sysdeps/s390/multiarch/ifunc-resolve.h
 	(s390_libc_ifunc_expr_init, s390_libc_ifunc_expr): New Define.
 	* sysdeps/s390/multiarch/8bit-generic.c
diff --git a/sysdeps/s390/multiarch/utf8-utf16-z9.c b/sysdeps/s390/multiarch/utf8-utf16-z9.c
new file mode 100644
index 0000000..b55ef1a
--- /dev/null
+++ b/sysdeps/s390/multiarch/utf8-utf16-z9.c
@@ -0,0 +1,48 @@
+/* Conversion between UTF-8 and UTF-16 - multiarch s390 version.
+
+   Copyright (C) 2017 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/>.  */
+
+#include <sysdeps/s390/utf8-utf16-z9.c>
+#include <ifunc-resolve.h>
+
+#undef FROM_LOOP
+#define FROM_LOOP	__from_utf8_loop
+#undef TO_LOOP
+#define TO_LOOP		__to_utf8_loop
+
+#define _SINGLE_NAME(NAME) NAME##_single
+#define SINGLE_NAME(NAME) _SINGLE_NAME(NAME)
+strong_alias (SINGLE_NAME (FROM_LOOP_DEFAULT), SINGLE_NAME (FROM_LOOP))
+strong_alias (SINGLE_NAME (TO_LOOP_DEFAULT), SINGLE_NAME (TO_LOOP))
+
+/* Generate ifunc'ed loop functions for FROM/TO_LOOP.  */
+s390_libc_ifunc_expr (FROM_LOOP_DEFAULT, FROM_LOOP,
+		      (HAVE_FROM_VX && (hwcap & HWCAP_S390_VX))
+		      ? FROM_LOOP_VX
+		      : (HAVE_FROM_CU && (hwcap & HWCAP_S390_ZARCH
+					  && hwcap & HWCAP_S390_HIGH_GPRS
+					  && hwcap & HWCAP_S390_ETF3EH))
+			? FROM_LOOP_CU
+			: FROM_LOOP_DEFAULT);
+
+s390_libc_ifunc_expr (TO_LOOP_DEFAULT, TO_LOOP,
+		      (HAVE_TO_VX && (hwcap & HWCAP_S390_VX))
+		      ? TO_LOOP_VX
+		      : TO_LOOP_DEFAULT);
+
+#include <iconv/skeleton.c>
diff --git a/sysdeps/s390/utf8-utf16-z9.c b/sysdeps/s390/utf8-utf16-z9.c
index 20de29a..42163e7 100644
--- a/sysdeps/s390/utf8-utf16-z9.c
+++ b/sysdeps/s390/utf8-utf16-z9.c
@@ -1,4 +1,4 @@
-/* Conversion between UTF-16 and UTF-32 BE/internal.
+/* Conversion between UTF-8 and UTF-16 - s390 version.
 
    This module uses the Z9-109 variants of the Convert Unicode
    instructions.
@@ -27,8 +27,35 @@
 #include <dlfcn.h>
 #include <stdint.h>
 #include <unistd.h>
-#include <dl-procinfo.h>
 #include <gconv.h>
+#include <string.h>
+
+/* Select which versions should be defined depending on support
+   for multiarch, vector and used minimum architecture level.  */
+#ifdef HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT
+# define HAVE_FROM_C		0
+# define FROM_LOOP_DEFAULT	FROM_LOOP_CU
+#else
+# define HAVE_FROM_C		1
+# define FROM_LOOP_DEFAULT	FROM_LOOP_C
+#endif
+
+#define HAVE_TO_C		1
+#define TO_LOOP_DEFAULT		TO_LOOP_C
+
+#if defined HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT || defined USE_MULTIARCH
+# define HAVE_FROM_CU		1
+#else
+# define HAVE_FROM_CU		0
+#endif
+
+#if defined HAVE_S390_VX_ASM_SUPPORT && defined USE_MULTIARCH
+# define HAVE_FROM_VX		1
+# define HAVE_TO_VX		1
+#else
+# define HAVE_FROM_VX		0
+# define HAVE_TO_VX		0
+#endif
 
 #if defined HAVE_S390_VX_GCC_SUPPORT
 # define ASM_CLOBBER_VR(NR) , NR
@@ -49,8 +76,8 @@
 #define MAX_NEEDED_FROM		4
 #define MIN_NEEDED_TO		2
 #define MAX_NEEDED_TO		4
-#define FROM_LOOP		__from_utf8_loop
-#define TO_LOOP			__to_utf8_loop
+#define FROM_LOOP		FROM_LOOP_DEFAULT
+#define TO_LOOP			TO_LOOP_DEFAULT
 #define FROM_DIRECTION		(dir == from_utf8)
 #define ONE_DIRECTION           0
 
@@ -214,9 +241,8 @@ gconv_end (struct __gconv_step *data)
     STANDARD_FROM_LOOP_ERR_HANDLER (i);					\
   }
 
-#define BODY_FROM_ETF3EH BODY_FROM_HW (HARDWARE_CONVERT ("cu12 %0, %1, 1"))
-
-#define HW_FROM_VX							\
+#if HAVE_FROM_VX == 1
+# define HW_FROM_VX							\
   {									\
     register const unsigned char* pInput asm ("8") = inptr;		\
     register size_t inlen asm ("9") = inend - inptr;			\
@@ -291,11 +317,42 @@ gconv_end (struct __gconv_step *data)
     inptr = pInput;							\
     outptr = pOutput;							\
   }
-#define BODY_FROM_VX BODY_FROM_HW (HW_FROM_VX)
+# define BODY_FROM_VX BODY_FROM_HW (HW_FROM_VX)
 
+/* Generate loop-function with hardware vector and utf-convert instructions.  */
+# define MIN_NEEDED_INPUT	MIN_NEEDED_FROM
+# define MAX_NEEDED_INPUT	MAX_NEEDED_FROM
+# define MIN_NEEDED_OUTPUT	MIN_NEEDED_TO
+# define MAX_NEEDED_OUTPUT	MAX_NEEDED_TO
+# define FROM_LOOP_VX		__from_utf8_loop_vx
+# define LOOPFCT		FROM_LOOP_VX
+# define LOOP_NEED_FLAGS
+# define BODY			BODY_FROM_VX
+# include <iconv/loop.c>
+#else
+# define FROM_LOOP_VX		NULL
+#endif /* HAVE_FROM_VX != 1  */
+
+#if HAVE_FROM_CU == 1
+# define BODY_FROM_ETF3EH BODY_FROM_HW (HARDWARE_CONVERT ("cu12 %0, %1, 1"))
 
+/* Generate loop-function with hardware utf-convert instruction.  */
+# define MIN_NEEDED_INPUT	MIN_NEEDED_FROM
+# define MAX_NEEDED_INPUT	MAX_NEEDED_FROM
+# define MIN_NEEDED_OUTPUT	MIN_NEEDED_TO
+# define MAX_NEEDED_OUTPUT	MAX_NEEDED_TO
+# define FROM_LOOP_CU		__from_utf8_loop_etf3eh
+# define LOOPFCT		FROM_LOOP_CU
+# define LOOP_NEED_FLAGS
+# define BODY			BODY_FROM_ETF3EH
+# include <iconv/loop.c>
+#else
+# define FROM_LOOP_CU		NULL
+#endif /* HAVE_FROM_CU != 1  */
+
+#if HAVE_FROM_C == 1
 /* The software implementation is based on the code in gconv_simple.c.  */
-#define BODY_FROM_C							\
+# define BODY_FROM_C							\
   {									\
     /* Next input byte.  */						\
     uint16_t ch = *inptr;						\
@@ -443,66 +500,26 @@ gconv_end (struct __gconv_step *data)
   }
 
 /* Generate loop-function with software implementation.  */
-#define MIN_NEEDED_INPUT	MIN_NEEDED_FROM
-#define MAX_NEEDED_INPUT	MAX_NEEDED_FROM
-#define MIN_NEEDED_OUTPUT	MIN_NEEDED_TO
-#define MAX_NEEDED_OUTPUT	MAX_NEEDED_TO
-#define LOOPFCT			__from_utf8_loop_c
-#define LOOP_NEED_FLAGS
-#define BODY			BODY_FROM_C
-#include <iconv/loop.c>
-
-/* Generate loop-function with hardware utf-convert instruction.  */
-#define MIN_NEEDED_INPUT	MIN_NEEDED_FROM
-#define MAX_NEEDED_INPUT	MAX_NEEDED_FROM
-#define MIN_NEEDED_OUTPUT	MIN_NEEDED_TO
-#define MAX_NEEDED_OUTPUT	MAX_NEEDED_TO
-#define LOOPFCT			__from_utf8_loop_etf3eh
-#define LOOP_NEED_FLAGS
-#define BODY			BODY_FROM_ETF3EH
-#include <iconv/loop.c>
-
-#if defined HAVE_S390_VX_ASM_SUPPORT
-/* Generate loop-function with hardware vector and utf-convert instructions.  */
 # define MIN_NEEDED_INPUT	MIN_NEEDED_FROM
 # define MAX_NEEDED_INPUT	MAX_NEEDED_FROM
 # define MIN_NEEDED_OUTPUT	MIN_NEEDED_TO
 # define MAX_NEEDED_OUTPUT	MAX_NEEDED_TO
-# define LOOPFCT		__from_utf8_loop_vx
+# define FROM_LOOP_C		__from_utf8_loop_c
+# define LOOPFCT		FROM_LOOP_C
 # define LOOP_NEED_FLAGS
-# define BODY			BODY_FROM_VX
+# define BODY			BODY_FROM_C
 # include <iconv/loop.c>
-#endif
-
-
-/* Generate ifunc'ed loop function.  */
-__typeof(__from_utf8_loop_c)
-__attribute__ ((ifunc ("__from_utf8_loop_resolver")))
-__from_utf8_loop;
-
-static void *
-__from_utf8_loop_resolver (unsigned long int dl_hwcap)
-{
-#if defined HAVE_S390_VX_ASM_SUPPORT
-  if (dl_hwcap & HWCAP_S390_VX)
-    return __from_utf8_loop_vx;
-  else
-#endif
-  if (dl_hwcap & HWCAP_S390_ZARCH && dl_hwcap & HWCAP_S390_HIGH_GPRS
-      && dl_hwcap & HWCAP_S390_ETF3EH)
-    return __from_utf8_loop_etf3eh;
-  else
-    return __from_utf8_loop_c;
-}
-
-strong_alias (__from_utf8_loop_c_single, __from_utf8_loop_single)
+#else
+# define FROM_LOOP_C		NULL
+#endif /* HAVE_FROM_C != 1  */
 
 /* Conversion from UTF-16 to UTF-8.  */
 
+#if HAVE_TO_C == 1
 /* The software routine is based on the functionality of the S/390
    hardware instruction (cu21) as described in the Principles of
    Operation.  */
-#define BODY_TO_C							\
+# define BODY_TO_C							\
   {									\
     uint16_t c = get16 (inptr);						\
 									\
@@ -601,7 +618,22 @@ strong_alias (__from_utf8_loop_c_single, __from_utf8_loop_single)
     inptr += 2;								\
   }
 
-#define BODY_TO_VX							\
+/* Generate loop-function with software implementation.  */
+# define MIN_NEEDED_INPUT	MIN_NEEDED_TO
+# define MAX_NEEDED_INPUT	MAX_NEEDED_TO
+# define MIN_NEEDED_OUTPUT	MIN_NEEDED_FROM
+# define MAX_NEEDED_OUTPUT	MAX_NEEDED_FROM
+# define TO_LOOP_C		__to_utf8_loop_c
+# define LOOPFCT		TO_LOOP_C
+# define BODY                   BODY_TO_C
+# define LOOP_NEED_FLAGS
+# include <iconv/loop.c>
+#else
+# define TO_LOOP_C		NULL
+#endif /* HAVE_TO_C != 1  */
+
+#if HAVE_TO_VX == 1
+# define BODY_TO_VX							\
   {									\
     size_t inlen  = inend - inptr;					\
     size_t outlen  = outend - outptr;					\
@@ -771,48 +803,23 @@ strong_alias (__from_utf8_loop_c_single, __from_utf8_loop_single)
     STANDARD_TO_LOOP_ERR_HANDLER (2);					\
   }
 
-/* Generate loop-function with software implementation.  */
-#define MIN_NEEDED_INPUT	MIN_NEEDED_TO
-#define MAX_NEEDED_INPUT	MAX_NEEDED_TO
-#define MIN_NEEDED_OUTPUT	MIN_NEEDED_FROM
-#define MAX_NEEDED_OUTPUT	MAX_NEEDED_FROM
-#if defined HAVE_S390_VX_ASM_SUPPORT
-# define LOOPFCT		__to_utf8_loop_c
-# define BODY                   BODY_TO_C
-# define LOOP_NEED_FLAGS
-# include <iconv/loop.c>
-
-/* Generate loop-function with software implementation.  */
+/* Generate loop-function with vector implementation.  */
 # define MIN_NEEDED_INPUT	MIN_NEEDED_TO
 # define MAX_NEEDED_INPUT	MAX_NEEDED_TO
 # define MIN_NEEDED_OUTPUT	MIN_NEEDED_FROM
 # define MAX_NEEDED_OUTPUT	MAX_NEEDED_FROM
-# define LOOPFCT		__to_utf8_loop_vx
+# define TO_LOOP_VX		__to_utf8_loop_vx
+# define LOOPFCT		TO_LOOP_VX
 # define BODY                   BODY_TO_VX
 # define LOOP_NEED_FLAGS
 # include <iconv/loop.c>
-
-/* Generate ifunc'ed loop function.  */
-__typeof(__to_utf8_loop_c)
-__attribute__ ((ifunc ("__to_utf8_loop_resolver")))
-__to_utf8_loop;
-
-static void *
-__to_utf8_loop_resolver (unsigned long int dl_hwcap)
-{
-  if (dl_hwcap & HWCAP_S390_VX)
-    return __to_utf8_loop_vx;
-  else
-    return __to_utf8_loop_c;
-}
-
-strong_alias (__to_utf8_loop_c_single, __to_utf8_loop_single)
-
 #else
-# define LOOPFCT		TO_LOOP
-# define BODY                   BODY_TO_C
-# define LOOP_NEED_FLAGS
-# include <iconv/loop.c>
-#endif /* !HAVE_S390_VX_ASM_SUPPORT  */
-
-#include <iconv/skeleton.c>
+# define TO_LOOP_VX		NULL
+#endif /* HAVE_TO_VX != 1  */
+
+/* This file also exists in sysdeps/s390/multiarch/ which
+   generates ifunc resolvers for FROM/TO_LOOP functions
+   and includes iconv/skeleton.c afterwards.  */
+#if ! defined USE_MULTIARCH
+# include <iconv/skeleton.c>
+#endif

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=51213e2b8d89164527131f3bf6c5946b811c5e3e

commit 51213e2b8d89164527131f3bf6c5946b811c5e3e
Author: Stefan Liebler <stli@linux.vnet.ibm.com>
Date:   Fri Apr 21 15:30:00 2017 +0200

    S390: Use new s390_libc_ifunc_expr macro in s390 8bit-generic.c.
    
    This patch adds s390_libc_ifunc_expr macro which uses the __ifunc base macro
    in include/libc-symbols.h and lets the user define a generic expression to
    choose the correct ifunc variant.  Furthermore as the base macro is used,
    the ifunc resolver functions are now also using inhibit_stack_protector.
    S390 needs its own version due to the hwcap argument of the ifunc resolver.
    
    This new macro is now used in iconv code in 8bit-generic.c instead of using
    gcc attribute ifunc directly.
    
    ChangeLog:
    
    	* sysdeps/s390/multiarch/ifunc-resolve.h
    	(s390_libc_ifunc_expr_init, s390_libc_ifunc_expr): New Define.
    	* sysdeps/s390/multiarch/8bit-generic.c
    	(__to_generic, __from_generic): Use s390_libc_ifunc_expr to
    	define ifunc resolvers.

diff --git a/ChangeLog b/ChangeLog
index dedd753..12bf100 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2017-04-21  Stefan Liebler  <stli@linux.vnet.ibm.com>
+
+	* sysdeps/s390/multiarch/ifunc-resolve.h
+	(s390_libc_ifunc_expr_init, s390_libc_ifunc_expr): New Define.
+	* sysdeps/s390/multiarch/8bit-generic.c
+	(__to_generic, __from_generic): Use s390_libc_ifunc_expr to
+	define ifunc resolvers.
+
 2017-04-21  Florian Weimer  <fweimer@redhat.com>
 
 	[BZ #20424]
diff --git a/sysdeps/s390/multiarch/8bit-generic.c b/sysdeps/s390/multiarch/8bit-generic.c
index 99f63e4..49f0ed8 100644
--- a/sysdeps/s390/multiarch/8bit-generic.c
+++ b/sysdeps/s390/multiarch/8bit-generic.c
@@ -40,8 +40,7 @@
    to translate between multiple generic characters and "1 byte UCS4"
    characters at once. The vector instructions are used to convert between
    the "1 byte UCS4" and UCS4.  */
-# include <unistd.h>
-# include <dl-procinfo.h>
+# include <ifunc-resolve.h>
 
 # undef FROM_LOOP
 # undef TO_LOOP
@@ -372,33 +371,17 @@
 
 
 /* Generate ifunc'ed loop function.  */
-__typeof(__from_generic_c)
-__attribute__ ((ifunc ("__from_generic_resolver")))
-__from_generic;
+s390_libc_ifunc_expr (__from_generic_c, __from_generic,
+		      (sizeof (from_ucs4) / sizeof (from_ucs4[0]) <= 256
+		       && hwcap & HWCAP_S390_VX)
+		      ? __from_generic_vx
+		      : __from_generic_c);
 
-static void *
-__from_generic_resolver (unsigned long int dl_hwcap)
-{
-  if (sizeof (from_ucs4) / sizeof (from_ucs4[0]) <= 256
-      && dl_hwcap & HWCAP_S390_VX)
-    return &__from_generic_vx;
-  else
-    return &__from_generic_c;
-}
-
-__typeof(__to_generic_c)
-__attribute__ ((ifunc ("__to_generic_resolver")))
-__to_generic;
-
-static void *
-__to_generic_resolver (unsigned long int dl_hwcap)
-{
-  if (sizeof (from_ucs4) / sizeof (from_ucs4[0]) <= 256
-      && dl_hwcap & HWCAP_S390_VX)
-    return &__to_generic_vx;
-  else
-    return &__to_generic_c;
-}
+s390_libc_ifunc_expr (__to_generic_c, __to_generic,
+		      (sizeof (from_ucs4) / sizeof (from_ucs4[0]) <= 256
+		       && hwcap & HWCAP_S390_VX)
+		      ? __to_generic_vx
+		      : __to_generic_c);
 
 strong_alias (__to_generic_c_single, __to_generic_single)
 
@@ -410,6 +393,6 @@ strong_alias (__to_generic_c_single, __to_generic_single)
 
 #else
 /* Generate this module without ifunc if build environment lacks vector
-   support. Instead the common 8bit-generic.c is used.  */
+   support.  Instead the common 8bit-generic.c is used.  */
 # include "iconvdata/8bit-generic.c"
 #endif /* !defined HAVE_S390_VX_ASM_SUPPORT */
diff --git a/sysdeps/s390/multiarch/ifunc-resolve.h b/sysdeps/s390/multiarch/ifunc-resolve.h
index c04822d..adbd08a 100644
--- a/sysdeps/s390/multiarch/ifunc-resolve.h
+++ b/sysdeps/s390/multiarch/ifunc-resolve.h
@@ -83,3 +83,8 @@
 	   ? RESOLVERFUNC##_vx						\
 	   : RESOLVERFUNC##_c,						\
 	   unsigned long int dl_hwcap, s390_vx_libc_ifunc_init);
+
+#define s390_libc_ifunc_expr_init()
+#define s390_libc_ifunc_expr(TYPE_FUNC, FUNC, EXPR)		\
+  __ifunc (TYPE_FUNC, FUNC, EXPR, unsigned long int hwcap,	\
+	   s390_libc_ifunc_expr_init);

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                               |   35 +++++
 sysdeps/s390/multiarch/8bit-generic.c   |   41 ++----
 sysdeps/s390/multiarch/ifunc-resolve.h  |    5 +
 sysdeps/s390/multiarch/utf16-utf32-z9.c |   44 +++++++
 sysdeps/s390/multiarch/utf8-utf16-z9.c  |   48 +++++++
 sysdeps/s390/multiarch/utf8-utf32-z9.c  |   48 +++++++
 sysdeps/s390/utf16-utf32-z9.c           |  142 ++++++++++----------
 sysdeps/s390/utf8-utf16-z9.c            |  197 +++++++++++++++--------------
 sysdeps/s390/utf8-utf32-z9.c            |  215 ++++++++++++++++---------------
 9 files changed, 476 insertions(+), 299 deletions(-)
 create mode 100644 sysdeps/s390/multiarch/utf16-utf32-z9.c
 create mode 100644 sysdeps/s390/multiarch/utf8-utf16-z9.c
 create mode 100644 sysdeps/s390/multiarch/utf8-utf32-z9.c


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]