QSC Post Quantum Cryptographic Library 1.0.0.6c (A6)
A post quantum secure library written in Ansi C
 
Loading...
Searching...
No Matches
cpuidex.h File Reference

Retrieves CPU features and capabilities. More...

#include "common.h"

Go to the source code of this file.

Data Structures

struct  qsc_cpuidex_cpu_features
 Contains the CPU feature availability. More...
 

Macros

#define QSC_CPUIDEX_SERIAL_SIZE   12ULL
 The CPU serial number length (in bytes).
 
#define QSC_CPUIDEX_VENDOR_SIZE   12ULL
 The CPU vendor name length.
 

Enumerations

enum  qsc_cpuidex_cpu_type {
  qsc_cpuid_unknown = 0x00U , qsc_cpuid_amd = 0x01U , qsc_cpuid_intel = 0x02U , qsc_cpuid_via = 0x03U ,
  qsc_cpuid_hygion = 0x04U
}
 The detectable CPU architectures. More...
 

Functions

QSC_EXPORT_API bool qsc_cpuidex_features_set (qsc_cpuidex_cpu_features *const features)
 Populate the CPU features structure with detected CPU capabilities.
 
QSC_EXPORT_API void qsc_cpuidex_print_stats (void)
 Print the detected CPU features to the console.
 

Detailed Description

Retrieves CPU features and capabilities.

This header provides functions and type definitions for detecting and retrieving the CPU's supported features and capabilities. It leverages the CPUID instruction and additional methods to identify the availability of hardware-accelerated cryptographic instructions (e.g., AES-NI, AVX, AVX2, AVX512, and ARM NEON), along with other processor attributes such as cache sizes, core counts, and clock frequencies. The header also defines constants for the CPU serial number and vendor string lengths, and enumerates supported CPU manufacturer types.

Example Usage:
if (qsc_cpuidex_features_set(&features))
{
}
QSC_EXPORT_API void qsc_cpuidex_print_stats(void)
Print the detected CPU features to the console.
Definition cpuidex.c:930
QSC_EXPORT_API bool qsc_cpuidex_features_set(qsc_cpuidex_cpu_features *const features)
Populate the CPU features structure with detected CPU capabilities.
Definition cpuidex.c:873
Contains the CPU feature availability.
Definition cpuidex.h:119

Reference Links:

Keywords:

CPUID, CPU detection, AES-NI, AVX, AVX2, AVX512, NEON, cryptographic instructions, CPU features, hardware acceleration

Enumeration Type Documentation

◆ qsc_cpuidex_cpu_type

The detectable CPU architectures.

Enumerator
qsc_cpuid_unknown 

The CPU type is unknown.

qsc_cpuid_amd 

The CPU type is AMD.

qsc_cpuid_intel 

The CPU type is Intel.

qsc_cpuid_via 

The CPU type is VIA.

qsc_cpuid_hygion 

The CPU type is Hygion.

Function Documentation

◆ qsc_cpuidex_features_set()

QSC_EXPORT_API bool qsc_cpuidex_features_set ( qsc_cpuidex_cpu_features *const features)

Populate the CPU features structure with detected CPU capabilities.

Parameters
features[qsc_cpuidex_cpu_features* const] Pointer to a qsc_cpuidex_cpu_features structure to populate.
Returns
[bool] Returns true if the features were successfully detected; false otherwise.

◆ qsc_cpuidex_print_stats()

QSC_EXPORT_API void qsc_cpuidex_print_stats ( void )

Print the detected CPU features to the console.

This function outputs the CPU capabilities (for example, AVX, AESNI, cache size, vendor) to the console.