8#include <botan/internal/cpuid.h>
10#include <botan/exceptn.h>
11#include <botan/internal/parsing.h>
13#if defined(BOTAN_HAS_OS_UTILS)
14 #include <botan/internal/os_utils.h>
19#if !defined(BOTAN_HAS_CPUID_DETECTION)
35 std::vector<std::string> flags;
37 const uint32_t bitset = state().bitset();
39 for(
size_t i = 0; i != 32; ++i) {
40 const uint32_t b =
static_cast<uint32_t
>(1) << i;
41 if((bitset & b) == b) {
51 state() = CPUID_Data();
54#if defined(BOTAN_HAS_CPUID_DETECTION)
58uint32_t cleared_cpuid_bits() {
61 #if defined(BOTAN_HAS_OS_UTILS)
62 std::string clear_cpuid_env;
64 for(
const auto& cpuid :
split_on(clear_cpuid_env,
',')) {
66 cleared |= bit->as_u32();
79CPUID::CPUID_Data::CPUID_Data() {
80#if defined(BOTAN_HAS_CPUID_DETECTION)
81 m_processor_features = detect_cpu_features(~cleared_cpuid_bits());
83 m_processor_features = 0;
static std::optional< CPUFeature > from_string(std::string_view)
std::string to_string() const
static std::optional< CPUID::Feature > bit_from_string(std::string_view tok)
static std::string to_string()
bool read_env_variable(std::string &value_out, std::string_view var_name)
std::vector< std::string > split_on(std::string_view str, char delim)
std::string string_join(const std::vector< std::string > &strs, char delim)