[PATCH 19/30] x86_64: Add glibc-hwcaps support

H.J. Lu hjl.tools@gmail.com
Thu Jun 25 13:50:50 GMT 2020


On Thu, Jun 25, 2020 at 3:14 AM Florian Weimer via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> * Florian Weimer via Libc-alpha:
>
> > Details of the supported CPU flags and the names are still subject to
> > changes.
> > +int32_t
> > +_dl_hwcaps_subdirs_active (void)
> > +{
> > +  const struct cpu_features *cpu_features = __get_cpu_features ();
> > +  int32_t result = 0;
> > +  int32_t bit = 1 << 3;
> > +
> > +  /* Test in reverse preference order.  */
> > +
> > +  /* x86-100.  */
> > +  if (!(CPU_FEATURES_ARCH_P (cpu_features, CMPXCHG16B_Usable)
> > +        && CPU_FEATURES_ARCH_P (cpu_features, POPCNT_Usable)
> > +        && CPU_FEATURES_ARCH_P (cpu_features, SSE3_Usable)
> > +        && CPU_FEATURES_ARCH_P (cpu_features, SSE4_1_Usable)
> > +        && CPU_FEATURES_ARCH_P (cpu_features, SSE4_2_Usable)
> > +        && CPU_FEATURES_ARCH_P (cpu_features, SSSE3_Usable)))
> > +    return result;
>
> This misuses CPU_FEATURES_ARCH_P, and the recent <cpu-features.h> update
> on the master branch makes it finally fail to compile.  The version
> below should fix the build and also correct the feature detection logic.
>
> Thanks,
> Florian
>
> diff --git a/sysdeps/x86_64/dl-hwcaps-subdirs.c b/sysdeps/x86_64/dl-hwcaps-subdirs.c
> new file mode 100644
> index 0000000000..1a90854b69
> --- /dev/null
> +++ b/sysdeps/x86_64/dl-hwcaps-subdirs.c
> @@ -0,0 +1,73 @@
> +/* Architecture-specific glibc-hwcaps subdirectories.  x86 version.
> +   Copyright (C) 2020 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <dl-hwcaps.h>
> +#include <cpu-features.h>
> +
> +const char _dl_hwcaps_subdirs[] = "x86-103:x86-102:x86-101:x86-100";
>

I understand why you use digits.  But it is very cryptic.  Since it is
user visible,
how can one tell what 103 means without looking at glibc source?

-- 
H.J.


More information about the Libc-alpha mailing list