11#include <botan/types.h>
12#include <botan/internal/target_info.h>
16#if defined(BOTAN_HAS_CPUID_DETECTION)
17 #include <botan/internal/cpuid_features.h>
22#if !defined(BOTAN_HAS_CPUID_DETECTION)
26 enum Bit : uint32_t {};
28 uint32_t as_u32()
const;
32 static std::optional<CPUFeature> from_string(std::string_view);
68 if(state().has_bit(feat.
as_u32())) {
100 return state().has_bit(feat1.
as_u32() | feat2.
as_u32());
111 static std::optional<CPUID::Feature> bit_from_string(std::string_view tok);
116 template <
typename T>
118 const uint64_t flag64 =
static_cast<uint64_t
>(flag);
119 if((cpuid & flag64) == flag64) {
120 return (bit.
as_u32() & allowed);
131 CPUID_Data(
const CPUID_Data& other) =
default;
132 CPUID_Data& operator=(
const CPUID_Data& other) =
default;
134 void clear_cpuid_bit(uint32_t bit) { m_processor_features &= ~bit; }
136 bool has_bit(uint32_t bit)
const {
return (m_processor_features & bit) == bit; }
138 uint32_t bitset()
const {
return m_processor_features; }
141#if defined(BOTAN_HAS_CPUID_DETECTION)
142 static uint32_t detect_cpu_features(uint32_t allowed_bits);
145 uint32_t m_processor_features;
148 static CPUID_Data& state() {
149 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.