support non-intel-cpu visual studio
diff --git a/xbyak/xbyak_util.h b/xbyak/xbyak_util.h
index 45811bb..78ff065 100644
--- a/xbyak/xbyak_util.h
+++ b/xbyak/xbyak_util.h
@@ -9,7 +9,11 @@
*/
#include "xbyak.h"
-#if defined(__i386__) || defined(__x86_64__)
+#if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)
+ #define XBYAK_INTEL_CPU_SPECIFIC
+#endif
+
+#ifdef XBYAK_INTEL_CPU_SPECIFIC
#ifdef _MSC_VER
#if (_MSC_VER < 1400) && defined(XBYAK32)
static inline __declspec(naked) void __cpuid(int[4], int)
@@ -82,7 +86,7 @@
}
void setFamily()
{
- unsigned int data[4] = {0};
+ unsigned int data[4] = {};
getCpuid(1, data);
stepping = data[0] & mask(4);
model = (data[0] >> 4) & mask(4);
@@ -109,7 +113,7 @@
{
if ((type_ & tINTEL) == 0) return;
- unsigned int data[4] = {0};
+ unsigned int data[4] = {};
/* CAUTION: These numbers are configuration as shipped by Intel. */
getCpuidEx(0x0, 0, data);
@@ -150,7 +154,7 @@
const unsigned int UNIFIED_CACHE = 3;
unsigned int smt_width = 0;
unsigned int logical_cores = 0;
- unsigned int data[4] = {0};
+ unsigned int data[4] = {};
if (x2APIC_supported_) {
smt_width = numCores_[0];
@@ -221,37 +225,44 @@
*/
static inline void getCpuid(unsigned int eaxIn, unsigned int data[4])
{
-#if defined(__i386__) || defined(__x86_64__)
-#ifdef _MSC_VER
+#ifdef XBYAK_INTEL_CPU_SPECIFIC
+ #ifdef _MSC_VER
__cpuid(reinterpret_cast<int*>(data), eaxIn);
-#else
+ #else
__cpuid(eaxIn, data[0], data[1], data[2], data[3]);
-#endif
+ #endif
+#else
+ (void)eaxIn;
+ (void)data;
#endif
}
static inline void getCpuidEx(unsigned int eaxIn, unsigned int ecxIn, unsigned int data[4])
{
-#if defined(__i386__) || defined(__x86_64__)
-#ifdef _MSC_VER
+#ifdef XBYAK_INTEL_CPU_SPECIFIC
+ #ifdef _MSC_VER
__cpuidex(reinterpret_cast<int*>(data), eaxIn, ecxIn);
-#else
+ #else
__cpuid_count(eaxIn, ecxIn, data[0], data[1], data[2], data[3]);
-#endif
+ #endif
+#else
+ (void)eaxIn;
+ (void)ecxIn;
+ (void)data;
#endif
}
static inline uint64 getXfeature()
{
-#if defined(__i386__) || defined(__x86_64__)
-#ifdef _MSC_VER
+#ifdef XBYAK_INTEL_CPU_SPECIFIC
+ #ifdef _MSC_VER
return _xgetbv(0);
-#else
+ #else
unsigned int eax, edx;
// xgetvb is not support on gcc 4.2
// __asm__ volatile("xgetbv" : "=a"(eax), "=d"(edx) : "c"(0));
__asm__ volatile(".byte 0x0f, 0x01, 0xd0" : "=a"(eax), "=d"(edx) : "c"(0));
return ((uint64)edx << 32) | eax;
-#endif
-#else // defined(__i386__) || defined(__x86_64__)
+ #endif
+#else
return 0;
#endif
}
@@ -329,7 +340,7 @@
, coresSharignDataCache_()
, dataCacheLevels_(0)
{
- unsigned int data[4] = {0};
+ unsigned int data[4] = {};
const unsigned int& EAX = data[0];
const unsigned int& EBX = data[1];
const unsigned int& ECX = data[2];
@@ -438,15 +449,15 @@
public:
static inline uint64 getRdtsc()
{
-#if defined(__i386__) || defined(__x86_64__)
-#ifdef _MSC_VER
+#ifdef XBYAK_INTEL_CPU_SPECIFIC
+ #ifdef _MSC_VER
return __rdtsc();
-#else
+ #else
unsigned int eax, edx;
__asm__ volatile("rdtsc" : "=a"(eax), "=d"(edx));
return ((uint64)edx << 32) | eax;
-#endif
-#else // defined(__i386__) || defined(__x86_64__)
+ #endif
+#else
// TODO: Need another impl of Clock or rdtsc-equivalent for non-x86 cpu
return 0;
#endif