From 5e1122827a9f9751922b25c332f8f0272de60719 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Wed, 7 Jun 2017 14:09:59 -0700 Subject: x86-64: Rename wmemset.h to ifunc-wmemset.h No code changes. * sysdeps/x86_64/multiarch/wmemset.c: Include ifunc-wmemset.h instead of wmemset.h. * sysdeps/x86_64/multiarch/wmemset_chk.c: Likewise. * sysdeps/x86_64/multiarch/wmemset.h: Renamed to ... * sysdeps/x86_64/multiarch/ifunc-wmemset.h: This. --- ChangeLog | 10 +++++++ sysdeps/x86_64/multiarch/ifunc-impl-list.c | 4 +-- sysdeps/x86_64/multiarch/ifunc-wmemset.h | 42 ++++++++++++++++++++++++++++++ sysdeps/x86_64/multiarch/wmemset.c | 2 +- sysdeps/x86_64/multiarch/wmemset.h | 42 ------------------------------ sysdeps/x86_64/multiarch/wmemset_chk.c | 2 +- 6 files changed, 56 insertions(+), 46 deletions(-) create mode 100644 sysdeps/x86_64/multiarch/ifunc-wmemset.h delete mode 100644 sysdeps/x86_64/multiarch/wmemset.h diff --git a/ChangeLog b/ChangeLog index 88483ae3aa..bbc21abb6c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2017-06-07 H.J. Lu + + * sysdeps/x86_64/multiarch/ifunc-impl-list.c: Update + comments. + * sysdeps/x86_64/multiarch/wmemset.c: Include ifunc-wmemset.h + instead of wmemset.h. + * sysdeps/x86_64/multiarch/wmemset_chk.c: Likewise. + * sysdeps/x86_64/multiarch/wmemset.h: Renamed to ... + * sysdeps/x86_64/multiarch/ifunc-wmemset.h: This. + 2017-06-07 Gabriel F. T. Gomes * stdio-common/printf-parsemb.c (__parse_one_specmb): Initialize diff --git a/sysdeps/x86_64/multiarch/ifunc-impl-list.c b/sysdeps/x86_64/multiarch/ifunc-impl-list.c index ee4243a233..5627183aca 100644 --- a/sysdeps/x86_64/multiarch/ifunc-impl-list.c +++ b/sysdeps/x86_64/multiarch/ifunc-impl-list.c @@ -315,7 +315,7 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __wmemcmp_ssse3) IFUNC_IMPL_ADD (array, i, wmemcmp, 1, __wmemcmp_sse2)) - /* Support sysdeps/x86_64/multiarch/wmemset.S. */ + /* Support sysdeps/x86_64/multiarch/wmemset.c. */ IFUNC_IMPL (i, name, wmemset, IFUNC_IMPL_ADD (array, i, wmemset, 1, __wmemset_sse2_unaligned) @@ -444,7 +444,7 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __strncmp_ssse3) IFUNC_IMPL_ADD (array, i, strncmp, 1, __strncmp_sse2)) - /* Support sysdeps/x86_64/multiarch/wmemset_chk.S. */ + /* Support sysdeps/x86_64/multiarch/wmemset_chk.c. */ IFUNC_IMPL (i, name, __wmemset_chk, IFUNC_IMPL_ADD (array, i, __wmemset_chk, 1, __wmemset_chk_sse2_unaligned) diff --git a/sysdeps/x86_64/multiarch/ifunc-wmemset.h b/sysdeps/x86_64/multiarch/ifunc-wmemset.h new file mode 100644 index 0000000000..d761985a47 --- /dev/null +++ b/sysdeps/x86_64/multiarch/ifunc-wmemset.h @@ -0,0 +1,42 @@ +/* Common definition for wmemset/wmemset_chk ifunc selections. + 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 + . */ + +#include + +extern __typeof (REDIRECT_NAME) OPTIMIZE (sse2_unaligned) attribute_hidden; +extern __typeof (REDIRECT_NAME) OPTIMIZE (avx2_unaligned) attribute_hidden; +extern __typeof (REDIRECT_NAME) OPTIMIZE (avx512_unaligned) attribute_hidden; + +static inline void * +IFUNC_SELECTOR (void) +{ + const struct cpu_features* cpu_features = __get_cpu_features (); + + if (!CPU_FEATURES_ARCH_P (cpu_features, Prefer_No_VZEROUPPER) + && CPU_FEATURES_ARCH_P (cpu_features, AVX2_Usable) + && CPU_FEATURES_ARCH_P (cpu_features, AVX_Fast_Unaligned_Load)) + { + if (CPU_FEATURES_ARCH_P (cpu_features, AVX512F_Usable) + && !CPU_FEATURES_ARCH_P (cpu_features, Prefer_No_AVX512)) + return OPTIMIZE (avx512_unaligned); + else + return OPTIMIZE (avx2_unaligned); + } + + return OPTIMIZE (sse2_unaligned); +} diff --git a/sysdeps/x86_64/multiarch/wmemset.c b/sysdeps/x86_64/multiarch/wmemset.c index 61626a9e74..dd35be6e49 100644 --- a/sysdeps/x86_64/multiarch/wmemset.c +++ b/sysdeps/x86_64/multiarch/wmemset.c @@ -26,7 +26,7 @@ # undef __wmemset # define SYMBOL_NAME wmemset -# include "wmemset.h" +# include "ifunc-wmemset.h" libc_ifunc_redirected (__redirect_wmemset, __wmemset, IFUNC_SELECTOR ()); weak_alias (__wmemset, wmemset) diff --git a/sysdeps/x86_64/multiarch/wmemset.h b/sysdeps/x86_64/multiarch/wmemset.h deleted file mode 100644 index d761985a47..0000000000 --- a/sysdeps/x86_64/multiarch/wmemset.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Common definition for wmemset/wmemset_chk ifunc selections. - 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 - . */ - -#include - -extern __typeof (REDIRECT_NAME) OPTIMIZE (sse2_unaligned) attribute_hidden; -extern __typeof (REDIRECT_NAME) OPTIMIZE (avx2_unaligned) attribute_hidden; -extern __typeof (REDIRECT_NAME) OPTIMIZE (avx512_unaligned) attribute_hidden; - -static inline void * -IFUNC_SELECTOR (void) -{ - const struct cpu_features* cpu_features = __get_cpu_features (); - - if (!CPU_FEATURES_ARCH_P (cpu_features, Prefer_No_VZEROUPPER) - && CPU_FEATURES_ARCH_P (cpu_features, AVX2_Usable) - && CPU_FEATURES_ARCH_P (cpu_features, AVX_Fast_Unaligned_Load)) - { - if (CPU_FEATURES_ARCH_P (cpu_features, AVX512F_Usable) - && !CPU_FEATURES_ARCH_P (cpu_features, Prefer_No_AVX512)) - return OPTIMIZE (avx512_unaligned); - else - return OPTIMIZE (avx2_unaligned); - } - - return OPTIMIZE (sse2_unaligned); -} diff --git a/sysdeps/x86_64/multiarch/wmemset_chk.c b/sysdeps/x86_64/multiarch/wmemset_chk.c index 2c039a5141..d3ded5595b 100644 --- a/sysdeps/x86_64/multiarch/wmemset_chk.c +++ b/sysdeps/x86_64/multiarch/wmemset_chk.c @@ -24,7 +24,7 @@ # undef __wmemset_chk # define SYMBOL_NAME wmemset_chk -# include "wmemset.h" +# include "ifunc-wmemset.h" libc_ifunc_redirected (__redirect_wmemset_chk, __wmemset_chk, IFUNC_SELECTOR ()); -- cgit 1.4.1