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

github.com/google/cpu_features.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Chatelet <chatelet.guillaume@gmail.com>2019-01-17 18:42:06 +0300
committerGitHub <noreply@github.com>2019-01-17 18:42:06 +0300
commitb1fa492d8f4f591d42279edb36569341df0aafaa (patch)
treeb12a430c7e2f2eb137160e96a51543af3985b97f
parentc4305584e0e78d37101d4762815632b59ffd6940 (diff)
parent918553a21fa89272e644c674fd87c460c1759fcc (diff)
Merge pull request #53 from google/export_GetArmCpuId
Export GetArmCpuId function
-rw-r--r--include/cpuinfo_arm.h4
-rw-r--r--src/cpuinfo_arm.c4
-rw-r--r--test/cpuinfo_arm_test.cc26
3 files changed, 21 insertions, 13 deletions
diff --git a/include/cpuinfo_arm.h b/include/cpuinfo_arm.h
index 7a94bb0..5930486 100644
--- a/include/cpuinfo_arm.h
+++ b/include/cpuinfo_arm.h
@@ -15,6 +15,7 @@
#ifndef CPU_FEATURES_INCLUDE_CPUINFO_ARM_H_
#define CPU_FEATURES_INCLUDE_CPUINFO_ARM_H_
+#include <stdint.h> // uint32_t
#include "cpu_features_macros.h"
CPU_FEATURES_START_CPP_NAMESPACE
@@ -51,6 +52,9 @@ typedef struct {
ArmInfo GetArmInfo(void);
+// Compute CpuId from ArmInfo.
+uint32_t GetArmCpuId(const ArmInfo* const info);
+
////////////////////////////////////////////////////////////////////////////////
// Introspection functions
diff --git a/src/cpuinfo_arm.c b/src/cpuinfo_arm.c
index 3ea0641..24b9067 100644
--- a/src/cpuinfo_arm.c
+++ b/src/cpuinfo_arm.c
@@ -101,7 +101,7 @@ static bool HandleArmLine(const LineResult result, ArmInfo* const info,
return !result.eof;
}
-static uint32_t GetCpuId(const ArmInfo* const info) {
+uint32_t GetArmCpuId(const ArmInfo* const info) {
return (ExtractBitRange(info->implementer, 7, 0) << 24) |
(ExtractBitRange(info->variant, 3, 0) << 20) |
(ExtractBitRange(info->part, 11, 0) << 4) |
@@ -118,7 +118,7 @@ static void FixErrors(ArmInfo* const info,
// Handle kernel configuration bugs that prevent the correct reporting of CPU
// features.
- switch (GetCpuId(info)) {
+ switch (GetArmCpuId(info)) {
case 0x4100C080:
// Special case: The emulator-specific Android 4.2 kernel fails to report
// support for the 32-bit ARM IDIV instruction. Technically, this is a
diff --git a/test/cpuinfo_arm_test.cc b/test/cpuinfo_arm_test.cc
index a72c566..34c7551 100644
--- a/test/cpuinfo_arm_test.cc
+++ b/test/cpuinfo_arm_test.cc
@@ -82,17 +82,17 @@ TEST(CpuinfoArmTest, InvalidArmv7) {
DisableHardwareCapabilities();
auto& fs = GetEmptyFilesystem();
fs.CreateFile("/proc/cpuinfo",
- R"(Processor : ARMv6-compatible processor rev 6 (v6l)
-BogoMIPS : 199.47
-Features : swp half thumb fastmult vfp edsp java
-CPU implementer : 0x41
-CPU architecture: 7
-CPU variant : 0x0
-CPU part : 0xb76
-CPU revision : 6
-
-Hardware : SPICA
-Revision : 0020
+ R"(Processor : ARMv6-compatible processor rev 6 (v6l)
+BogoMIPS : 199.47
+Features : swp half thumb fastmult vfp edsp java
+CPU implementer : 0x41
+CPU architecture: 7
+CPU variant : 0x0
+CPU part : 0xb76
+CPU revision : 6
+
+Hardware : SPICA
+Revision : 0020
Serial : 33323613546d00ec )");
const auto info = GetArmInfo();
EXPECT_EQ(info.architecture, 6);
@@ -137,6 +137,8 @@ CPU revision : 2)");
const auto info = GetArmInfo();
EXPECT_TRUE(info.features.idiva);
EXPECT_TRUE(info.features.idivt);
+
+ EXPECT_EQ(GetArmCpuId(&info), 0x510006f2);
}
// The Nexus 4 (Qualcomm Krait) kernel configuration forgets to report IDIV
@@ -153,6 +155,8 @@ CPU revision : 3)");
const auto info = GetArmInfo();
EXPECT_TRUE(info.features.idiva);
EXPECT_TRUE(info.features.idivt);
+
+ EXPECT_EQ(GetArmCpuId(&info), 0x510006f3);
}
// The emulator-specific Android 4.2 kernel fails to report support for the