1
0
mirror of https://github.com/google/cpu_features.git synced 2025-04-28 07:23:37 +02:00

Merge pull request #53 from google/export_GetArmCpuId

Export GetArmCpuId function
This commit is contained in:
Guillaume Chatelet 2019-01-17 16:42:06 +01:00 committed by GitHub
commit b1fa492d8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 12 deletions

View File

@ -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

View File

@ -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

View File

@ -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