Skip to content

Commit 8a6fa45

Browse files
committed
Fix build for architectures without CPUID
Signed-off-by: Stefan Weil <[email protected]>
1 parent 0aca609 commit 8a6fa45

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/arch/simddetect.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,17 @@
2222
#include "params.h" // for STRING_VAR
2323
#include "tprintf.h" // for tprintf
2424

25+
#if defined(AVX) || defined(AVX2) || defined(SSE4_1)
26+
# define HAS_CPUID
27+
#endif
28+
29+
#if defined(HAS_CPUID)
2530
#if defined(__GNUC__)
2631
# include <cpuid.h>
2732
#elif defined(_WIN32)
2833
# include <intrin.h>
2934
#endif
35+
#endif
3036

3137
namespace tesseract {
3238

@@ -75,6 +81,7 @@ SIMDDetect::SIMDDetect() {
7581
// The fallback is a generic dot product calculation.
7682
SetDotProduct(DotProductGeneric);
7783

84+
#if defined(HAS_CPUID)
7885
#if defined(__GNUC__)
7986
unsigned int eax, ebx, ecx, edx;
8087
if (__get_cpuid(1, &eax, &ebx, &ecx, &edx) != 0) {
@@ -110,6 +117,7 @@ SIMDDetect::SIMDDetect() {
110117
}
111118
#else
112119
#error "I don't know how to test for SIMD with this compiler"
120+
#endif
113121
#endif
114122

115123
// Select code for calculation of dot product based on autodetection.

0 commit comments

Comments
 (0)