Index: source/lib/sysdep/arch/x86_x64/topology.cpp =================================================================== --- source/lib/sysdep/arch/x86_x64/topology.cpp +++ source/lib/sysdep/arch/x86_x64/topology.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -101,6 +101,18 @@ DEBUG_WARN_ERR(ERR::CPU_FEATURE_MISSING); const size_t logicalPerPackage = bits(regs.ebx, 16, 23); const size_t maxCoresPerPackage = MaxCoresPerPackage(); + +#if defined(CPUID_IMPLEMENTATION_PIC86) + // first generation Intel multi-core systems without HT (Penryn, + // Wolfdale, Yorkfield) falsely set the HT bit + // its confused inline asm in x86_x64::__cpuid() for GCC+i386+PIC + // hide assert and disable hyperthreading + if(logicalPerPackage % maxCoresPerPackage && x86_x64::Vendor() == x86_x64::VENDOR_INTEL && x86_x64::Family() == 6) + { + + return 1; + } +#endif // cores ought to be uniform WRT # logical processors ENSURE(logicalPerPackage % maxCoresPerPackage == 0); const size_t maxLogicalPerCore = logicalPerPackage / maxCoresPerPackage; Index: source/lib/sysdep/arch/x86_x64/x86_x64.h =================================================================== --- source/lib/sysdep/arch/x86_x64/x86_x64.h +++ source/lib/sysdep/arch/x86_x64/x86_x64.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -37,6 +37,19 @@ #include // __rdtsc #endif +#if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 150030729 +// VC10+ and VC9 SP1: __cpuidex is already available +# define CPUID_IMPLEMENTATION_WINDOWS +#elif GCC_VERSION +# if defined(__i386__) && defined(__PIC__) +# define CPUID_IMPLEMENTATION_PIC86 +# else +# define CPUID_IMPLEMENTATION_UNIX +# endif +#else +# error "compiler not supported" +#endif + namespace x86_x64 { /** Index: source/lib/sysdep/arch/x86_x64/x86_x64.cpp =================================================================== --- source/lib/sysdep/arch/x86_x64/x86_x64.cpp +++ source/lib/sysdep/arch/x86_x64/x86_x64.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -46,23 +46,21 @@ namespace x86_x64 { -#if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 150030729 +#if defined(CPUID_IMPLEMENTATION_WINDOWS) // VC10+ and VC9 SP1: __cpuidex is already available -#elif GCC_VERSION -# if defined(__i386__) && defined(__PIC__) -# define __cpuidex(regsArray, level, index)\ +#elif defined(CPUID_IMPLEMENTATION_PIC86) +# define __cpuidex(regsArray, level, index)\ __asm__ __volatile__ ("pushl %%ebx\n"\ "cpuid\n"\ "mov %%ebx,%1\n"\ "popl %%ebx"\ : "=a" ((regsArray)[0]), "=r" ((regsArray)[1]), "=c" ((regsArray)[2]), "=d" ((regsArray)[3])\ : "0" (level), "2" (index)); -# else -# define __cpuidex(regsArray, level, index)\ +#elif defined(CPUID_IMPLEMENTATION_UNIX) +# define __cpuidex(regsArray, level, index)\ __asm__ __volatile__ ("cpuid"\ : "=a" ((regsArray)[0]), "=b" ((regsArray)[1]), "=c" ((regsArray)[2]), "=d" ((regsArray)[3])\ : "0" (level), "2" (index)); -# endif #else # error "compiler not supported" #endif