|
|
51f0aa |
From 42e0828f582dcc4ff92d65039910ffe5fa9d881b Mon Sep 17 00:00:00 2001
|
|
|
51f0aa |
From: Stefan Liebler <stli@linux.vnet.ibm.com>
|
|
|
51f0aa |
Date: Thu, 27 Jul 2017 10:53:58 +0200
|
|
|
51f0aa |
Subject: [PATCH 02/10] S390: Use new s390_libc_ifunc_expr macro in s390
|
|
|
51f0aa |
8bit-generic.c.
|
|
|
51f0aa |
|
|
|
51f0aa |
upstream-commit 51213e2b8d89164527131f3bf6c5946b811c5e3e
|
|
|
51f0aa |
|
|
|
51f0aa |
This patch adds s390_libc_ifunc_expr macro which uses the __ifunc base macro
|
|
|
51f0aa |
(upstream it is in include/libc-symbols.h; this backport implements it
|
|
|
51f0aa |
in s390-header) and lets the user define a generic expression to
|
|
|
51f0aa |
choose the correct ifunc variant. Furthermore as the base macro is used,
|
|
|
51f0aa |
the ifunc resolver functions are now also using inhibit_stack_protector.
|
|
|
51f0aa |
S390 needs its own version due to the hwcap argument of the ifunc resolver.
|
|
|
51f0aa |
|
|
|
51f0aa |
This new macro is now used in iconv code in 8bit-generic.c instead of using
|
|
|
51f0aa |
gcc attribute ifunc directly.
|
|
|
51f0aa |
|
|
|
51f0aa |
ChangeLog:
|
|
|
51f0aa |
|
|
|
51f0aa |
* sysdeps/s390/multiarch/ifunc-resolve.h
|
|
|
51f0aa |
(s390_libc_ifunc_expr_init, s390_libc_ifunc_expr, __ifunc,
|
|
|
51f0aa |
__ifunc_resolver): New Define.
|
|
|
51f0aa |
* sysdeps/s390/multiarch/8bit-generic.c
|
|
|
51f0aa |
(__to_generic, __from_generic): Use s390_libc_ifunc_expr to
|
|
|
51f0aa |
define ifunc resolvers.
|
|
|
51f0aa |
---
|
|
|
51f0aa |
sysdeps/s390/multiarch/8bit-generic.c | 41 ++++++++++------------------------
|
|
|
51f0aa |
sysdeps/s390/multiarch/ifunc-resolve.h | 20 +++++++++++++++++
|
|
|
51f0aa |
2 files changed, 32 insertions(+), 29 deletions(-)
|
|
|
51f0aa |
|
|
|
51f0aa |
diff --git a/sysdeps/s390/multiarch/8bit-generic.c b/sysdeps/s390/multiarch/8bit-generic.c
|
|
|
51f0aa |
index 93565e1..9232240 100644
|
|
|
51f0aa |
--- a/sysdeps/s390/multiarch/8bit-generic.c
|
|
|
51f0aa |
+++ b/sysdeps/s390/multiarch/8bit-generic.c
|
|
|
51f0aa |
@@ -40,8 +40,7 @@
|
|
|
51f0aa |
to translate between multiple generic characters and "1 byte UCS4"
|
|
|
51f0aa |
characters at once. The vector instructions are used to convert between
|
|
|
51f0aa |
the "1 byte UCS4" and UCS4. */
|
|
|
51f0aa |
-# include <unistd.h>
|
|
|
51f0aa |
-# include <dl-procinfo.h>
|
|
|
51f0aa |
+# include <ifunc-resolve.h>
|
|
|
51f0aa |
|
|
|
51f0aa |
# undef FROM_LOOP
|
|
|
51f0aa |
# undef TO_LOOP
|
|
|
51f0aa |
@@ -372,33 +371,17 @@
|
|
|
51f0aa |
|
|
|
51f0aa |
|
|
|
51f0aa |
/* Generate ifunc'ed loop function. */
|
|
|
51f0aa |
-__typeof(__from_generic_c)
|
|
|
51f0aa |
-__attribute__ ((ifunc ("__from_generic_resolver")))
|
|
|
51f0aa |
-__from_generic;
|
|
|
51f0aa |
+s390_libc_ifunc_expr (__from_generic_c, __from_generic,
|
|
|
51f0aa |
+ (sizeof (from_ucs4) / sizeof (from_ucs4[0]) <= 256
|
|
|
51f0aa |
+ && hwcap & HWCAP_S390_VX)
|
|
|
51f0aa |
+ ? __from_generic_vx
|
|
|
51f0aa |
+ : __from_generic_c);
|
|
|
51f0aa |
|
|
|
51f0aa |
-static void *
|
|
|
51f0aa |
-__from_generic_resolver (unsigned long int dl_hwcap)
|
|
|
51f0aa |
-{
|
|
|
51f0aa |
- if (sizeof (from_ucs4) / sizeof (from_ucs4[0]) <= 256
|
|
|
51f0aa |
- && dl_hwcap & HWCAP_S390_VX)
|
|
|
51f0aa |
- return &__from_generic_vx;
|
|
|
51f0aa |
- else
|
|
|
51f0aa |
- return &__from_generic_c;
|
|
|
51f0aa |
-}
|
|
|
51f0aa |
-
|
|
|
51f0aa |
-__typeof(__to_generic_c)
|
|
|
51f0aa |
-__attribute__ ((ifunc ("__to_generic_resolver")))
|
|
|
51f0aa |
-__to_generic;
|
|
|
51f0aa |
-
|
|
|
51f0aa |
-static void *
|
|
|
51f0aa |
-__to_generic_resolver (unsigned long int dl_hwcap)
|
|
|
51f0aa |
-{
|
|
|
51f0aa |
- if (sizeof (from_ucs4) / sizeof (from_ucs4[0]) <= 256
|
|
|
51f0aa |
- && dl_hwcap & HWCAP_S390_VX)
|
|
|
51f0aa |
- return &__to_generic_vx;
|
|
|
51f0aa |
- else
|
|
|
51f0aa |
- return &__to_generic_c;
|
|
|
51f0aa |
-}
|
|
|
51f0aa |
+s390_libc_ifunc_expr (__to_generic_c, __to_generic,
|
|
|
51f0aa |
+ (sizeof (from_ucs4) / sizeof (from_ucs4[0]) <= 256
|
|
|
51f0aa |
+ && hwcap & HWCAP_S390_VX)
|
|
|
51f0aa |
+ ? __to_generic_vx
|
|
|
51f0aa |
+ : __to_generic_c);
|
|
|
51f0aa |
|
|
|
51f0aa |
strong_alias (__to_generic_c_single, __to_generic_single)
|
|
|
51f0aa |
|
|
|
51f0aa |
@@ -410,6 +393,6 @@ strong_alias (__to_generic_c_single, __to_generic_single)
|
|
|
51f0aa |
|
|
|
51f0aa |
#else
|
|
|
51f0aa |
/* Generate this module without ifunc if build environment lacks vector
|
|
|
51f0aa |
- support. Instead the common 8bit-generic.c is used. */
|
|
|
51f0aa |
+ support. Instead the common 8bit-generic.c is used. */
|
|
|
51f0aa |
# include "iconvdata/8bit-generic.c"
|
|
|
51f0aa |
#endif /* !defined HAVE_S390_VX_ASM_SUPPORT */
|
|
|
51f0aa |
diff --git a/sysdeps/s390/multiarch/ifunc-resolve.h b/sysdeps/s390/multiarch/ifunc-resolve.h
|
|
|
51f0aa |
index e9fd90e..883365b 100644
|
|
|
51f0aa |
--- a/sysdeps/s390/multiarch/ifunc-resolve.h
|
|
|
51f0aa |
+++ b/sysdeps/s390/multiarch/ifunc-resolve.h
|
|
|
51f0aa |
@@ -92,3 +92,23 @@
|
|
|
51f0aa |
return &RESOLVERFUNC##_c; \
|
|
|
51f0aa |
} \
|
|
|
51f0aa |
__asm__ (".type " #FUNC ", %gnu_indirect_function");
|
|
|
51f0aa |
+
|
|
|
51f0aa |
+/* Helper / base macros for indirect function symbols
|
|
|
51f0aa |
+ (See include/libc-symbols in upstream glibc). */
|
|
|
51f0aa |
+#define __ifunc_resolver(type_name, name, expr, arg, init, classifier) \
|
|
|
51f0aa |
+ classifier void *name##_ifunc (arg) \
|
|
|
51f0aa |
+ { \
|
|
|
51f0aa |
+ init (); \
|
|
|
51f0aa |
+ __typeof (type_name) *res = expr; \
|
|
|
51f0aa |
+ return res; \
|
|
|
51f0aa |
+ }
|
|
|
51f0aa |
+
|
|
|
51f0aa |
+#define __ifunc(type_name, name, expr, arg, init) \
|
|
|
51f0aa |
+ extern __typeof (type_name) name __attribute__ \
|
|
|
51f0aa |
+ ((ifunc (#name "_ifunc"))); \
|
|
|
51f0aa |
+ __ifunc_resolver (type_name, name, expr, arg, init, static)
|
|
|
51f0aa |
+
|
|
|
51f0aa |
+#define s390_libc_ifunc_expr_init()
|
|
|
51f0aa |
+#define s390_libc_ifunc_expr(TYPE_FUNC, FUNC, EXPR) \
|
|
|
51f0aa |
+ __ifunc (TYPE_FUNC, FUNC, EXPR, unsigned long int hwcap, \
|
|
|
51f0aa |
+ s390_libc_ifunc_expr_init);
|
|
|
51f0aa |
--
|
|
|
51f0aa |
1.8.3.1
|
|
|
51f0aa |
|