]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Simplify CPUID value handling.
authorUlrich Drepper <drepper@redhat.com>
Mon, 1 Jun 2009 00:52:05 +0000 (17:52 -0700)
committerUlrich Drepper <drepper@redhat.com>
Mon, 1 Jun 2009 00:52:05 +0000 (17:52 -0700)
SO far Intel and AMD use exactly the same bits meaning the same
things in CPUID index 1.  Simplify the code.  Should an architecture
come along which doesn't use the same semantics then it must use a
different index value than COMMON_CPUID_INDEX_1.

ChangeLog
sysdeps/x86_64/cacheinfo.c
sysdeps/x86_64/multiarch/init-arch.c
sysdeps/x86_64/multiarch/init-arch.h
sysdeps/x86_64/multiarch/sched_cpucount.c

index dd08740b51cbd7036e630ea8bd5a42528f674947..1de4c0dd4f03740d626440c315b98b89b32d82a9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,24 @@
+2009-05-31  Ulrich Drepper  <drepper@redhat.com>
+
+       * sysdeps/x86_64/multiarch/init-arch.h: Define COMMON_CPUID_INDEX_1
+       instead of INTEL_CPUID_INDEX_1 and AMD_CPUID_INDEX_1.  So far there
+       are no differences.  If an architecture has bits in CPUID index 1
+       meaning different things the values for the COMMON_CPUID_INDEX_1
+       index must not be set.
+       (INTEL_HAS_POPCOUNT, AMD_HAS_POPCOUNT): Removed in favor of...
+       (HAS_POPCOUNT): ...this.  New macro.
+       * sysdeps/x86_64/multiarch/init-arch.c: Use COMMON_CPUID_INDEX_1
+       instead of INTEL_CPUID_INDEX_1 and AMD_CPUID_INDEX_1.  Unify code
+       to set the value for Intel and AMD architectures.
+       * sysdeps/x86_64/cacheinfo.c: Use COMMON_CPUID_INDEX_1 instead of
+       INTEL_CPUID_INDEX_1.
+       * sysdeps/x86_64/multiarch/sched_cpucount.c: Adjust for HAS_POPCOUNT
+       change.
+
 2009-05-30  Andreas Schwab  <schwab@linux-m68k.org>
 
        * configure.in: Move AC_CANONICAL_HOST before first use of $host
        and $build.
-       * configure: Regenerated.
 
 2009-05-29  Jakub Jelinek  <jakub@redhat.com>
 
@@ -15,8 +31,6 @@
        * sysdeps/ieee754/ldbl-128/s_sinl.c: Include <errno.h>.
        (__sinl): Set errno to EDOM for ±Inf.
 
-2009-05-29  Jakub Jelinek  <jakub@redhat.com>
-
        * sysdeps/s390/s390-32/__longjmp.c (__longjmp): If CHECK_SP is
        defined, use it.
        * sysdeps/s390/s390-64/__longjmp.c (__longjmp): Likewise.
index cd192caad86e5ce309de0e38cfdbb791aa840168..362687c1815157376b5f1a061cd6d4db24c73123 100644 (file)
@@ -489,10 +489,10 @@ init_cacheinfo (void)
        }
 
 #ifdef USE_MULTIARCH
-      eax = __cpu_features.cpuid[INTEL_CPUID_INDEX_1].eax;
-      ebx = __cpu_features.cpuid[INTEL_CPUID_INDEX_1].ebx;
-      ecx = __cpu_features.cpuid[INTEL_CPUID_INDEX_1].ecx;
-      edx = __cpu_features.cpuid[INTEL_CPUID_INDEX_1].edx;
+      eax = __cpu_features.cpuid[COMMON_CPUID_INDEX_1].eax;
+      ebx = __cpu_features.cpuid[COMMON_CPUID_INDEX_1].ebx;
+      ecx = __cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx;
+      edx = __cpu_features.cpuid[COMMON_CPUID_INDEX_1].edx;
 #else
       asm volatile ("cpuid"
                    : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
index eb4365fe3277b5321b84f13bcf1e2be0950cd4e0..ec0eb29fafdbd936454fa43d0e66af19de90a9d1 100644 (file)
@@ -1,6 +1,6 @@
 /* Initialize CPU feature data.
    This file is part of the GNU C Library.
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
    Contributed by Ulrich Drepper <drepper@redhat.com>.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -41,11 +41,12 @@ __init_cpu_features (void)
     {
       __cpu_features.kind = arch_kind_intel;
 
+    get_common_cpuid:
       asm volatile ("cpuid"
-                   : "=a" (__cpu_features.cpuid[INTEL_CPUID_INDEX_1].eax),
-                     "=b" (__cpu_features.cpuid[INTEL_CPUID_INDEX_1].ebx),
-                     "=c" (__cpu_features.cpuid[INTEL_CPUID_INDEX_1].ecx),
-                     "=d" (__cpu_features.cpuid[INTEL_CPUID_INDEX_1].edx)
+                   : "=a" (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].eax),
+                     "=b" (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ebx),
+                     "=c" (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx),
+                     "=d" (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].edx)
                    : "0" (1));
     }
   /* This spells out "AuthenticAMD".  */
@@ -53,12 +54,7 @@ __init_cpu_features (void)
     {
       __cpu_features.kind = arch_kind_amd;
 
-      asm volatile ("cpuid"
-                   : "=a" (__cpu_features.cpuid[AMD_CPUID_INDEX_1].eax),
-                     "=b" (__cpu_features.cpuid[AMD_CPUID_INDEX_1].ebx),
-                     "=c" (__cpu_features.cpuid[AMD_CPUID_INDEX_1].ecx),
-                     "=d" (__cpu_features.cpuid[AMD_CPUID_INDEX_1].edx)
-                   : "0" (1));
+      goto get_common_cpuid;
     }
   else
     __cpu_features.kind = arch_kind_other;
index 86cd83dc4cc64437c0a94e5b49dcbb387eafe479..40b804571d69944898c9261e438ad7d44e03ec40 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of the GNU C Library.
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 
    The GNU C Library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
 
 enum
   {
-    INTEL_CPUID_INDEX_1 = 0,
+    COMMON_CPUID_INDEX_1 = 0,
     /* Keep the following line at the end.  */
-    INTEL_CPUID_INDEX_MAX
-  };
-
-enum
-  {
-    AMD_CPUID_INDEX_1 = 0,
-    /* Keep the following line at the end.  */
-    AMD_CPUID_INDEX_MAX
+    COMMON_CPUID_INDEX_MAX
   };
 
 extern struct cpu_features
@@ -48,7 +41,7 @@ extern struct cpu_features
     unsigned int ebx;
     unsigned int ecx;
     unsigned int edx;
-  } cpuid[MAX (INTEL_CPUID_INDEX_MAX, AMD_CPUID_INDEX_MAX)];
+  } cpuid[COMMON_CPUID_INDEX_MAX];
 } __cpu_features attribute_hidden;
 
 
@@ -61,10 +54,5 @@ extern void __init_cpu_features (void) attribute_hidden;
 
 /* Following are the feature tests used throughout libc.  */
 
-#define INTEL_HAS_POPCOUNT \
-  (__cpu_features.kind == arch_kind_intel                              \
-   && (__cpu_features.cpuid[INTEL_CPUID_INDEX_1].ecx & (1 << 23)) != 0)
-
-#define AMD_HAS_POPCOUNT \
-  (__cpu_features.kind == arch_kind_amd                                \
-   && (__cpu_features.cpuid[AMD_CPUID_INDEX_1].ecx & (1 << 23)) != 0)
+#define HAS_POPCOUNT \
+  ((__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx & (1 << 23)) != 0)
index dc20182df471531a4a6a228e250fbf221dd55f9d..e7f9daed0518a7669d44c618be7e604759068980 100644 (file)
@@ -1,6 +1,6 @@
 /* Count bits in CPU set.  x86-64 multi-arch version.
    This file is part of the GNU C Library.
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
    Contributed by Ulrich Drepper <drepper@redhat.com>.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -35,8 +35,7 @@
 # undef __sched_cpucount
 
 libc_ifunc (__sched_cpucount,
-           INTEL_HAS_POPCOUNT || AMD_HAS_POPCOUNT
-           ? popcount_cpucount : generic_cpucount);
+           HAS_POPCOUNT ? popcount_cpucount : generic_cpucount);
 #else
 # include_next <sched_cpucount.c>
 #endif