File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2929
3030#if defined(__INTEL_COMPILER) && defined(USE_POPCNT) // Intel compiler
3131
32- #include < nmmintrin.h>
33-
3432inline bool cpu_has_popcnt () {
3533
3634 int CPUInfo[4 ] = {-1 };
@@ -42,8 +40,6 @@ inline bool cpu_has_popcnt() {
4240
4341#elif defined(_MSC_VER) && defined(USE_POPCNT) // Microsoft compiler
4442
45- #include < intrin.h>
46-
4743inline bool cpu_has_popcnt () {
4844
4945 int CPUInfo[4 ] = {-1 };
@@ -55,16 +51,6 @@ inline bool cpu_has_popcnt() {
5551
5652#elif defined(__GNUC__) && defined(USE_POPCNT) // Gcc compiler
5753
58- inline void __cpuid (unsigned int op,
59- unsigned int *eax, unsigned int *ebx,
60- unsigned int *ecx, unsigned int *edx)
61- {
62- *eax = op;
63- *ecx = 0 ;
64- __asm__ (" cpuid" : " =a" (*eax), " =b" (*ebx), " =c" (*ecx), " =d" (*edx)
65- : " 0" (*eax), " 2" (*ecx));
66- }
67-
6854inline bool cpu_has_popcnt () {
6955
7056 unsigned int eax, ebx, ecx, edx;
Original file line number Diff line number Diff line change @@ -73,4 +73,22 @@ typedef uint64_t Bitboard;
7373#define CACHE_LINE_ALIGNMENT __attribute__ ((aligned(64)))
7474#endif
7575
76+ // Define a __cpuid() function for gcc compilers, for Intel and MSVC
77+ // is already available as an intrinsic.
78+ #if defined(__INTEL_COMPILER )
79+ #include <nmmintrin.h>
80+ #elif defined(_MSC_VER )
81+ #include <intrin.h>
82+ #elif defined(__GNUC__ )
83+ inline void __cpuid (unsigned int op ,
84+ unsigned int * eax , unsigned int * ebx ,
85+ unsigned int * ecx , unsigned int * edx )
86+ {
87+ * eax = op ;
88+ * ecx = 0 ;
89+ __asm__("cpuid" : "=a" (* eax ), "=b" (* ebx ), "=c" (* ecx ), "=d" (* edx )
90+ : "0" (* eax ), "2" (* ecx ));
91+ }
92+ #endif
93+
7694#endif // !defined(TYPES_H_INCLUDED)
You can’t perform that action at this time.
0 commit comments