Crypto++
8.3
Free C++ class library of cryptographic schemes
|
Functions for CPU features and intrinsics. More...
Go to the source code of this file.
Macros | |
#define | NEW_LINE |
#define | INTEL_PREFIX |
#define | INTEL_NOPREFIX |
#define | ATT_PREFIX |
#define | ATT_NOPREFIX |
#define | CRYPTOPP_CPUID_AVAILABLE 1 |
Functions | |
IA-32 CPU FEATURES | |
bool | HasSSE2 () |
Determine SSE2 availability. More... | |
bool | HasSSSE3 () |
Determine SSSE3 availability. More... | |
bool | HasSSE41 () |
Determine SSE4.1 availability. More... | |
bool | HasSSE42 () |
Determine SSE4.2 availability. More... | |
bool | HasMOVBE () |
Determine MOVBE availability. More... | |
bool | HasAESNI () |
Determine AES-NI availability. More... | |
bool | HasCLMUL () |
Determine Carryless Multiply availability. More... | |
bool | HasSHA () |
Determine SHA availability. More... | |
bool | HasADX () |
Determine ADX availability. More... | |
bool | HasAVX () |
Determine AVX availability. More... | |
bool | HasAVX2 () |
Determine AVX2 availability. More... | |
bool | HasRDRAND () |
Determine RDRAND availability. More... | |
bool | HasRDSEED () |
Determine RDSEED availability. More... | |
bool | HasPadlockRNG () |
Determine Padlock RNG availability. More... | |
bool | HasPadlockACE () |
Determine Padlock ACE availability. More... | |
bool | HasPadlockACE2 () |
Determine Padlock ACE2 availability. More... | |
bool | HasPadlockPHE () |
Determine Padlock PHE availability. More... | |
bool | HasPadlockPMM () |
Determine Padlock PMM availability. More... | |
bool | IsP4 () |
Determine if the CPU is an Intel P4. More... | |
int | GetCacheLineSize () |
Provides the cache line size. More... | |
ARM A-32, Aarch32 and AArch64 CPU FEATURES | |
bool | HasARMv7 () |
Determine if an ARM processor is ARMv7 or above. More... | |
bool | HasNEON () |
Determine if an ARM processor has Advanced SIMD available. More... | |
bool | HasPMULL () |
Determine if an ARM processor provides Polynomial Multiplication. More... | |
bool | HasCRC32 () |
Determine if an ARM processor has CRC32 available. More... | |
bool | HasAES () |
Determine if an ARM processor has AES available. More... | |
bool | HasSHA1 () |
Determine if an ARM processor has SHA1 available. More... | |
bool | HasSHA2 () |
Determine if an ARM processor has SHA256 available. More... | |
bool | HasSHA512 () |
Determine if an ARM processor has SHA512 available. More... | |
bool | HasSHA3 () |
Determine if an ARM processor has SHA3 available. More... | |
bool | HasSM3 () |
Determine if an ARM processor has SM3 available. More... | |
bool | HasSM4 () |
Determine if an ARM processor has SM4 available. More... | |
POWERPC CPU FEATURES | |
bool | HasAltivec () |
Determine if a PowerPC processor has Altivec available. More... | |
bool | HasPower7 () |
Determine if a PowerPC processor has Power7 available. More... | |
bool | HasPower8 () |
Determine if a PowerPC processor has Power8 available. More... | |
bool | HasPower9 () |
Determine if a PowerPC processor has Power9 available. More... | |
bool | HasSHA256 () |
Determine if a PowerPC processor has SHA256 available. More... | |
bool | HasDARN () |
Determine if a PowerPC processor has DARN available. More... | |
Functions for CPU features and intrinsics.
The CPU functions are used in IA-32, ARM and PowerPC code paths. The functions provide cpu specific feature testing on IA-32, ARM and PowerPC machines. Feature detection uses CPUID on IA-32, like Intel and AMD. On other platforms a two-part strategy is used. First, the library attempts to *Query* the OS for a feature, like using Linux getauxval() or android_getCpuFeatures(). If that fails, then *Probe* the cpu executing an instruction and an observe a SIGILL if unsupported. The general pattern used by the library is:
g_hasCRC32 = CPU_QueryCRC32() || CPU_ProbeCRC32(); g_hasPMULL = CPU_QueryPMULL() || CPU_ProbePMULL(); g_hasAES = CPU_QueryAES() || CPU_ProbeAES();
Generally speaking, CPU_Query() is in the source file cpu.cpp
because it does not require special architectural flags. CPU_Probe() is in a source file that recieves architectural flags, like sse_simd.cpp
, neon_simd.cpp
and ppc_simd.cpp
. For example, compiling neon_simd.cpp
on an ARM64 machine will have -march=armv8-a
applied during a compile to make the instruction set architecture (ISA) available. The cpu probes are expensive when compared to a standard OS feature query. The library also avoids probes on Apple platforms because Apple's signal handling for SIGILLs appears to corrupt memory. CPU_Probe() will unconditionally return false for Apple platforms. OpenSSL experienced the same problem and moved away from SIGILL probes on Apple.
Definition in file cpu.h.
|
inline |
Determine SSE2 availability.
|
inline |
Determine SSSE3 availability.
|
inline |
Determine SSE4.1 availability.
|
inline |
Determine SSE4.2 availability.
|
inline |
Determine MOVBE availability.
|
inline |
Determine AES-NI availability.
|
inline |
Determine Carryless Multiply availability.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Determine RDRAND availability.
|
inline |
Determine RDSEED availability.
|
inline |
Determine Padlock RNG availability.
|
inline |
Determine Padlock ACE availability.
|
inline |
Determine Padlock ACE2 availability.
|
inline |
Determine Padlock PHE availability.
|
inline |
Determine Padlock PMM availability.
|
inline |
|
inline |
Provides the cache line size.
|
inline |
|
inline |
Determine if an ARM processor has Advanced SIMD available.
-mfpu=neon
(32-bit) or -march=armv8-a
(64-bit). Also see ARM's __ARM_NEON
preprocessor macro.
|
inline |
Determine if an ARM processor provides Polynomial Multiplication.
Determine if a PowerPC processor has Polynomial Multiply available.
-march=armv8-a+crypto
; while Apple requires -arch arm64
. Also see ARM's __ARM_FEATURE_CRYPTO
preprocessor macro. -mcpu=power8
; while IBM XL C/C++ compilers require -qarch=pwr8 -qaltivec
. Also see PowerPC's __CRYPTO
preprocessor macro.
|
inline |
Determine if an ARM processor has CRC32 available.
-march=armv8-a+crc
; while Apple requires -arch arm64
. Also see ARM's __ARM_FEATURE_CRC32
preprocessor macro.
|
inline |
Determine if an ARM processor has AES available.
Determine if a PowerPC processor has AES available.
-march=armv8-a+crypto
; while Apple requires -arch arm64
. Also see ARM's __ARM_FEATURE_CRYPTO
preprocessor macro. -mcpu=power8
; while IBM XL C/C++ compilers require -qarch=pwr8 -qaltivec
. Also see PowerPC's __CRYPTO
preprocessor macro.
|
inline |
Determine if an ARM processor has SHA1 available.
-march=armv8-a+crypto
; while Apple requires -arch arm64
. Also see ARM's __ARM_FEATURE_CRYPTO
preprocessor macro.
|
inline |
Determine if an ARM processor has SHA256 available.
-march=armv8-a+crypto
; while Apple requires -arch arm64
. Also see ARM's __ARM_FEATURE_CRYPTO
preprocessor macro.
|
inline |
Determine if an ARM processor has SHA512 available.
Determine if a PowerPC processor has SHA512 available.
-march=armv8.4-a+crypto
; while Apple requires -arch arm64
. Also see ARM's __ARM_FEATURE_CRYPTO
preprocessor macro. -mcpu=power8
; while IBM XL C/C++ compilers require -qarch=pwr8 -qaltivec
. Also see PowerPC's __CRYPTO
preprocessor macro.
|
inline |
Determine if an ARM processor has SHA3 available.
-march=armv8.4-a+crypto
; while Apple requires -arch arm64
. Also see ARM's __ARM_FEATURE_CRYPTO
preprocessor macro.
|
inline |
Determine if an ARM processor has SM3 available.
-march=armv8.4-a+crypto
; while Apple requires -arch arm64
. Also see ARM's __ARM_FEATURE_CRYPTO
preprocessor macro.
|
inline |
Determine if an ARM processor has SM4 available.
-march=armv8.4-a+crypto
; while Apple requires -arch arm64
. Also see ARM's __ARM_FEATURE_CRYPTO
preprocessor macro.
|
inline |
Determine if a PowerPC processor has Altivec available.
-mcpu=power4
; while IBM XL C/C++ compilers require -qarch=pwr6 -qaltivec
. Also see PowerPC's _ALTIVEC_
preprocessor macro.
|
inline |
Determine if a PowerPC processor has Power7 available.
-mcpu=power7
; while IBM XL C/C++ compilers require -qarch=pwr7 -qaltivec
. Also see PowerPC's _ALTIVEC_
preprocessor macro.
|
inline |
Determine if a PowerPC processor has Power8 available.
-mcpu=power8
; while IBM XL C/C++ compilers require -qarch=pwr8 -qaltivec
. Also see PowerPC's _ALTIVEC_
preprocessor macro.
|
inline |
Determine if a PowerPC processor has Power9 available.
-mcpu=power9
; while IBM XL C/C++ compilers require -qarch=pwr9 -qaltivec
. Also see PowerPC's _ALTIVEC_
preprocessor macro.
|
inline |
Determine if a PowerPC processor has SHA256 available.
-mcpu=power8
; while IBM XL C/C++ compilers require -qarch=pwr8 -qaltivec
. Also see PowerPC's __CRYPTO
preprocessor macro.
|
inline |
Determine if a PowerPC processor has DARN available.
-mcpu=power9
; while IBM XL C/C++ compilers require -qarch=pwr9 -qaltivec
. Also see PowerPC's _ALTIVEC_
preprocessor macro.