1
0
mirror of https://github.com/google/cpu_features.git synced 2025-07-01 05:11:15 +02:00

Use a getter function to avoid manual work for future to-be-added cpu features

This commit is contained in:
Patrick Siegl
2019-12-14 11:58:36 +00:00
committed by Guillaume Chatelet
parent 73a121b1ae
commit 3d71a964f5
7 changed files with 260 additions and 442 deletions

View File

@ -33,11 +33,23 @@ CPU_FEATURES_START_CPP_NAMESPACE
((FeatureType*)features)->FeatureName = value; \
}
// Use the following macro to declare getter functions to be used in
// CapabilityConfig.
#define DECLARE_GETTER(FeatureType, FeatureName) \
static int get_##FeatureName(void* const features) { \
return ((FeatureType*)features)->FeatureName; \
}
#define DECLARE_SETTER_AND_GETTER(FeatureType, FeatureName) \
DECLARE_SETTER(FeatureType, FeatureName) \
DECLARE_GETTER(FeatureType, FeatureName)
// Describes the relationship between hardware caps and /proc/cpuinfo flags.
typedef struct {
const HardwareCapabilities hwcaps_mask;
const char* const proc_cpuinfo_flag;
void (*set_bit)(void* const, bool); // setter for the corresponding bit.
int (*get_bit)(void* const); // getter for the corresponding bit.
} CapabilityConfig;
// For every config, looks into flags_line for the presence of the