mirror of
https://github.com/google/cpu_features.git
synced 2025-04-27 23:22:31 +02:00
[NFC] clang-format codebase (#134)
* [NFC] clang-format codebase * revert to 80 char columns at the price of uglier table init * Specifically disabling clang-format for table initialization
This commit is contained in:
parent
38f2a0274f
commit
22a5362e11
@ -15,8 +15,8 @@
|
||||
#ifndef CPU_FEATURES_INCLUDE_CPUINFO_AARCH64_H_
|
||||
#define CPU_FEATURES_INCLUDE_CPUINFO_AARCH64_H_
|
||||
|
||||
#include "cpu_features_macros.h"
|
||||
#include "cpu_features_cache_info.h"
|
||||
#include "cpu_features_macros.h"
|
||||
|
||||
CPU_FEATURES_START_CPP_NAMESPACE
|
||||
|
||||
|
@ -16,8 +16,9 @@
|
||||
#define CPU_FEATURES_INCLUDE_CPUINFO_ARM_H_
|
||||
|
||||
#include <stdint.h> // uint32_t
|
||||
#include "cpu_features_macros.h"
|
||||
|
||||
#include "cpu_features_cache_info.h"
|
||||
#include "cpu_features_macros.h"
|
||||
|
||||
CPU_FEATURES_START_CPP_NAMESPACE
|
||||
|
||||
@ -25,11 +26,13 @@ typedef struct {
|
||||
int swp : 1; // SWP instruction (atomic read-modify-write)
|
||||
int half : 1; // Half-word loads and stores
|
||||
int thumb : 1; // Thumb (16-bit instruction set)
|
||||
int _26bit : 1; // "26 Bit" Model (Processor status register folded into program counter)
|
||||
int _26bit : 1; // "26 Bit" Model (Processor status register folded into
|
||||
// program counter)
|
||||
int fastmult : 1; // 32x32->64-bit multiplication
|
||||
int fpa : 1; // Floating point accelerator
|
||||
int vfp : 1; // Vector Floating Point.
|
||||
int edsp : 1; // DSP extensions (the 'e' variant of the ARM9 CPUs, and all others above)
|
||||
int edsp : 1; // DSP extensions (the 'e' variant of the ARM9 CPUs, and all
|
||||
// others above)
|
||||
int java : 1; // Jazelle (Java bytecode accelerator)
|
||||
int iwmmxt : 1; // Intel Wireless MMX Technology.
|
||||
int crunch : 1; // MaverickCrunch coprocessor
|
||||
@ -42,7 +45,8 @@ typedef struct {
|
||||
int idiva : 1; // SDIV and UDIV hardware division in ARM mode.
|
||||
int idivt : 1; // SDIV and UDIV hardware division in Thumb mode.
|
||||
int vfpd32 : 1; // VFP with 32 D-registers
|
||||
int lpae : 1; // Large Physical Address Extension (>4GB physical memory on 32-bit architecture)
|
||||
int lpae : 1; // Large Physical Address Extension (>4GB physical memory on
|
||||
// 32-bit architecture)
|
||||
int evtstrm : 1; // kernel event stream using generic architected timer
|
||||
int aes : 1; // Hardware-accelerated Advanced Encryption Standard.
|
||||
int pmull : 1; // Polynomial multiply long.
|
||||
|
@ -15,8 +15,8 @@
|
||||
#ifndef CPU_FEATURES_INCLUDE_CPUINFO_MIPS_H_
|
||||
#define CPU_FEATURES_INCLUDE_CPUINFO_MIPS_H_
|
||||
|
||||
#include "cpu_features_macros.h"
|
||||
#include "cpu_features_cache_info.h"
|
||||
#include "cpu_features_macros.h"
|
||||
|
||||
CPU_FEATURES_START_CPP_NAMESPACE
|
||||
|
||||
|
@ -15,8 +15,8 @@
|
||||
#ifndef CPU_FEATURES_INCLUDE_CPUINFO_PPC_H_
|
||||
#define CPU_FEATURES_INCLUDE_CPUINFO_PPC_H_
|
||||
|
||||
#include "cpu_features_macros.h"
|
||||
#include "cpu_features_cache_info.h"
|
||||
#include "cpu_features_macros.h"
|
||||
#include "internal/hwcaps.h"
|
||||
|
||||
CPU_FEATURES_START_CPP_NAMESPACE
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cpu_features_macros.h"
|
||||
|
||||
CPU_FEATURES_START_CPP_NAMESPACE
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cpu_features_macros.h"
|
||||
|
||||
CPU_FEATURES_START_CPP_NAMESPACE
|
||||
|
@ -18,6 +18,7 @@
|
||||
#define CPU_FEATURES_INCLUDE_INTERNAL_HWCAPS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cpu_features_macros.h"
|
||||
|
||||
CPU_FEATURES_START_CPP_NAMESPACE
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "cpu_features_macros.h"
|
||||
|
||||
CPU_FEATURES_START_CPP_NAMESPACE
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cpu_features_macros.h"
|
||||
#include "internal/hwcaps.h"
|
||||
#include "internal/string_view.h"
|
||||
|
@ -1,11 +1,12 @@
|
||||
#include "cpu-features.h"
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include "cpu_features_macros.h"
|
||||
#include "internal/filesystem.h"
|
||||
#include "internal/stack_line_reader.h"
|
||||
#include "internal/string_view.h"
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#if defined(CPU_FEATURES_ARCH_ARM)
|
||||
#include "cpuinfo_arm.h"
|
||||
#elif defined(CPU_FEATURES_ARCH_X86)
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "cpu-features.h"
|
||||
|
||||
int main() {
|
||||
|
@ -14,15 +14,15 @@
|
||||
|
||||
#include "cpuinfo_aarch64.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "internal/filesystem.h"
|
||||
#include "internal/hwcaps.h"
|
||||
#include "internal/stack_line_reader.h"
|
||||
#include "internal/string_view.h"
|
||||
#include "internal/unix_features_aggregator.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
||||
DECLARE_SETTER_AND_GETTER(Aarch64Features, fp)
|
||||
DECLARE_SETTER_AND_GETTER(Aarch64Features, asimd)
|
||||
DECLARE_SETTER_AND_GETTER(Aarch64Features, evtstrm)
|
||||
@ -75,6 +75,7 @@ DECLARE_SETTER_AND_GETTER(Aarch64Features, rng)
|
||||
DECLARE_SETTER_AND_GETTER(Aarch64Features, bti)
|
||||
|
||||
static const CapabilityConfig kConfigs[] = {
|
||||
// clang-format off
|
||||
[AARCH64_FP] = {{AARCH64_HWCAP_FP, 0}, "fp", &set_fp, &get_fp},
|
||||
[AARCH64_ASIMD] = {{AARCH64_HWCAP_ASIMD, 0}, "asimd", &set_asimd, &get_asimd},
|
||||
[AARCH64_EVTSTRM] = {{AARCH64_HWCAP_EVTSTRM, 0}, "evtstrm", &set_evtstrm, &get_evtstrm},
|
||||
@ -125,6 +126,7 @@ static const CapabilityConfig kConfigs[] = {
|
||||
[AARCH64_DGH] = {{0, AARCH64_HWCAP2_DGH}, "dgh", &set_dgh, &get_dgh},
|
||||
[AARCH64_RNG] = {{0, AARCH64_HWCAP2_RNG}, "rng", &set_rng, &get_rng},
|
||||
[AARCH64_BTI] = {{0, AARCH64_HWCAP2_BTI}, "bti", &set_bti, &get_bti},
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static const size_t kConfigsSize = sizeof(kConfigs) / sizeof(CapabilityConfig);
|
||||
@ -186,13 +188,11 @@ Aarch64Info GetAarch64Info(void) {
|
||||
|
||||
int GetAarch64FeaturesEnumValue(const Aarch64Features* features,
|
||||
Aarch64FeaturesEnum value) {
|
||||
if(value >= kConfigsSize)
|
||||
return false;
|
||||
if (value >= kConfigsSize) return false;
|
||||
return kConfigs[value].get_bit((Aarch64Features*)features);
|
||||
}
|
||||
|
||||
const char* GetAarch64FeaturesEnumName(Aarch64FeaturesEnum value) {
|
||||
if(value >= kConfigsSize)
|
||||
return "unknown feature";
|
||||
if (value >= kConfigsSize) return "unknown feature";
|
||||
return kConfigs[value].proc_cpuinfo_flag;
|
||||
}
|
||||
|
@ -14,6 +14,9 @@
|
||||
|
||||
#include "cpuinfo_arm.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "internal/bit_utils.h"
|
||||
#include "internal/filesystem.h"
|
||||
#include "internal/hwcaps.h"
|
||||
@ -21,9 +24,6 @@
|
||||
#include "internal/string_view.h"
|
||||
#include "internal/unix_features_aggregator.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
||||
DECLARE_SETTER_AND_GETTER(ArmFeatures, swp)
|
||||
DECLARE_SETTER_AND_GETTER(ArmFeatures, half)
|
||||
DECLARE_SETTER_AND_GETTER(ArmFeatures, thumb)
|
||||
@ -53,33 +53,35 @@ DECLARE_SETTER_AND_GETTER(ArmFeatures, sha2)
|
||||
DECLARE_SETTER_AND_GETTER(ArmFeatures, crc32)
|
||||
|
||||
static const CapabilityConfig kConfigs[] = {
|
||||
[ARM_SWP] = {{ARM_HWCAP_SWP, 0}, "swp", &set_swp, &get_swp}, //
|
||||
[ARM_HALF] = {{ARM_HWCAP_HALF, 0}, "half", &set_half, &get_half}, //
|
||||
[ARM_THUMB] = {{ARM_HWCAP_THUMB, 0}, "thumb", &set_thumb, &get_thumb}, //
|
||||
[ARM_26BIT] = {{ARM_HWCAP_26BIT, 0}, "26bit", &set__26bit, &get__26bit}, //
|
||||
[ARM_FASTMULT] = {{ARM_HWCAP_FAST_MULT, 0}, "fastmult", &set_fastmult, &get_fastmult}, //
|
||||
[ARM_FPA] = {{ARM_HWCAP_FPA, 0}, "fpa", &set_fpa, &get_fpa}, //
|
||||
[ARM_VFP] = {{ARM_HWCAP_VFP, 0}, "vfp", &set_vfp, &get_vfp}, //
|
||||
[ARM_EDSP] = {{ARM_HWCAP_EDSP, 0}, "edsp", &set_edsp, &get_edsp}, //
|
||||
[ARM_JAVA] = {{ARM_HWCAP_JAVA, 0}, "java", &set_java, &get_java}, //
|
||||
[ARM_IWMMXT] = {{ARM_HWCAP_IWMMXT, 0}, "iwmmxt", &set_iwmmxt, &get_iwmmxt}, //
|
||||
[ARM_CRUNCH] = {{ARM_HWCAP_CRUNCH, 0}, "crunch", &set_crunch, &get_crunch}, //
|
||||
[ARM_THUMBEE] = {{ARM_HWCAP_THUMBEE, 0}, "thumbee", &set_thumbee, &get_thumbee}, //
|
||||
[ARM_NEON] = {{ARM_HWCAP_NEON, 0}, "neon", &set_neon, &get_neon}, //
|
||||
[ARM_VFPV3] = {{ARM_HWCAP_VFPV3, 0}, "vfpv3", &set_vfpv3, &get_vfpv3}, //
|
||||
[ARM_VFPV3D16] = {{ARM_HWCAP_VFPV3D16, 0}, "vfpv3d16", &set_vfpv3d16, &get_vfpv3d16}, //
|
||||
[ARM_TLS] = {{ARM_HWCAP_TLS, 0}, "tls", &set_tls, &get_tls}, //
|
||||
[ARM_VFPV4] = {{ARM_HWCAP_VFPV4, 0}, "vfpv4", &set_vfpv4, &get_vfpv4}, //
|
||||
[ARM_IDIVA] = {{ARM_HWCAP_IDIVA, 0}, "idiva", &set_idiva, &get_idiva}, //
|
||||
[ARM_IDIVT] = {{ARM_HWCAP_IDIVT, 0}, "idivt", &set_idivt, &get_idivt}, //
|
||||
[ARM_VFPD32] = {{ARM_HWCAP_VFPD32, 0}, "vfpd32", &set_vfpd32, &get_vfpd32}, //
|
||||
[ARM_LPAE] = {{ARM_HWCAP_LPAE, 0}, "lpae", &set_lpae, &get_lpae}, //
|
||||
[ARM_EVTSTRM] = {{ARM_HWCAP_EVTSTRM, 0}, "evtstrm", &set_evtstrm, &get_evtstrm}, //
|
||||
[ARM_AES] = {{0, ARM_HWCAP2_AES}, "aes", &set_aes, &get_aes}, //
|
||||
[ARM_PMULL] = {{0, ARM_HWCAP2_PMULL}, "pmull", &set_pmull, &get_pmull}, //
|
||||
[ARM_SHA1] = {{0, ARM_HWCAP2_SHA1}, "sha1", &set_sha1, &get_sha1}, //
|
||||
[ARM_SHA2] = {{0, ARM_HWCAP2_SHA2}, "sha2", &set_sha2, &get_sha2}, //
|
||||
[ARM_CRC32] = {{0, ARM_HWCAP2_CRC32}, "crc32", &set_crc32, &get_crc32}, //
|
||||
// clang-format off
|
||||
[ARM_SWP] = {{ARM_HWCAP_SWP, 0}, "swp", &set_swp, &get_swp},
|
||||
[ARM_HALF] = {{ARM_HWCAP_HALF, 0}, "half", &set_half, &get_half},
|
||||
[ARM_THUMB] = {{ARM_HWCAP_THUMB, 0}, "thumb", &set_thumb, &get_thumb},
|
||||
[ARM_26BIT] = {{ARM_HWCAP_26BIT, 0}, "26bit", &set__26bit, &get__26bit},
|
||||
[ARM_FASTMULT] = {{ARM_HWCAP_FAST_MULT, 0}, "fastmult", &set_fastmult, &get_fastmult},
|
||||
[ARM_FPA] = {{ARM_HWCAP_FPA, 0}, "fpa", &set_fpa, &get_fpa},
|
||||
[ARM_VFP] = {{ARM_HWCAP_VFP, 0}, "vfp", &set_vfp, &get_vfp},
|
||||
[ARM_EDSP] = {{ARM_HWCAP_EDSP, 0}, "edsp", &set_edsp, &get_edsp},
|
||||
[ARM_JAVA] = {{ARM_HWCAP_JAVA, 0}, "java", &set_java, &get_java},
|
||||
[ARM_IWMMXT] = {{ARM_HWCAP_IWMMXT, 0}, "iwmmxt", &set_iwmmxt, &get_iwmmxt},
|
||||
[ARM_CRUNCH] = {{ARM_HWCAP_CRUNCH, 0}, "crunch", &set_crunch, &get_crunch},
|
||||
[ARM_THUMBEE] = {{ARM_HWCAP_THUMBEE, 0}, "thumbee", &set_thumbee, &get_thumbee},
|
||||
[ARM_NEON] = {{ARM_HWCAP_NEON, 0}, "neon", &set_neon, &get_neon},
|
||||
[ARM_VFPV3] = {{ARM_HWCAP_VFPV3, 0}, "vfpv3", &set_vfpv3, &get_vfpv3},
|
||||
[ARM_VFPV3D16] = {{ARM_HWCAP_VFPV3D16, 0}, "vfpv3d16", &set_vfpv3d16, &get_vfpv3d16},
|
||||
[ARM_TLS] = {{ARM_HWCAP_TLS, 0}, "tls", &set_tls, &get_tls},
|
||||
[ARM_VFPV4] = {{ARM_HWCAP_VFPV4, 0}, "vfpv4", &set_vfpv4, &get_vfpv4},
|
||||
[ARM_IDIVA] = {{ARM_HWCAP_IDIVA, 0}, "idiva", &set_idiva, &get_idiva},
|
||||
[ARM_IDIVT] = {{ARM_HWCAP_IDIVT, 0}, "idivt", &set_idivt, &get_idivt},
|
||||
[ARM_VFPD32] = {{ARM_HWCAP_VFPD32, 0}, "vfpd32", &set_vfpd32, &get_vfpd32},
|
||||
[ARM_LPAE] = {{ARM_HWCAP_LPAE, 0}, "lpae", &set_lpae, &get_lpae},
|
||||
[ARM_EVTSTRM] = {{ARM_HWCAP_EVTSTRM, 0}, "evtstrm", &set_evtstrm, &get_evtstrm},
|
||||
[ARM_AES] = {{0, ARM_HWCAP2_AES}, "aes", &set_aes, &get_aes},
|
||||
[ARM_PMULL] = {{0, ARM_HWCAP2_PMULL}, "pmull", &set_pmull, &get_pmull},
|
||||
[ARM_SHA1] = {{0, ARM_HWCAP2_SHA1}, "sha1", &set_sha1, &get_sha1},
|
||||
[ARM_SHA2] = {{0, ARM_HWCAP2_SHA2}, "sha2", &set_sha2, &get_sha2},
|
||||
[ARM_CRC32] = {{0, ARM_HWCAP2_CRC32}, "crc32", &set_crc32, &get_crc32},
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static const size_t kConfigsSize = sizeof(kConfigs) / sizeof(CapabilityConfig);
|
||||
@ -119,8 +121,8 @@ static bool HandleArmLine(const LineResult result, ArmInfo* const info,
|
||||
const StringView digits =
|
||||
CpuFeatures_StringView_KeepFront(value, IndexOfNonDigit(value));
|
||||
info->architecture = CpuFeatures_StringView_ParsePositiveNumber(digits);
|
||||
} else if (CpuFeatures_StringView_IsEquals(key, str("Processor"))
|
||||
|| CpuFeatures_StringView_IsEquals(key, str("model name")) ) {
|
||||
} else if (CpuFeatures_StringView_IsEquals(key, str("Processor")) ||
|
||||
CpuFeatures_StringView_IsEquals(key, str("model name"))) {
|
||||
// Android reports this in a non-Linux standard "Processor" but sometimes
|
||||
// also in "model name", Linux reports it only in "model name"
|
||||
// see RaspberryPiZero (Linux) vs InvalidArmv7 (Android) test-cases
|
||||
@ -224,13 +226,11 @@ ArmInfo GetArmInfo(void) {
|
||||
|
||||
int GetArmFeaturesEnumValue(const ArmFeatures* features,
|
||||
ArmFeaturesEnum value) {
|
||||
if(value >= kConfigsSize)
|
||||
return false;
|
||||
if (value >= kConfigsSize) return false;
|
||||
return kConfigs[value].get_bit((ArmFeatures*)features);
|
||||
}
|
||||
|
||||
const char* GetArmFeaturesEnumName(ArmFeaturesEnum value) {
|
||||
if(value >= kConfigsSize)
|
||||
return "unknown feature";
|
||||
if (value >= kConfigsSize) return "unknown feature";
|
||||
return kConfigs[value].proc_cpuinfo_flag;
|
||||
}
|
||||
|
@ -14,21 +14,21 @@
|
||||
|
||||
#include "cpuinfo_mips.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "internal/filesystem.h"
|
||||
#include "internal/stack_line_reader.h"
|
||||
#include "internal/string_view.h"
|
||||
#include "internal/unix_features_aggregator.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
DECLARE_SETTER_AND_GETTER(MipsFeatures, msa)
|
||||
DECLARE_SETTER_AND_GETTER(MipsFeatures, eva)
|
||||
DECLARE_SETTER_AND_GETTER(MipsFeatures, r6)
|
||||
|
||||
static const CapabilityConfig kConfigs[] = {
|
||||
[MIPS_MSA] = {{MIPS_HWCAP_MSA, 0}, "msa", &set_msa, &get_msa}, //
|
||||
[MIPS_EVA] = {{0, 0}, "eva", &set_eva, &get_eva}, //
|
||||
[MIPS_R6] = {{MIPS_HWCAP_R6, 0}, "r6", &set_r6, &get_r6}, //
|
||||
[MIPS_MSA] = {{MIPS_HWCAP_MSA, 0}, "msa", &set_msa, &get_msa},
|
||||
[MIPS_EVA] = {{0, 0}, "eva", &set_eva, &get_eva},
|
||||
[MIPS_R6] = {{MIPS_HWCAP_R6, 0}, "r6", &set_r6, &get_r6},
|
||||
};
|
||||
static const size_t kConfigsSize = sizeof(kConfigs) / sizeof(CapabilityConfig);
|
||||
|
||||
@ -80,13 +80,11 @@ MipsInfo GetMipsInfo(void) {
|
||||
|
||||
int GetMipsFeaturesEnumValue(const MipsFeatures* features,
|
||||
MipsFeaturesEnum value) {
|
||||
if(value >= kConfigsSize)
|
||||
return false;
|
||||
if (value >= kConfigsSize) return false;
|
||||
return kConfigs[value].get_bit((MipsFeatures*)features);
|
||||
}
|
||||
|
||||
const char* GetMipsFeaturesEnumName(MipsFeaturesEnum value) {
|
||||
if(value >= kConfigsSize)
|
||||
return "unknown feature";
|
||||
if (value >= kConfigsSize) return "unknown feature";
|
||||
return kConfigs[value].proc_cpuinfo_flag;
|
||||
}
|
||||
|
@ -12,11 +12,12 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "cpuinfo_ppc.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "cpuinfo_ppc.h"
|
||||
#include "internal/bit_utils.h"
|
||||
#include "internal/filesystem.h"
|
||||
#include "internal/stack_line_reader.h"
|
||||
@ -66,6 +67,7 @@ DECLARE_SETTER_AND_GETTER(PPCFeatures, scv)
|
||||
DECLARE_SETTER_AND_GETTER(PPCFeatures, htm_no_suspend)
|
||||
|
||||
static const CapabilityConfig kConfigs[] = {
|
||||
// clang-format off
|
||||
[PPC_32] = {{PPC_FEATURE_32, 0}, "ppc32", &set_ppc32, &get_ppc32},
|
||||
[PPC_64] = {{PPC_FEATURE_64, 0}, "ppc64", &set_ppc64, &get_ppc64},
|
||||
[PPC_601_INSTR] = {{PPC_FEATURE_601_INSTR, 0}, "ppc601", &set_ppc601, &get_ppc601},
|
||||
@ -91,8 +93,7 @@ static const CapabilityConfig kConfigs[] = {
|
||||
[PPC_POWER6_EXT] = {{PPC_FEATURE_POWER6_EXT, 0}, "power6x", &set_power6ext, &get_power6ext},
|
||||
[PPC_ARCH_2_06] = {{PPC_FEATURE_ARCH_2_06, 0}, "arch_2_06", &set_arch206, &get_arch206},
|
||||
[PPC_HAS_VSX] = {{PPC_FEATURE_HAS_VSX, 0}, "vsx", &set_vsx, &get_vsx},
|
||||
[PPC_PSERIES_PERFMON_COMPAT] = {{PPC_FEATURE_PSERIES_PERFMON_COMPAT, 0}, "archpmu",
|
||||
&set_pseries_perfmon_compat, &get_pseries_perfmon_compat},
|
||||
[PPC_PSERIES_PERFMON_COMPAT] = {{PPC_FEATURE_PSERIES_PERFMON_COMPAT, 0}, "archpmu", &set_pseries_perfmon_compat, &get_pseries_perfmon_compat},
|
||||
[PPC_TRUE_LE] = {{PPC_FEATURE_TRUE_LE, 0}, "true_le", &set_truele, &get_truele},
|
||||
[PPC_PPC_LE] = {{PPC_FEATURE_PPC_LE, 0}, "ppcle", &set_ppcle, &get_ppcle},
|
||||
[PPC_ARCH_2_07] = {{0, PPC_FEATURE2_ARCH_2_07}, "arch_2_07", &set_arch207, &get_arch207},
|
||||
@ -107,8 +108,8 @@ static const CapabilityConfig kConfigs[] = {
|
||||
[PPC_HAS_IEEE128] = {{0, PPC_FEATURE2_HAS_IEEE128}, "ieee128", &set_ieee128, &get_ieee128},
|
||||
[PPC_DARN] = {{0, PPC_FEATURE2_DARN}, "darn", &set_darn, &get_darn},
|
||||
[PPC_SCV] = {{0, PPC_FEATURE2_SCV}, "scv", &set_scv, &get_scv},
|
||||
[PPC_HTM_NO_SUSPEND] = {{0, PPC_FEATURE2_HTM_NO_SUSPEND}, "htm-no-suspend", &set_htm_no_suspend,
|
||||
&get_htm_no_suspend},
|
||||
[PPC_HTM_NO_SUSPEND] = {{0, PPC_FEATURE2_HTM_NO_SUSPEND}, "htm-no-suspend", &set_htm_no_suspend, &get_htm_no_suspend},
|
||||
// clang-format on
|
||||
};
|
||||
static const size_t kConfigsSize = sizeof(kConfigs) / sizeof(CapabilityConfig);
|
||||
|
||||
@ -178,13 +179,11 @@ PPCPlatformStrings GetPPCPlatformStrings(void) {
|
||||
|
||||
int GetPPCFeaturesEnumValue(const PPCFeatures* features,
|
||||
PPCFeaturesEnum value) {
|
||||
if(value >= kConfigsSize)
|
||||
return false;
|
||||
if (value >= kConfigsSize) return false;
|
||||
return kConfigs[value].get_bit((PPCFeatures*)features);
|
||||
}
|
||||
|
||||
const char* GetPPCFeaturesEnumName(PPCFeaturesEnum value) {
|
||||
if(value >= kConfigsSize)
|
||||
return "unknown feature";
|
||||
if (value >= kConfigsSize) return "unknown feature";
|
||||
return kConfigs[value].proc_cpuinfo_flag;
|
||||
}
|
||||
|
@ -12,12 +12,13 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "internal/hwcaps.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "cpu_features_macros.h"
|
||||
#include "internal/filesystem.h"
|
||||
#include "internal/hwcaps.h"
|
||||
#include "internal/string_view.h"
|
||||
|
||||
#if defined(NDEBUG)
|
||||
|
@ -13,12 +13,13 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include "internal/stack_line_reader.h"
|
||||
#include "internal/filesystem.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "internal/filesystem.h"
|
||||
|
||||
void StackLineReader_Initialize(StackLineReader* reader, int fd) {
|
||||
reader->view.ptr = reader->buffer;
|
||||
reader->view.size = 0;
|
||||
|
@ -13,6 +13,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include "internal/unix_features_aggregator.h"
|
||||
|
||||
#include "internal/string_view.h"
|
||||
|
||||
void CpuFeatures_SetFromFlags(const size_t configs_size,
|
||||
|
@ -13,10 +13,10 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include "cpuinfo_aarch64.h"
|
||||
#include "filesystem_for_testing.h"
|
||||
#include "hwcaps_for_testing.h"
|
||||
|
||||
#include "filesystem_for_testing.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "hwcaps_for_testing.h"
|
||||
|
||||
namespace cpu_features {
|
||||
namespace {
|
||||
@ -62,7 +62,8 @@ TEST(CpuinfoAarch64Test, FromHardwareCap) {
|
||||
}
|
||||
|
||||
TEST(CpuinfoAarch64Test, FromHardwareCap2) {
|
||||
SetHardwareCapabilities(AARCH64_HWCAP_FP, AARCH64_HWCAP2_SVE2 | AARCH64_HWCAP2_BTI);
|
||||
SetHardwareCapabilities(AARCH64_HWCAP_FP,
|
||||
AARCH64_HWCAP2_SVE2 | AARCH64_HWCAP2_BTI);
|
||||
GetEmptyFilesystem(); // disabling /proc/cpuinfo
|
||||
const auto info = GetAarch64Info();
|
||||
EXPECT_TRUE(info.features.fp);
|
||||
|
@ -13,10 +13,10 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include "cpuinfo_arm.h"
|
||||
#include "filesystem_for_testing.h"
|
||||
#include "hwcaps_for_testing.h"
|
||||
|
||||
#include "filesystem_for_testing.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "hwcaps_for_testing.h"
|
||||
|
||||
namespace cpu_features {
|
||||
namespace {
|
||||
|
@ -13,13 +13,13 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include "cpuinfo_mips.h"
|
||||
|
||||
#include "filesystem_for_testing.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "hwcaps_for_testing.h"
|
||||
#include "internal/stack_line_reader.h"
|
||||
#include "internal/string_view.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace cpu_features {
|
||||
|
||||
namespace {
|
||||
|
@ -13,12 +13,12 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include "cpuinfo_ppc.h"
|
||||
|
||||
#include "filesystem_for_testing.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "hwcaps_for_testing.h"
|
||||
#include "internal/string_view.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace cpu_features {
|
||||
namespace {
|
||||
|
||||
|
@ -12,13 +12,13 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "cpuinfo_x86.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <map>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "cpuinfo_x86.h"
|
||||
#include "internal/cpuid_x86.h"
|
||||
|
||||
namespace cpu_features {
|
||||
|
@ -12,9 +12,10 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "hwcaps_for_testing.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "hwcaps_for_testing.h"
|
||||
#include "internal/string_view.h"
|
||||
|
||||
namespace cpu_features {
|
||||
|
@ -13,8 +13,8 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include "internal/stack_line_reader.h"
|
||||
#include "filesystem_for_testing.h"
|
||||
|
||||
#include "filesystem_for_testing.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace cpu_features {
|
||||
|
@ -12,10 +12,10 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "internal/unix_features_aggregator.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace cpu_features {
|
||||
@ -28,11 +28,7 @@ struct Features {
|
||||
bool c = false;
|
||||
};
|
||||
|
||||
enum eFeatures {
|
||||
TEST_a,
|
||||
TEST_b,
|
||||
TEST_c
|
||||
};
|
||||
enum eFeatures { TEST_a, TEST_b, TEST_c };
|
||||
|
||||
DECLARE_SETTER_AND_GETTER(Features, a)
|
||||
DECLARE_SETTER_AND_GETTER(Features, b)
|
||||
@ -40,11 +36,10 @@ DECLARE_SETTER_AND_GETTER(Features, c)
|
||||
|
||||
class LinuxFeatureAggregatorTest : public testing::Test {
|
||||
public:
|
||||
const std::array<CapabilityConfig, 3> kConfigs = {{
|
||||
{{0b0001, 0b0000}, "a", &set_a, &get_a},
|
||||
const std::array<CapabilityConfig, 3> kConfigs = {
|
||||
{{{0b0001, 0b0000}, "a", &set_a, &get_a},
|
||||
{{0b0010, 0b0000}, "b", &set_b, &get_b},
|
||||
{{0b0000, 0b1100}, "c", &set_c, &get_c}
|
||||
}};
|
||||
{{0b0000, 0b1100}, "c", &set_c, &get_c}}};
|
||||
};
|
||||
|
||||
TEST_F(LinuxFeatureAggregatorTest, FromFlagsEmpty) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user