Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-04-29 17:25:35 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-04-29 17:25:35 +0300
commit738a890025eccc1b98fdc11386a9f203acda71c4 (patch)
tree24553cbb0a6990840a3fb15f2ec0903c01e86e0f /intern
parent9bdb2f5e0b2cbdcdb06af5d672cd8c22742346b2 (diff)
parent5946352ae2cd3ef14d8af07f8d4bd047954b9fd1 (diff)
Merge branch 'blender-v2.93-release'
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/util/util_system.cpp46
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;