This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: PATCH: Use __get_cpu_features () in HAS_CPUID_FLAG
On Wed, Dec 12, 2012 at 3:09 PM, Roland McGrath <roland@hack.frob.com> wrote:
> Looks OK.
It doesn't work since HAS_CPUID_FLAG is also used in ld.so
and ld.so has its own copy of cpu_features. I am testing this patch.
OK for 2.18 if test is OK?
--
H.J.
---
2012-12-12 H.J. Lu <hongjiu.lu@intel.com>
* sysdeps/x86_64/multiarch/init-arch.c (__get_cpu_features): Define
only if NOT_IN_libc isn't defined.
* sysdeps/x86_64/multiarch/init-arch.h (__get_cpu_features): Also
define if IS_IN_rtld is defined.
(HAS_CPUID_FLAG): Use __get_cpu_features ().
diff --git a/sysdeps/x86_64/multiarch/init-arch.c
b/sysdeps/x86_64/multiarch/init-arch.c
index 598f60f..0da7c29 100644
--- a/sysdeps/x86_64/multiarch/init-arch.c
+++ b/sysdeps/x86_64/multiarch/init-arch.c
@@ -181,6 +181,7 @@ __init_cpu_features (void)
#undef __get_cpu_features
+#ifndef NOT_IN_libc
const struct cpu_features *
__get_cpu_features (void)
{
@@ -189,3 +190,4 @@ __get_cpu_features (void)
return &__cpu_features;
}
+#endif
diff --git a/sysdeps/x86_64/multiarch/init-arch.h
b/sysdeps/x86_64/multiarch/init-arch.h
index 5ae6e9a..0141cc6 100644
--- a/sysdeps/x86_64/multiarch/init-arch.h
+++ b/sysdeps/x86_64/multiarch/init-arch.h
@@ -121,7 +121,7 @@ extern void __init_cpu_features (void) attribute_hidden;
extern const struct cpu_features *__get_cpu_features (void)
__attribute__ ((const));
-# ifndef NOT_IN_libc
+# if !defined NOT_IN_libc || defined IS_IN_rtld
# define __get_cpu_features() (&__cpu_features)
# endif
@@ -135,7 +135,7 @@ extern const struct cpu_features *__get_cpu_features (void)
are called only within __init_cpu_features, where we can't
call __get_cpu_features without infinite recursion. */
# define HAS_CPUID_FLAG(idx, reg, bit) \
- (((&__cpu_features)->cpuid[idx].reg & (bit)) != 0)
+ ((__get_cpu_features ()->cpuid[idx].reg & (bit)) != 0)
# define CPUID_OSXSAVE \
HAS_CPUID_FLAG (COMMON_CPUID_INDEX_1, ecx, bit_OSXSAVE)