@@ -87,11 +87,12 @@ static inline uint32_t _lrotl(uint32_t value, int shift)
87
87
#ifdef _WIN32
88
88
#include < intrin.h>
89
89
#pragma intrinsic(__rdtsc)
90
- #endif
91
-
90
+ #endif // _WIN32
91
+ #endif // _rdtsc
92
+ #ifndef _rdtsc
92
93
static inline uint64_t _rdtsc ()
93
94
{
94
- #if _WIN32
95
+ #ifdef _WIN32
95
96
return __rdtsc ();
96
97
#elif defined(__has_builtin) && __has_builtin(__builtin_readcyclecounter)
97
98
return __builtin_readcyclecounter ();
@@ -101,9 +102,9 @@ static inline uint64_t _rdtsc()
101
102
#error "No implementation for _rdtsc"
102
103
#endif
103
104
}
104
- #endif
105
+ #endif // _rdtsc
105
106
106
- #ifdef _MSC_VER
107
+ #ifdef _WIN32
107
108
#include < intrin.h>
108
109
#pragma intrinsic(_ReturnAddress)
109
110
#elif defined(__has_builtin)
@@ -132,17 +133,20 @@ static inline uint64_t _rdtsc()
132
133
#endif
133
134
134
135
#ifndef cpuid
135
- #if defined(_MSC_VER)
136
+ #if (defined _M_IX86 || defined _M_X64 || defined __i386__ || defined __amd64__)
137
+ #ifdef _WIN32
136
138
#include < intrin.h>
137
139
#define cpuid (regs, cpuid_type ) __cpuid(reinterpret_cast <int *>(regs), cpuid_type)
138
- #elif (defined __clang__ || defined __GNUC__) && (defined __i386__ || defined __amd64__)
140
+ #elif (defined __clang__ || defined __GNUC__)
139
141
#include < cpuid.h>
140
142
#define cpuid (regs, cpuid_type ) __cpuid(cpuid_type, regs[0 ], regs[1 ], regs[2 ], regs[3 ])
141
- #else
142
- /* Just return 0 for everything if its not x86 */
143
+ #endif
144
+ #endif // (defined _M_IX86 || defined _M_X64 || defined __i386__ || defined __amd64__)
145
+ #endif // cpuid
146
+ #ifndef cpuid
147
+ /* Just return 0 for everything if its not x86 or as fallback */
143
148
#include < string.h>
144
149
#define cpuid (regs, cpuid_type ) memset(regs, 0 , 16 )
145
- #endif
146
- #endif // cpuid
150
+ #endif // cpuid
147
151
148
- #endif // defined(_MSC_VER) && _MSC_VER < 1300
152
+ #endif // !( defined(_MSC_VER) && _MSC_VER < 1300)
0 commit comments