Botan 3.9.0
Crypto and TLS for C&
cpuid_features.cpp
Go to the documentation of this file.
1/**
2* (C) 2025 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#include <botan/internal/cpuid_features.h>
8
9#include <botan/exceptn.h>
10
11namespace Botan {
12
13std::string CPUFeature::to_string() const {
14 switch(m_bit) {
15 case CPUFeature::Bit::ALTIVEC:
16 return "altivec";
17 case CPUFeature::Bit::POWER_CRYPTO:
18 return "power_crypto";
19 case CPUFeature::Bit::DARN:
20 return "darn";
21 }
22 throw Invalid_State("CPUFeature invalid bit");
23}
24
25//static
26std::optional<CPUFeature> CPUFeature::from_string(std::string_view tok) {
27 if(tok == "altivec" || tok == "simd") {
28 return CPUFeature::Bit::ALTIVEC;
29 } else if(tok == "power_crypto") {
30 return CPUFeature::Bit::POWER_CRYPTO;
31 } else if(tok == "darn" || tok == "darn_rng") {
32 // TODO(Botan4) remove "darn_rng"
33 return CPUFeature::Bit::DARN;
34 } else {
35 return {};
36 }
37}
38
39} // namespace Botan
static std::optional< CPUFeature > from_string(std::string_view)
Definition cpuid.cpp:24
std::string to_string() const
Definition cpuid.cpp:28