11#include <botan/types.h>
15#if defined(BOTAN_HAS_CPUID_DETECTION)
16 #include <botan/internal/cpuid_features.h>
21#if !defined(BOTAN_HAS_CPUID_DETECTION)
25 enum Bit : uint32_t {};
27 uint32_t as_u32()
const;
31 static std::optional<CPUFeature> from_string(std::string_view);
67 if(state().has_bit(feat.
as_u32())) {
110 static std::optional<CPUID::Feature> bit_from_string(std::string_view tok);
115 template <
typename T>
117 const uint64_t flag64 =
static_cast<uint64_t
>(flag);
118 if((cpuid & flag64) == flag64) {
119 return (bit.
as_u32() & allowed);
127 const uint32_t feat_bit = bit.
as_u32();
128 return ((allowed & feat_bit) == feat_bit);
135 CPUID_Data(
const CPUID_Data& other) =
default;
136 CPUID_Data(CPUID_Data&& other) =
default;
137 CPUID_Data& operator=(
const CPUID_Data& other) =
default;
138 CPUID_Data& operator=(CPUID_Data&& other) =
default;
139 ~CPUID_Data() =
default;
141 void clear_cpuid_bit(uint32_t bit) { m_processor_features &= ~bit; }
143 bool has_bit(uint32_t bit)
const {
return (m_processor_features & bit) == bit; }
145 uint32_t bitset()
const {
return m_processor_features; }
148#if defined(BOTAN_HAS_CPUID_DETECTION)
149 static uint32_t detect_cpu_features(uint32_t allowed_bits);
152 uint32_t m_processor_features;
155 static CPUID_Data& state() {
156 static CPUID::CPUID_Data g_cpuid;
std::string to_string() const
static std::optional< std::string > check(CPUID::Feature feat)
static bool has(CPUID::Feature feat1, CPUID::Feature feat2)
static uint32_t if_set(uint64_t cpuid, T flag, CPUID::Feature bit, uint32_t allowed)
static void clear_cpuid_bit(CPUID::Feature bit)
static std::string to_string()
static std::optional< std::string > check(CPUID::Feature feat1, CPUID::Feature feat2)
static bool has(CPUID::Feature feat)
std::string to_string(ErrorType type)
Convert an ErrorType to string.