ce426f
From b13a91507798183556d7e1891fe3d4cd3a947aa6 Mon Sep 17 00:00:00 2001
ce426f
From: Stefan Liebler <stli@linux.vnet.ibm.com>
ce426f
Date: Thu, 8 Oct 2015 10:48:13 +0200
ce426f
Subject: [PATCH 09/30] S390: Ifunc resolver macro for vector instructions.
ce426f
ce426f
upstream-commit-id: fd484e057dd4d2813182df08584a4c48d6f1dd7a
ce426f
https://www.sourceware.org/ml/libc-alpha/2015-07/msg00076.html
ce426f
ce426f
This patch introduces a s390 specific ifunc resolver macro for 32/64bit,
ce426f
which chooses <func>_vx with vector instructions if HWCAP_S390_VX flag
ce426f
in hwcaps is set or <func>_c if not.
ce426f
ce426f
ChangeLog:
ce426f
ce426f
	* sysdeps/s390/multiarch/ifunc-resolve.h (s390_vx_libc_ifunc,
ce426f
	s390_vx_libc_ifunc2): New macro function.
ce426f
---
ce426f
 sysdeps/s390/multiarch/ifunc-resolve.h | 19 +++++++++++++++++++
ce426f
 1 file changed, 19 insertions(+)
ce426f
ce426f
diff --git a/sysdeps/s390/multiarch/ifunc-resolve.h b/sysdeps/s390/multiarch/ifunc-resolve.h
ce426f
index 491df68..e9fd90e 100644
ce426f
--- a/sysdeps/s390/multiarch/ifunc-resolve.h
ce426f
+++ b/sysdeps/s390/multiarch/ifunc-resolve.h
ce426f
@@ -73,3 +73,22 @@
ce426f
     else								\
ce426f
       return &__##FUNC##_default;					\
ce426f
   }
ce426f
+
ce426f
+#define s390_vx_libc_ifunc(FUNC)		\
ce426f
+  s390_vx_libc_ifunc2(FUNC, FUNC)
ce426f
+
ce426f
+#define s390_vx_libc_ifunc2(RESOLVERFUNC, FUNC)				\
ce426f
+  /* Make the declarations of the optimized functions hidden in order
ce426f
+     to prevent GOT slots being generated for them.  */			\
ce426f
+  extern __typeof (FUNC) RESOLVERFUNC##_vx attribute_hidden;		\
ce426f
+  extern __typeof (FUNC) RESOLVERFUNC##_c attribute_hidden;		\
ce426f
+  extern void *__resolve_##RESOLVERFUNC (unsigned long int) __asm__ (#FUNC); \
ce426f
+									\
ce426f
+  void *__resolve_##RESOLVERFUNC (unsigned long int dl_hwcap)		\
ce426f
+  {									\
ce426f
+    if (dl_hwcap & HWCAP_S390_VX)					\
ce426f
+      return &RESOLVERFUNC##_vx;					\
ce426f
+    else								\
ce426f
+      return &RESOLVERFUNC##_c;						\
ce426f
+  }									\
ce426f
+ __asm__ (".type " #FUNC ", %gnu_indirect_function");
ce426f
-- 
ce426f
2.3.0
ce426f