X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=libs%2Fpbd%2Ffpu.cc;h=78bcd3d8121f0f71e79cd3ebcc700124ae7f8eb9;hb=659701c59b76bdcbfcf5c1b8ce8962eb3f6a1ca2;hp=c72f65d303ce85e4c92e0995b9a83c4a4c10fddc;hpb=5a41b86028cd5068d8e74d7481dca60aefeff75d;p=ardour.git diff --git a/libs/pbd/fpu.cc b/libs/pbd/fpu.cc index c72f65d303..78bcd3d812 100644 --- a/libs/pbd/fpu.cc +++ b/libs/pbd/fpu.cc @@ -33,7 +33,7 @@ #include "pbd/fpu.h" #include "pbd/error.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace PBD; using namespace std; @@ -71,24 +71,18 @@ __cpuid(int regs[4], int cpuid_leaf) #endif /* !PLATFORM_WINDOWS */ -#ifndef COMPILER_MSVC - -static uint64_t -_xgetbv (uint32_t xcr) -{ -#ifdef __APPLE__ - /* it would be nice to make this work on OS X but as long we use veclib, - we don't really need to know about SSE/AVX on that platform. - */ - return 0; -#else - uint32_t eax, edx; - __asm__ volatile ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (xcr)); - return (static_cast(edx) << 32) | eax; +#ifndef HAVE_XGETBV // Allow definition by build system + #if defined(__MINGW32__) && defined(__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR >= 5 + #define HAVE_XGETBV + #elif defined(_MSC_VER) && _MSC_VER >= 1600 + // '_xgetbv()' was only available from VC10 onwards + #define HAVE_XGETBV + #endif #endif -} -#elif _MSC_VER < 1600 +#ifndef HAVE_XGETBV + +#ifdef COMPILER_MSVC // '_xgetbv()' was only available from VC10 onwards __declspec(noinline) static uint64_t @@ -101,11 +95,29 @@ _xgetbv (uint32_t xcr) // to place this function into its own (unoptimized) source file. __asm { mov ecx, [xcr] - __asm _emit 0x0f __asm _emit 0x01 __asm _emit 0xd0 /*xgetbv*/ - } + __asm _emit 0x0f __asm _emit 0x01 __asm _emit 0xd0 /*xgetbv*/ + } +} + +#else + +static uint64_t +_xgetbv (uint32_t xcr) +{ +#ifdef __APPLE__ + /* it would be nice to make this work on OS X but as long we use veclib, + we don't really need to know about SSE/AVX on that platform. + */ + return 0; +#else + uint32_t eax, edx; + __asm__ volatile ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (xcr)); + return (static_cast(edx) << 32) | eax; +#endif } #endif /* !COMPILER_MSVC */ +#endif /* !HAVE_XGETBV */ #endif /* ARCH_X86 */ #ifndef _XCR_XFEATURE_ENABLED_MASK