Le 28/01/2014 14:31, Brice Goglin a écrit :
> Le 28/01/2014 13:00, Samuel Thibault a écrit :
>> Brice Goglin, le Tue 28 Jan 2014 12:46:24 +0100, a écrit :
>>>   42: xchg %ebx,%rbx
>>>
>>> I guess having both ebx and rbx on these lines isn't OK. On Linux, I get
>>> rsi instead of ebx, no problem.
>>>
>>> Samuel, any idea?
>> Mmm, IIRC, "unsigned long" on windows may not be 64bit but 32bit?
>> Perhaps we could rather include stdint.h and use uintptr_t or uint64_t
>> there (so any other unix with 32bit unsigned long is fixed), and in the
>> case of windows, include windows.h and use DWORDLONG.
>>
>

The attached patch gets the x86 backend working on win32 and win64
(without breaking Linux/*BSD on ci.inria.fr).
I am reusing the hwloc_uint64_t logic by manually reimplementing what's
not in hwloc/autogen/config.h yet.

Robin, I can send a new win64 build (based on master/v1.9) if you want
to test before I release an official v1.8 fix.

Brice

commit 9fdf2b92e740d45ef632681f16977b18ad907ffc
Author: Brice Goglin <brice.gog...@inria.fr>
List-Post: hwloc-users@lists.open-mpi.org
Date:   Tue Jan 28 15:41:57 2014 +0100

    Fix cpuid on windows 64bits and get the x86 backend reenabled there

    unsigned long isn't 64bits, so the cpuid assembly code fails to
    build during configure, and the entire x86 backend gets disabled.

    Use hwloc_uint64_t instead.

diff --git a/config/hwloc.m4 b/config/hwloc.m4
index 3806933..05414af 100644
--- a/config/hwloc.m4
+++ b/config/hwloc.m4
@@ -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 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>
       ]], [[
diff --git a/include/private/cpuid.h b/include/private/cpuid.h
index 9234848..e34d276 100644
--- a/include/private/cpuid.h
+++ b/include/private/cpuid.h
@@ -54,7 +54,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"

Reply via email to