AI-generated Key Takeaways
-
The content describes the
SbCPUFeaturesstruct and its nested structs (SbCPUFeaturesARM,SbCPUFeaturesMIPS,SbCPUFeaturesX86), which hold detailed information about CPU architecture, features, and capabilities. -
SbCPUFeaturescontains fields like processor brand, cache line sizes, hardware capability bitmasks, and architecture-specific details. -
Each architecture-specific struct (
SbCPUFeaturesARM,SbCPUFeaturesMIPS,SbCPUFeaturesX86) has members that identify the processor's manufacturer, model, and supported instruction sets, such as NEON, AES, AVX, and SSE. -
The
SbCPUFeaturesGetfunction retrieves CPU features and populates anSbCPUFeaturesstruct, returning false if the CPU architecture is unknown and the struct is invalid.
Structs
SbCPUFeatures
Members
SbCPUFeaturesArchitecture architectureArchitecture of the processor.
const char * brandProcessor brand string retrievable by CPUID or from /proc/cpuinfo under the key "model name" or "Processor".
int32_t icache_line_sizeProcessor cache line size in bytes of Level 1 instruction cache and data cache. Queried by sysconf(_SC_LEVEL1_ICACHE_LINESIZE) and sysconf(_SC_LEVEL1_DCACHE_LINESIZE), or from files /proc/cpuinfo, /proc/self/auxv, or CPUID with CLFLUSH instruction.
int32_t dcache_line_sizebool has_fpuProcessor has floating-point unit on-chip.
uint32_t hwcapBit-mask containing processor features flags. Queried by getauxval(AT_HWCAP) if it is supported.
uint32_t hwcap2Similar to hwcap. Queried by getauxval(AT_HWCAP2) if it is supported.
SbCPUFeaturesARM armProcessor features specific to each architecture. Set the appropriate
SbCPUFeatures<ARCH_NAME>for the underlying architecture. Set the otherSbCPUFeatures<OTHER_ARCH>to be invalid, meaning:'-1' for signed integer fields
'false' for feature flag fields
'0' for feature flag bitmasks
empty string for string fields
SbCPUFeaturesMIPS mips_archThe reason that the "_arch" suffix exists for mips is because on some platforms that use MIPS as the underlying architecture, "mips" is already defined as a macro.
SbCPUFeaturesX86 x86
SbCPUFeaturesARM
Members
int16_t implementerProcessor implementer/implementor code. ARM is 0x41, NVIDIA is 0x4e, etc.
int16_t variantProcessor variant number, indicating the major revision number.
int16_t revisionProcessor revision number, indicating the minor revision number.
int16_t architecture_generationProcessor architecture generation number, indicating the generations (ARMv6-M, ARMv7, etc) within an architecture family. This field is called "Architecture" or "Constant" in the processor ID register.
int16_t partProcessor part number, indicating Cortex-M0, Cortex-A8, etc.
bool has_neonARM Advanced SIMD (NEON) vector instruction set extension.
bool has_thumb2Thumb-2 mode.
bool has_vfpVFP (SIMD vector floating point instructions).
bool has_vfp3VFP version 3
bool has_vfp4VFP version 4
bool has_vfp3_d32VFP version 3 with 32 D-registers.
bool has_idivaSDIV and UDIV hardware division in ARM mode.
bool has_aesArm 64 feature flags
AES instructions.
bool has_crc32CRC32 instructions.
bool has_sha1SHA-1 instructions.
bool has_sha2SHA-256 instructions.
bool has_pmull64-bit PMULL and PMULL2 instructions.
SbCPUFeaturesMIPS
Members
bool has_msaMIPS SIMD Architecture (MSA).
SbCPUFeaturesX86
Members
const char * vendorProcessor vendor ID string, e.g. "GenuineIntel", "AuthenticAMD", etc
int16_t familyProcessor family ID
int16_t ext_familyProcessor extended family ID, needs to be examined only when the family ID is 0FH.
int16_t modelProcessor model ID
int16_t ext_modelProcessor extended model ID, needs to be examined only when the family ID is 06H or 0FH.
int16_t steppingProcessor stepping ID, a product revision number
int16_t typeProcessor type ID
int32_t signatureA raw form of collection of processor stepping, model, and family information
bool has_cmovConditional Move Instructions (plus FCMOVcc, FCOMI with FPU).
bool has_mmxMultimedia extensions.
bool has_sseSSE (Streaming SIMD Extensions).
bool has_sse2SSE2 extensions.
bool has_tscTime Stamp Counter.
bool has_sse3SSE3 extensions.
bool has_pclmulqdqPCLMULQDQ instruction.
bool has_ssse3Supplemental SSE3 extensions.
bool has_sse41SSE-4.1 extensions.
bool has_sse42SSE-4.2 extensions.
bool has_movbeMOVBE instruction.
bool has_popcntPOPCNT instruction.
bool has_osxsaveXSAVE/XRSTOR/XGETBV/XSETBV instruction enabled in this OS.
bool has_avxAVX (Advanced Vector Extensions).
bool has_f16c16-bit FP conversions.
bool has_fma3Fused multiply-add.
bool has_aesniAES new instructions (AES-NI).
bool has_avx2AVX2 Extensions.
bool has_avx512fAVX-512 Foundation.
bool has_avx512dqAVX-512 DQ (Double/Quad granular) Instructions.
bool has_avx512ifmaAVX-512 Integer Fused Multiply-Add instructions.
bool has_avx512pfAVX-512 Prefetch.
bool has_avx512erAVX-512 Exponential and Reciprocal.
bool has_avx512cdAVX-512 Conflict Detection.
bool has_avx512bwAVX-512 BW (Byte/Word granular) Instructions.
bool has_avx512vlAVX-512 VL (128/256 Vector Length) Extensions.
bool has_bmi1First group of bit manipulation extensions.
bool has_bmi2Second group of bit manipulation extensions.
bool has_lzcntBit manipulation instruction LZCNT.
bool has_sahfSAHF in long mode.
Functions
SbCPUFeaturesGet
Retrieve the underlying CPU features and place it in features, which must not
be NULL.
If this function returns false, it means the CPU architecture is unknown and all
fields in features are invalid.
Declaration
bool SbCPUFeaturesGet(SbCPUFeatures *features)