diff options
author | Brecht Van Lommel <brecht@blender.org> | 2021-04-29 17:21:30 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2021-04-29 17:22:53 +0300 |
commit | dcf2c6e225083b3e6145f8dc2b3116ef37d5827f (patch) | |
tree | 19fbc14574eece8f84ebe6c5d8ce94cfe775f8a2 /intern/cycles/util/util_system.cpp | |
parent | 87ba01dba90b0b2ffbad2b9e07552734959814db (diff) |
Fix build error after recent changes to CPU name detection
Diffstat (limited to 'intern/cycles/util/util_system.cpp')
-rw-r--r-- | intern/cycles/util/util_system.cpp | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/intern/cycles/util/util_system.cpp b/intern/cycles/util/util_system.cpp index 8971867b736..03bc5aea1dd 100644 --- a/intern/cycles/util/util_system.cpp +++ b/intern/cycles/util/util_system.cpp @@ -145,7 +145,8 @@ int system_cpu_num_active_group_processors() return numaAPI_GetNumCurrentNodesProcessors(); } -#if !defined(__APPLE__) && (!defined(_WIN32) || defined(FREE_WINDOWS)) +/* Equivalent of Windows __cpuid for x86 processors on other platforms. */ +#if (!defined(_WIN32) || defined(FREE_WINDOWS)) && (defined(__x86_64__) || defined(__i386__)) static void __cpuid(int data[4], int selector) { # if defined(__x86_64__) @@ -167,12 +168,33 @@ static void __cpuid(int data[4], int selector) string system_cpu_brand_string() { #if defined(__APPLE__) + /* Get from system on macOS. */ char modelname[512] = ""; size_t bufferlen = 512; if (sysctlbyname("machdep.cpu.brand_string", &modelname, &bufferlen, NULL, 0) == 0) { return modelname; } -#elif !defined(WIN32) && !defined(__x86_64__) && !defined(__i386__) +#elif defined(WIN32) || defined(__x86_64__) || defined(__i386__) + /* Get from intrinsics on Windows and x86. */ + char buf[49] = {0}; + int result[4] = {0}; + + __cpuid(result, 0x80000000); + + if (result[0] != 0 && result[0] >= (int)0x80000004) { + __cpuid((int *)(buf + 0), 0x80000002); + __cpuid((int *)(buf + 16), 0x80000003); + __cpuid((int *)(buf + 32), 0x80000004); + + string brand = buf; + + /* Make it a bit more presentable. */ + brand = string_remove_trademark(brand); + + return brand; + } +#else + /* Get from /proc/cpuinfo on Unix systems. */ FILE *cpuinfo = fopen("/proc/cpuinfo", "r"); if (cpuinfo != nullptr) { char cpuinfo_buf[513] = ""; @@ -192,24 +214,6 @@ string system_cpu_brand_string() } } } -#else - char buf[49] = {0}; - int result[4] = {0}; - - __cpuid(result, 0x80000000); - - if (result[0] != 0 && result[0] >= (int)0x80000004) { - __cpuid((int *)(buf + 0), 0x80000002); - __cpuid((int *)(buf + 16), 0x80000003); - __cpuid((int *)(buf + 32), 0x80000004); - - string brand = buf; - - /* make it a bit more presentable */ - brand = string_remove_trademark(brand); - - return brand; - } #endif return "Unknown CPU"; } @@ -219,7 +223,7 @@ int system_cpu_bits() return (sizeof(void *) * 8); } -#if defined(__x86_64__) || defined(_M_X64) || defined(i386) || defined(_M_IX86) +#if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86) struct CPUCapabilities { bool x64; |