Botan 1.10.17

Static Public Member Functions | List of all members
Botan::CPUID Class Reference

`#include <cpuid.h>`

## Static Public Member Functions
static size_t | cache_line_size ()
static bool | has_aes_ni ()
static bool | has_altivec ()
static bool | has_avx ()
static bool | has_movbe ()
static bool | has_pcmuludq ()
static bool | has_rdrand ()
static bool | has_rdtsc ()
static bool | has_sse2 ()
static bool | has_sse41 ()
static bool | has_sse42 ()
static bool | has_ssse3 ()
static void | initialize ()

## Detailed Description

A class handling runtime CPU feature detection

Definition at line 18 of file cpuid.h.

## Member Function Documentation

## ◆ cache_line_size()

static size_t Botan::CPUID::cache_line_size | ( |  | ) |
| inline static

Return a best guess of the cache line size

Definition at line 29 of file cpuid.h.

Referenced by Botan::prefetch_readonly(), and Botan::prefetch_readwrite().

29 { return cache_line; }

## ◆ has_aes_ni()

static bool Botan::CPUID::has_aes_ni | ( |  | ) |
| inline static

Check if the processor supports AES-NI

Definition at line 70 of file cpuid.h.

Referenced by Botan::AES_ISA_Engine::find_block_cipher().

71 { return x86_processor_flags_has(CPUID_AESNI_BIT); }

## ◆ has_altivec()

static bool Botan::CPUID::has_altivec | ( |  | ) |
| inline static

Check if the processor supports AltiVec/VMX

Definition at line 94 of file cpuid.h.

94 { return altivec_capable; }

## ◆ has_avx()

static bool Botan::CPUID::has_avx | ( |  | ) |
| inline static

Check if the processor supports extended AVX vector instructions

Definition at line 64 of file cpuid.h.

65 { return x86_processor_flags_has(CPUID_AVX_BIT); }

## ◆ has_movbe()

static bool Botan::CPUID::has_movbe | ( |  | ) |
| inline static

Check if the processor supports MOVBE

Definition at line 82 of file cpuid.h.

83 { return x86_processor_flags_has(CPUID_MOVBE_BIT); }

## ◆ has_pcmuludq()

static bool Botan::CPUID::has_pcmuludq | ( |  | ) |
| inline static

Check if the processor supports PCMULUDQ

Definition at line 76 of file cpuid.h.

77 { return x86_processor_flags_has(CPUID_PCMUL_BIT); }

## ◆ has_rdrand()

static bool Botan::CPUID::has_rdrand | ( |  | ) |
| inline static

Check if the processor supports RDRAND

Definition at line 88 of file cpuid.h.

Referenced by Botan::Intel_Rdrand::poll().

89 { return x86_processor_flags_has(CPUID_RDRAND_BIT); }

## ◆ has_rdtsc()

static bool Botan::CPUID::has_rdtsc | ( |  | ) |
| inline static

Check if the processor supports RDTSC

Definition at line 34 of file cpuid.h.

Referenced by Botan::High_Resolution_Timestamp::poll().

35 { return x86_processor_flags_has(CPUID_RDTSC_BIT); }

## ◆ has_sse2()

static bool Botan::CPUID::has_sse2 | ( |  | ) |
| inline static

Check if the processor supports SSE2

Definition at line 40 of file cpuid.h.

Referenced by Botan::SIMD_Engine::find_block_cipher(), and Botan::SIMD_Engine::find_hash().

41 { return x86_processor_flags_has(CPUID_SSE2_BIT); }

## ◆ has_sse41()

static bool Botan::CPUID::has_sse41 | ( |  | ) |
| inline static

Check if the processor supports SSE4.1

Definition at line 52 of file cpuid.h.

53 { return x86_processor_flags_has(CPUID_SSE41_BIT); }

## ◆ has_sse42()

static bool Botan::CPUID::has_sse42 | ( |  | ) |
| inline static

Check if the processor supports SSE4.2

Definition at line 58 of file cpuid.h.

59 { return x86_processor_flags_has(CPUID_SSE42_BIT); }

## ◆ has_ssse3()

static bool Botan::CPUID::has_ssse3 | ( |  | ) |
| inline static

Check if the processor supports SSSE3

Definition at line 46 of file cpuid.h.

Referenced by Botan::SIMD_Engine::find_block_cipher().

47 { return x86_processor_flags_has(CPUID_SSSE3_BIT); }

## ◆ initialize()

void Botan::CPUID::initialize | ( |  | ) |
| static

Probe the CPU and see what extensions are supported

Definition at line 196 of file cpuid.cpp.

References CALL_CPUID.

Referenced by Botan::Library_State::initialize().

197 {
198 u32bit cpuid[4] = { 0 };
199 CALL_CPUID(1, cpuid);
200
201 x86_processor_flags = (static_cast<u64bit>(cpuid[2]) << 32) | cpuid[3];
202
203 #if defined(BOTAN_TARGET_ARCH_IS_X86_64)
204 /*
205 * If we don't have access to CPUID, we can still safely assume that
206 * any x86-64 processor has SSE2.
207 */
208 if(x86_processor_flags == 0)
209 x86_processor_flags |= (1 << CPUID_SSE2_BIT);
210 #endif
211
212 cache_line = get_x86_cache_line_size();
213
214 altivec_capable = false;
215
216 #if defined(BOTAN_TARGET_CPU_IS_PPC_FAMILY)
217 if(altivec_check_sysctl() || altivec_check_pvr_emul())
218 altivec_capable = true;
219 #endif
220 }
Botan::u64bit
unsigned long long u64bit
Definition: types.h:49
CALL_CPUID
#define CALL_CPUID(type, out)
Definition: cpuid.cpp:81
Botan::u32bit
unsigned int u32bit
Definition: types.h:32

The documentation for this class was generated from the following files:

- src/utils/cpuid.h
- src/utils/cpuid.cpp