diff --git a/CMakeLists.txt b/CMakeLists.txt index 745fd1898..169d4a196 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -180,8 +180,11 @@ option(OCIO_USE_OIIO_FOR_APPS "Request OIIO to build apps (ociolutimage, ociocon if (NOT APPLE) - if ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(AMD64|IA64|EM64T|X86|x86_64|i386|i686)") + if ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(AMD64|IA64|EM64T|x86_64|X86|i386|i686)") # Intel-based architecture (not APPLE) + if ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(X86|i386|i686)") + set(OCIO_ARCH_X86_32 1) + endif() set(OCIO_ARCH_X86 1) set(OCIO_BUILD_ENABLE_OPTIMIZATIONS_SSE ON) set(OCIO_BUILD_ENABLE_OPTIMIZATIONS_AVX ON) diff --git a/src/OpenColorIO/CPUInfo.cpp b/src/OpenColorIO/CPUInfo.cpp index 7aae56ad9..28fcd9477 100644 --- a/src/OpenColorIO/CPUInfo.cpp +++ b/src/OpenColorIO/CPUInfo.cpp @@ -50,6 +50,13 @@ static inline void cpuid(int index, int *data) { #if _MSC_VER __cpuid(data, index); +#elif OCIO_ARCH_X86_32 + __asm__ volatile ( + "mov %%ebx, %%esi \n\t" + "cpuid \n\t" + "xchg %%ebx, %%esi" + : "=a" (data[0]), "=S" (data[1]), "=c" (data[2]), "=d" (data[3]) + : "0" (index), "2"(0)); #else __asm__ volatile ( "mov %%rbx, %%rsi \n\t" diff --git a/src/OpenColorIO/CPUInfoConfig.h.in b/src/OpenColorIO/CPUInfoConfig.h.in index a94a7bb84..472af56a4 100644 --- a/src/OpenColorIO/CPUInfoConfig.h.in +++ b/src/OpenColorIO/CPUInfoConfig.h.in @@ -3,6 +3,7 @@ #cmakedefine01 OCIO_ARCH_X86 +#cmakedefine01 OCIO_ARCH_X86_32 // Relevant only for arm64 architecture. #if defined(__aarch64__)