summaryrefslogtreecommitdiff
path: root/Source/Core/Common/ArmCPUDetect.cpp
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2016-06-24 10:43:46 +0200
committerPierre Bourdon <delroth@gmail.com>2016-06-24 10:43:46 +0200
commit3570c7f03a2aa90aa634f96c0af1969af610f14d (patch)
tree4252e03c0e853ba7cffe022937698c854ad0eaa9 /Source/Core/Common/ArmCPUDetect.cpp
parent2115e8a4a6814e32107b5205ff5c95bbd3c6e99c (diff)
Reformat all the things. Have fun with merge conflicts.
Diffstat (limited to 'Source/Core/Common/ArmCPUDetect.cpp')
-rw-r--r--Source/Core/Common/ArmCPUDetect.cpp107
1 files changed, 56 insertions, 51 deletions
diff --git a/Source/Core/Common/ArmCPUDetect.cpp b/Source/Core/Common/ArmCPUDetect.cpp
index 4e68054410..64e36b0d67 100644
--- a/Source/Core/Common/ArmCPUDetect.cpp
+++ b/Source/Core/Common/ArmCPUDetect.cpp
@@ -2,87 +2,92 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
+#include <asm/hwcap.h>
#include <fstream>
#include <sstream>
#include <string>
-#include <unistd.h>
-#include <asm/hwcap.h>
#include <sys/auxv.h>
+#include <unistd.h>
-#include "Common/CommonTypes.h"
#include "Common/CPUDetect.h"
+#include "Common/CommonTypes.h"
#include "Common/StringUtil.h"
const char procfile[] = "/proc/cpuinfo";
static std::string GetCPUString()
{
- const std::string marker = "Hardware\t: ";
- std::string cpu_string = "Unknown";
+ const std::string marker = "Hardware\t: ";
+ std::string cpu_string = "Unknown";
- std::string line;
- std::ifstream file(procfile);
+ std::string line;
+ std::ifstream file(procfile);
- if (!file)
- return cpu_string;
+ if (!file)
+ return cpu_string;
- while (std::getline(file, line))
- {
- if (line.find(marker) != std::string::npos)
- {
- cpu_string = line.substr(marker.length());
- break;
- }
- }
+ while (std::getline(file, line))
+ {
+ if (line.find(marker) != std::string::npos)
+ {
+ cpu_string = line.substr(marker.length());
+ break;
+ }
+ }
- return cpu_string;
+ return cpu_string;
}
CPUInfo cpu_info;
CPUInfo::CPUInfo()
{
- Detect();
+ Detect();
}
// Detects the various CPU features
void CPUInfo::Detect()
{
- // Set some defaults here
- // When ARMv8 CPUs come out, these need to be updated.
- HTT = false;
- OS64bit = true;
- CPU64bit = true;
- Mode64bit = true;
- vendor = VENDOR_ARM;
-
- // Get the information about the CPU
- num_cores = sysconf(_SC_NPROCESSORS_CONF);
- strncpy(cpu_string, GetCPUString().c_str(), sizeof(cpu_string));
-
- unsigned long hwcaps = getauxval(AT_HWCAP);
- bFP = hwcaps & HWCAP_FP;
- bASIMD = hwcaps & HWCAP_ASIMD;
- bAES = hwcaps & HWCAP_AES;
- bCRC32 = hwcaps & HWCAP_CRC32;
- bSHA1 = hwcaps & HWCAP_SHA1;
- bSHA2 = hwcaps & HWCAP_SHA2;
+ // Set some defaults here
+ // When ARMv8 CPUs come out, these need to be updated.
+ HTT = false;
+ OS64bit = true;
+ CPU64bit = true;
+ Mode64bit = true;
+ vendor = VENDOR_ARM;
+
+ // Get the information about the CPU
+ num_cores = sysconf(_SC_NPROCESSORS_CONF);
+ strncpy(cpu_string, GetCPUString().c_str(), sizeof(cpu_string));
+
+ unsigned long hwcaps = getauxval(AT_HWCAP);
+ bFP = hwcaps & HWCAP_FP;
+ bASIMD = hwcaps & HWCAP_ASIMD;
+ bAES = hwcaps & HWCAP_AES;
+ bCRC32 = hwcaps & HWCAP_CRC32;
+ bSHA1 = hwcaps & HWCAP_SHA1;
+ bSHA2 = hwcaps & HWCAP_SHA2;
}
// Turn the CPU info into a string we can show
std::string CPUInfo::Summarize()
{
- std::string sum;
- if (num_cores == 1)
- sum = StringFromFormat("%s, %i core", cpu_string, num_cores);
- else
- sum = StringFromFormat("%s, %i cores", cpu_string, num_cores);
-
- if (bAES) sum += ", AES";
- if (bCRC32) sum += ", CRC32";
- if (bSHA1) sum += ", SHA1";
- if (bSHA2) sum += ", SHA2";
- if (CPU64bit) sum += ", 64-bit";
-
- return sum;
+ std::string sum;
+ if (num_cores == 1)
+ sum = StringFromFormat("%s, %i core", cpu_string, num_cores);
+ else
+ sum = StringFromFormat("%s, %i cores", cpu_string, num_cores);
+
+ if (bAES)
+ sum += ", AES";
+ if (bCRC32)
+ sum += ", CRC32";
+ if (bSHA1)
+ sum += ", SHA1";
+ if (bSHA2)
+ sum += ", SHA2";
+ if (CPU64bit)
+ sum += ", 64-bit";
+
+ return sum;
}