]> xenbits.xensource.com Git - people/andrewcoop/hwloc.git/commitdiff
Fix cpuid on windows 64bits so that the x86 backend is enabled as expected
authorBrice Goglin <Brice.Goglin@inria.fr>
Tue, 28 Jan 2014 14:41:57 +0000 (15:41 +0100)
committerBrice Goglin <Brice.Goglin@inria.fr>
Wed, 29 Jan 2014 09:16:45 +0000 (10:16 +0100)
unsigned long isn't 64bits on win64, so the cpuid assembly code fails to
build during configure (%ebx and %rbx gets mixed in the assembly),
and the entire x86 backend gets disabled.

Use hwloc_uint64_t instead. It needs hwloc/autogen/config.h which isn't
ready during configure yet, so manually add #include/#define during
the cpuid check.

Thanks to Robin Scher for reporting the problem.

config/hwloc.m4
include/private/cpuid.h

index 38069335a58f70f6663b9c5892e6f327c8fd7fe3..bfee6e11d0399221406ccd3071784fd91b42306f 100644 (file)
@@ -1,6 +1,6 @@
 dnl -*- Autoconf -*-
 dnl
-dnl Copyright © 2009-2013 Inria.  All rights reserved.
+dnl Copyright © 2009-2014 Inria.  All rights reserved.
 dnl Copyright (c) 2009-2012 Université Bordeaux 1
 dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
 dnl                         University Research and Technology
@@ -995,8 +995,23 @@ EOF])
     AC_MSG_CHECKING([for cpuid])
     old_CPPFLAGS="$CPPFLAGS"
     CPPFLAGS="$CPPFLAGS -I$HWLOC_top_srcdir/include"
+    # We need hwloc_uint64_t but we can't use hwloc/autogen/config.h before configure ends.
+    # So pass #include/#define manually here for now.
+    CPUID_CHECK_HEADERS=
+    CPUID_CHECK_DEFINE=
+    if test "x$hwloc_windows" = xyes; then
+      CPUID_CHECK_HEADERS="#include <windows.h>"
+      CPUID_CHECK_DEFINE="#define hwloc_uint64_t DWORDLONG"
+    else
+      CPUID_CHECK_DEFINE="#define hwloc_uint64_t uint64_t"
+      if test "x$ac_cv_header_stdint_h" = xyes; then
+        CPUID_CHECK_HEADERS="#include <stdint.h>"
+      fi
+    fi
     AC_LINK_IFELSE([AC_LANG_PROGRAM([[
         #include <stdio.h>
+        $CPUID_CHECK_HEADERS
+        $CPUID_CHECK_DEFINE
         #define __hwloc_inline
         #include <private/cpuid.h>
       ]], [[
index 92348485117996d0ce0a32914da40f34e5f3cb6f..214ab382719cc7dac2e5b2431538a967c868dc75 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright © 2010-2012 Université Bordeaux 1
  * Copyright © 2010 Cisco Systems, Inc.  All rights reserved.
+ * Copyright © 2014 Inria.  All rights reserved.
  *
  * See COPYING in top-level directory.
  */
@@ -54,7 +55,7 @@ static __hwloc_inline void hwloc_cpuid(unsigned *eax, unsigned *ebx, unsigned *e
   /* Note: gcc might want to use bx or the stack for %1 addressing, so we can't
    * use them :/ */
 #ifdef HWLOC_X86_64_ARCH
-  unsigned long sav_rbx;
+  hwloc_uint64_t sav_rbx;
   asm(
   "mov %%rbx,%2\n\t"
   "cpuid\n\t"