mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
CPUDetect: Ensure we never get zero cores.
This commit is contained in:
1 parent
92ace6716a
commit
e725eddf13
1 file changed
+6
-3
@@ -26,6 +26,7 @@
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <memory.h>
|
||||
#include <set>
|
||||
@@ -369,7 +370,7 @@ void CPUInfo::Detect() {
|
||||
}
|
||||
|
||||
// This seems to be the count per core. Hopefully all cores are the same, but we counted each above.
|
||||
logical_cpu_count /= num_cores;
|
||||
logical_cpu_count /= std::max(num_cores, 1);
|
||||
#elif PPSSPP_PLATFORM(LINUX)
|
||||
if (File::Exists("/sys/devices/system/cpu/present")) {
|
||||
// This may not count unplugged cores, but at least it's a best guess.
|
||||
@@ -396,7 +397,7 @@ void CPUInfo::Detect() {
|
||||
}
|
||||
|
||||
// This seems to be the count per core. Hopefully all cores are the same, but we counted each above.
|
||||
std::max(logical_cpu_count /= std::max(num_cores, 1), 1);
|
||||
logical_cpu_count /= std::max(num_cores, 1);
|
||||
#elif PPSSPP_PLATFORM(MAC)
|
||||
int num = 0;
|
||||
size_t sz = sizeof(num);
|
||||
@@ -404,10 +405,12 @@ void CPUInfo::Detect() {
|
||||
num_cores = num;
|
||||
sz = sizeof(num);
|
||||
if (sysctlbyname("hw.logicalcpu_max", &num, &sz, nullptr, 0) == 0) {
|
||||
logical_cpu_count = num / num_cores;
|
||||
logical_cpu_count = num / std::max(num_cores, 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (logical_cpu_count <= 0)
|
||||
logical_cpu_count = 1;
|
||||
}
|
||||
|
||||
// Turn the cpu info into a string we can show
|
||||
|
||||
Reference in new issue
Block a user