From: Brice Goglin Date: Tue, 28 Jan 2014 14:41:57 +0000 (+0100) Subject: Fix cpuid on windows 64bits so that the x86 backend is enabled as expected X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=23be199cf9ec1f16adbf475447eb8473916a27e6;p=people%2Fandrewcoop%2Fhwloc.git Fix cpuid on windows 64bits so that the x86 backend is enabled as expected 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. --- diff --git a/config/hwloc.m4 b/config/hwloc.m4 index 38069335..bfee6e11 100644 --- a/config/hwloc.m4 +++ b/config/hwloc.m4 @@ -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 " + 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 " + fi + fi AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include + $CPUID_CHECK_HEADERS + $CPUID_CHECK_DEFINE #define __hwloc_inline #include ]], [[ diff --git a/include/private/cpuid.h b/include/private/cpuid.h index 92348485..214ab382 100644 --- a/include/private/cpuid.h +++ b/include/private/cpuid.h @@ -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"