Botan 3.14.1
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::VSX:
16 return "vsx";
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 == "vsx" || tok == "simd" || tok == "altivec") {
28 // TODO(Botan4) remove "altivec"
29 return CPUFeature::Bit::VSX;
30 } else if(tok == "power_crypto") {
31 return CPUFeature::Bit::POWER_CRYPTO;
32 } else if(tok == "darn" || tok == "darn_rng") {
33 // TODO(Botan4) remove "darn_rng"
34 return CPUFeature::Bit::DARN;
35 } else {
36 return {};
37 }
38}
39
40} // namespace Botan
static std::optional< CPUFeature > from_string(std::string_view)
Definition cpuid.cpp:24
std::string to_string() const
Definition cpuid.cpp:28