libcpuid(3)
π libcpuid β the LibCPUID situation π
okay so bestie, welcome to libcpuid(3) from the Library Functions Manual, and no cap, this one is a whole vibe. LibCPUID provides CPU identification. that's the whole gig. it looks at your processor and tells you what's up. iconic behavior fr fr.
β¨ NAME β¨
libcpuid β LibCPUID. yes the name is literally the library. LibCPUID provides CPU identification. that's it, that's the mission statement, and honestly? slay.
πΈ SYNOPSIS πΈ
bestie, this is where it gets meaty. we got structures, we got macros, we got typedefs. buckle up π
π¦ Data Structures π¦
struct cpu_raw_data_tβ just holds the raw CPUID data. unprocessed, unfiltered, straight from the source. it's giving raw data energy.struct cpu_raw_data_array_tβ an array of raw CPUID data. so like, many of the above. a whole squad of raw data.struct cpu_sgx_tβ carries the info about the SGX features of the processor. and then, for reasons known only to the original docs, it's immediately followed by the words:
Example usage:
...with nothing after it in this section. we love a cliffhanger π
struct x86_id_tβ holds the x86 specific info. x86 girlies rise πstruct arm_id_tβ holds the ARM specific info. ARM girlies also rise π«Άstruct cpu_id_tβ the big one. this contains the recognized CPU features/info. main character struct energy πstruct system_id_tβ contains the recognized features/info for all CPUs on the system. not just one, bestie. the whole roster.struct cpu_mark_tβ an internal structure, used incpu_tsc_mark,cpu_tsc_unmarkandcpu_clock_by_mark. internal!! so don't go poking it like it's yours πstruct cpu_epc_tβ this is literally the return value ofcpuid_get_epc(). that's its entire lore.struct cpu_list_tβ a structure that holds a list of processor names. a lil roster of CPU names, adorable.
π Macros π
#define LIBCPUID_DEPRECATED(message)β the deprecation marker macro, takes amessage. it's the library's way of saying "this one is old, bestie, please move on".#define NUM_CPU_VENDORS NUM_CPU_VENDORSβ yes it defines itself to itself. no, we are not going to explain it. it is what it is. periodt.#define NUM_CPU_ARCHITECTURES NUM_CPU_ARCHITECTURESβ same situation, different name. iconic honestly.#define NUM_FEATURE_LEVELS NUM_FEATURE_LEVELSβ once again defining itself. self-love, we stan.#define NUM_CPU_PURPOSES NUM_CPU_PURPOSESβ yep. itself. again. consistency is a virtue.#define NUM_HYPERVISOR_VENDORS NUM_HYPERVISOR_VENDORSβ and another one. the self-definition streak is unmatched π₯#define CPU_INVALID_VALUE 0x3fffffffβ the "this value is invalid" sentinel, and its exact value is0x3fffffff. memorize it or whatever, it'll come back.
β Typedefs β
typedef void(* libcpuid_warn_fn_t) (const char *msg)β a function pointer type for warning callbacks. it takes aconst char *msgand returnsvoid. so if the library needs to warn you about something, this is the shape of the function it'll call to do it. very "hey bestie, heads up" of it.
okay that's the structures, macros and typedefs wrapped. the rest of this manual is long and we're only on part 1, so keep scrolling bestie, there is SO much more π
β¨ Enumerations β¨
okay bestie, this is the big one β all the enums the library hands you. every value listed below is exactly as it is in the header, no cap. π
enum cpu_vendor_t
enum cpu_vendor_t { VENDOR_INTEL = 0, VENDOR_AMD, VENDOR_CYRIX,
VENDOR_NEXGEN, VENDOR_TRANSMETA, VENDOR_UMC, VENDOR_CENTAUR,
VENDOR_RISE, VENDOR_SIS, VENDOR_NSC, VENDOR_HYGON, VENDOR_ARM,
VENDOR_BROADCOM, VENDOR_CAVIUM, VENDOR_DEC, VENDOR_FUJITSU,
VENDOR_HISILICON, VENDOR_INFINEON, VENDOR_FREESCALE, VENDOR_NVIDIA,
VENDOR_APM, VENDOR_QUALCOMM, VENDOR_SAMSUNG, VENDOR_MARVELL,
VENDOR_APPLE, VENDOR_FARADAY, VENDOR_MICROSOFT, VENDOR_PHYTIUM,
VENDOR_AMPERE, NUM_CPU_VENDORS, VENDOR_UNKNOWN = -1 }
the CPU vendor, figured out from the Vendor String. that's the vibe β libcpuid peeks at the string and goes "oh you're an VENDOR_APPLE bestie, iconic". VENDOR_UNKNOWN is -1 so it's lowkey the "idk her" option. π
enum cpu_architecture_t
enum cpu_architecture_t { ARCHITECTURE_X86 = 0, ARCHITECTURE_ARM,
NUM_CPU_ARCHITECTURES, ARCHITECTURE_UNKNOWN = -1 }
the CPU architecture. yes it's short. sometimes the queen keeps it simple. ARCHITECTURE_UNKNOWN is -1 again, the classic escape hatch. π¦
enum cpu_feature_level_t
enum cpu_feature_level_t { FEATURE_LEVEL_I386, FEATURE_LEVEL_I486,
FEATURE_LEVEL_I586, FEATURE_LEVEL_I686, FEATURE_LEVEL_X86_64_V1,
FEATURE_LEVEL_X86_64_V2, FEATURE_LEVEL_X86_64_V3,
FEATURE_LEVEL_X86_64_V4, FEATURE_LEVEL_ARM_V1 = 100,
FEATURE_LEVEL_ARM_V2, FEATURE_LEVEL_ARM_V3, FEATURE_LEVEL_ARM_V4,
FEATURE_LEVEL_ARM_V4T, FEATURE_LEVEL_ARM_V5, FEATURE_LEVEL_ARM_V5T,
FEATURE_LEVEL_ARM_V5TE, FEATURE_LEVEL_ARM_V5TEJ,
FEATURE_LEVEL_ARM_V6, FEATURE_LEVEL_ARM_V6_M,
FEATURE_LEVEL_ARM_V7_A, FEATURE_LEVEL_ARM_V7_M,
FEATURE_LEVEL_ARM_V7_R, FEATURE_LEVEL_ARM_V7E_M,
FEATURE_LEVEL_ARM_V8_0_A, FEATURE_LEVEL_ARM_V8_0_M,
FEATURE_LEVEL_ARM_V8_0_R, FEATURE_LEVEL_ARM_V8_1_A,
FEATURE_LEVEL_ARM_V8_1_M, FEATURE_LEVEL_ARM_V8_2_A,
FEATURE_LEVEL_ARM_V8_3_A, FEATURE_LEVEL_ARM_V8_4_A,
FEATURE_LEVEL_ARM_V8_5_A, FEATURE_LEVEL_ARM_V8_6_A,
FEATURE_LEVEL_ARM_V8_7_A, FEATURE_LEVEL_ARM_V8_8_A,
FEATURE_LEVEL_ARM_V8_9_A, FEATURE_LEVEL_ARM_V9_0_A,
FEATURE_LEVEL_ARM_V9_1_A, FEATURE_LEVEL_ARM_V9_2_A,
FEATURE_LEVEL_ARM_V9_3_A, FEATURE_LEVEL_ARM_V9_4_A,
FEATURE_LEVEL_ARM_V9_5_A, NUM_FEATURE_LEVELS, FEATURE_LEVEL_UNKNOWN
= -1 }
the CPU feature level! notice how x86 starts at 0 and ARM starts at 100? that's a deliberate little gap so the two families never beef over numbers. main character energy. and FEATURE_LEVEL_UNKNOWN = -1 holds down the "we don't know her" corner. π
enum cpu_purpose_t
enum cpu_purpose_t { PURPOSE_GENERAL = 0, PURPOSE_PERFORMANCE,
PURPOSE_EFFICIENCY, PURPOSE_LP_EFFICIENCY, PURPOSE_U_PERFORMANCE,
NUM_CPU_PURPOSES }
the CPU purpose. like, is this core here for general stuff, for raw performance, for efficiency, for low-power efficiency, or for ultra-performance? it's giving big-little core lore and honestly we're obsessed. π₯
enum hypervisor_vendor_t
enum hypervisor_vendor_t { HYPERVISOR_NONE = 0, HYPERVISOR_BHYVE,
HYPERVISOR_HYPERV, HYPERVISOR_KVM, HYPERVISOR_PARALLELS,
HYPERVISOR_QEMU, HYPERVISOR_VIRTUALBOX, HYPERVISOR_VMWARE,
HYPERVISOR_XEN, NUM_HYPERVISOR_VENDORS, HYPERVISOR_UNKNOWN = -1 }
the hypervisor vendor, guessed from the CPU_FEATURE_HYPERVISOR flag. HYPERVISOR_NONE = 0 means you're on bare metal, periodt. HYPERVISOR_UNKNOWN = -1 is the "couldn't tell, she's mysterious" slot. π§
enum cpu_feature_t
bestie. breathe. this one is long. it's the CPU feature identifiers and no, I'm not skipping a single one, the facts stay facts. π«Ά
enum cpu_feature_t { CPU_FEATURE_FPU = 0, CPU_FEATURE_VME,
CPU_FEATURE_DE, CPU_FEATURE_PSE, CPU_FEATURE_TSC, CPU_FEATURE_MSR,
CPU_FEATURE_PAE, CPU_FEATURE_MCE, CPU_FEATURE_CX8, CPU_FEATURE_APIC,
CPU_FEATURE_MTRR, CPU_FEATURE_SEP, CPU_FEATURE_PGE, CPU_FEATURE_MCA,
CPU_FEATURE_CMOV, CPU_FEATURE_PAT, CPU_FEATURE_PSE36,
CPU_FEATURE_PN, CPU_FEATURE_CLFLUSH, CPU_FEATURE_DTS,
CPU_FEATURE_ACPI, CPU_FEATURE_MMX, CPU_FEATURE_FXSR,
CPU_FEATURE_SSE, CPU_FEATURE_SSE2, CPU_FEATURE_SS, CPU_FEATURE_HT,
CPU_FEATURE_TM, CPU_FEATURE_IA64, CPU_FEATURE_PBE, CPU_FEATURE_PNI,
CPU_FEATURE_PCLMUL, CPU_FEATURE_DTS64, CPU_FEATURE_MONITOR,
CPU_FEATURE_DS_CPL, CPU_FEATURE_VMX, CPU_FEATURE_SMX,
CPU_FEATURE_EST, CPU_FEATURE_TM2, CPU_FEATURE_SSSE3,
CPU_FEATURE_CID, CPU_FEATURE_CX16, CPU_FEATURE_XTPR,
CPU_FEATURE_PDCM, CPU_FEATURE_DCA, CPU_FEATURE_SSE4_1,
CPU_FEATURE_SSE4_2, CPU_FEATURE_SYSCALL, CPU_FEATURE_XD,
CPU_FEATURE_MOVBE, CPU_FEATURE_POPCNT, CPU_FEATURE_AES,
CPU_FEATURE_XSAVE, CPU_FEATURE_OSXSAVE, CPU_FEATURE_AVX,
CPU_FEATURE_MMXEXT, CPU_FEATURE_3DNOW, CPU_FEATURE_3DNOWEXT,
CPU_FEATURE_NX, CPU_FEATURE_FXSR_OPT, CPU_FEATURE_RDTSCP,
CPU_FEATURE_LM, CPU_FEATURE_LAHF_LM, CPU_FEATURE_CMP_LEGACY,
CPU_FEATURE_SVM, CPU_FEATURE_ABM, CPU_FEATURE_MISALIGNSSE,
CPU_FEATURE_SSE4A, CPU_FEATURE_3DNOWPREFETCH, CPU_FEATURE_OSVW,
CPU_FEATURE_IBS, CPU_FEATURE_SSE5, CPU_FEATURE_SKINIT,
CPU_FEATURE_WDT, CPU_FEATURE_TS, CPU_FEATURE_FID, CPU_FEATURE_VID,
CPU_FEATURE_TTP, CPU_FEATURE_TM_AMD, CPU_FEATURE_STC,
CPU_FEATURE_100MHZSTEPS, CPU_FEATURE_HWPSTATE,
CPU_FEATURE_CONSTANT_TSC, CPU_FEATURE_XOP, CPU_FEATURE_FMA3,
CPU_FEATURE_FMA4, CPU_FEATURE_TBM, CPU_FEATURE_F16C,
CPU_FEATURE_RDRAND, CPU_FEATURE_X2APIC, CPU_FEATURE_CPB,
CPU_FEATURE_APERFMPERF, CPU_FEATURE_PFI, CPU_FEATURE_PA,
CPU_FEATURE_AVX2, CPU_FEATURE_BMI1, CPU_FEATURE_BMI2,
CPU_FEATURE_HLE, CPU_FEATURE_RTM, CPU_FEATURE_AVX512F,
CPU_FEATURE_AVX512DQ, CPU_FEATURE_AVX512PF, CPU_FEATURE_AVX512ER,
CPU_FEATURE_AVX512CD, CPU_FEATURE_SHA_NI, CPU_FEATURE_AVX512BW,
CPU_FEATURE_AVX512VL, CPU_FEATURE_SGX, CPU_FEATURE_RDSEED,
CPU_FEATURE_ADX, CPU_FEATURE_AVX512VNNI, CPU_FEATURE_AVX512VBMI,
CPU_FEATURE_AVX512VBMI2, CPU_FEATURE_HYPERVISOR, CPU_FEATURE_SWAP,
CPU_FEATURE_THUMB, CPU_FEATURE_ADVMULTU, CPU_FEATURE_ADVMULTS,
CPU_FEATURE_JAZELLE, CPU_FEATURE_DEBUGV6, CPU_FEATURE_DEBUGV6P1,
CPU_FEATURE_THUMB2, CPU_FEATURE_DEBUGV7, CPU_FEATURE_DEBUGV7P1,
CPU_FEATURE_THUMBEE, CPU_FEATURE_DIVIDE, CPU_FEATURE_LPAE,
CPU_FEATURE_PMUV1, CPU_FEATURE_PMUV2, CPU_FEATURE_ASID16,
CPU_FEATURE_ADVSIMD, CPU_FEATURE_CRC32, CPU_FEATURE_CSV2_1P1,
CPU_FEATURE_CSV2_1P2, CPU_FEATURE_CSV2_2, CPU_FEATURE_CSV2_3,
CPU_FEATURE_DOUBLELOCK, CPU_FEATURE_ETS2, CPU_FEATURE_FP,
CPU_FEATURE_MIXEDEND, CPU_FEATURE_MIXEDENDEL0, CPU_FEATURE_PMULL,
CPU_FEATURE_PMUV3, CPU_FEATURE_SHA1, CPU_FEATURE_SHA256,
CPU_FEATURE_NTLBPA, CPU_FEATURE_HAFDBS, CPU_FEATURE_HPDS,
CPU_FEATURE_LOR, CPU_FEATURE_LSE, CPU_FEATURE_PAN,
CPU_FEATURE_PMUV3P1, CPU_FEATURE_RDM, CPU_FEATURE_VHE,
CPU_FEATURE_VMID16, CPU_FEATURE_AA32HPD, CPU_FEATURE_AA32I8MM,
CPU_FEATURE_DPB, CPU_FEATURE_DEBUGV8P2, CPU_FEATURE_F32MM,
CPU_FEATURE_F64MM, CPU_FEATURE_FP16, CPU_FEATURE_HPDS2,
CPU_FEATURE_I8MM, CPU_FEATURE_IESB, CPU_FEATURE_LPA,
CPU_FEATURE_LSMAOC, CPU_FEATURE_LVA, CPU_FEATURE_PAN2,
CPU_FEATURE_RAS, CPU_FEATURE_SHA3, CPU_FEATURE_SHA512,
CPU_FEATURE_SM3, CPU_FEATURE_SM4, CPU_FEATURE_SPE, CPU_FEATURE_SVE,
CPU_FEATURE_TTCNP, CPU_FEATURE_UAO, CPU_FEATURE_XNX,
CPU_FEATURE_CCIDX, CPU_FEATURE_CONSTPACFIELD, CPU_FEATURE_EPAC,
CPU_FEATURE_FCMA, CPU_FEATURE_FPAC, CPU_FEATURE_FPACCOMBINE,
CPU_FEATURE_JSCVT, CPU_FEATURE_LRCPC, CPU_FEATURE_PACIMP,
CPU_FEATURE_PACQARMA3, CPU_FEATURE_PACQARMA5, CPU_FEATURE_PAUTH,
CPU_FEATURE_SPEV1P1, CPU_FEATURE_AMUV1, CPU_FEATURE_BBM,
CPU_FEATURE_DIT, CPU_FEATURE_DEBUGV8P4, CPU_FEATURE_DOTPROD,
CPU_FEATURE_DOUBLEFAULT, CPU_FEATURE_FHM, CPU_FEATURE_FLAGM,
CPU_FEATURE_IDST, CPU_FEATURE_LRCPC2, CPU_FEATURE_LSE2,
CPU_FEATURE_MPAM, CPU_FEATURE_PMUV3P4, CPU_FEATURE_RASV1P1,
CPU_FEATURE_S2FWB, CPU_FEATURE_SEL2, CPU_FEATURE_TLBIOS,
CPU_FEATURE_TLBIRANGE, CPU_FEATURE_TRF, CPU_FEATURE_TTL,
CPU_FEATURE_TTST, CPU_FEATURE_BTI, CPU_FEATURE_CSV2,
CPU_FEATURE_CSV3, CPU_FEATURE_DPB2, CPU_FEATURE_E0PD,
CPU_FEATURE_EVT, CPU_FEATURE_EXS, CPU_FEATURE_FRINTTS,
CPU_FEATURE_FLAGM2, CPU_FEATURE_MTE, CPU_FEATURE_MTE2,
CPU_FEATURE_PMUV3P5, CPU_FEATURE_RNG, CPU_FEATURE_RNG_TRAP,
CPU_FEATURE_SB, CPU_FEATURE_SPECRES, CPU_FEATURE_SSBS,
CPU_FEATURE_SSBS2, CPU_FEATURE_AA32BF16, CPU_FEATURE_AMUV1P1,
CPU_FEATURE_BF16, CPU_FEATURE_DGH, CPU_FEATURE_ECV, CPU_FEATURE_FGT,
CPU_FEATURE_HPMN0, CPU_FEATURE_MPAMV0P1, CPU_FEATURE_MPAMV1P1,
CPU_FEATURE_MTPMU, CPU_FEATURE_PAUTH2, CPU_FEATURE_TWED,
CPU_FEATURE_AFP, CPU_FEATURE_EBF16, CPU_FEATURE_HCX,
CPU_FEATURE_LPA2, CPU_FEATURE_LS64, CPU_FEATURE_LS64_ACCDATA,
CPU_FEATURE_LS64_V, CPU_FEATURE_MTE3, CPU_FEATURE_MTE_ASYM_FAULT,
CPU_FEATURE_PAN3, CPU_FEATURE_PMUV3P7, CPU_FEATURE_RPRES,
CPU_FEATURE_SPEV1P2, CPU_FEATURE_WFXT, CPU_FEATURE_XS,
CPU_FEATURE_CMOW, CPU_FEATURE_DEBUGV8P8, CPU_FEATURE_HBC,
CPU_FEATURE_MOPS, CPU_FEATURE_NMI, CPU_FEATURE_PMUV3P8,
CPU_FEATURE_SCTLR2, CPU_FEATURE_SPEV1P3, CPU_FEATURE_TCR2,
CPU_FEATURE_TIDCP1, CPU_FEATURE_ADERR, CPU_FEATURE_AIE,
CPU_FEATURE_ANERR, CPU_FEATURE_ATS1A, CPU_FEATURE_CLRBHB,
CPU_FEATURE_CSSC, CPU_FEATURE_DEBUGV8P9, CPU_FEATURE_DOUBLEFAULT2,
CPU_FEATURE_ECBHB, CPU_FEATURE_FGT2, CPU_FEATURE_HAFT,
CPU_FEATURE_LRCPC3, CPU_FEATURE_MTE4, CPU_FEATURE_MTE_ASYNC,
CPU_FEATURE_MTE_CANONICAL_TAGS, CPU_FEATURE_MTE_NO_ADDRESS_TAGS,
CPU_FEATURE_MTE_PERM, CPU_FEATURE_MTE_STORE_ONLY,
CPU_FEATURE_MTE_TAGGED_FAR, CPU_FEATURE_PFAR,
CPU_FEATURE_PMUV3_ICNTR, CPU_FEATURE_PMUV3_SS, CPU_FEATURE_PMUV3P9,
CPU_FEATURE_PRFMSLC, CPU_FEATURE_RASV2, CPU_FEATURE_RPRFM,
CPU_FEATURE_S1PIE, CPU_FEATURE_S1POE, CPU_FEATURE_S2PIE,
CPU_FEATURE_S2POE, CPU_FEATURE_SPECRES2, CPU_FEATURE_SPE_DPFZS,
CPU_FEATURE_SPEV1P4, CPU_FEATURE_SPMU, CPU_FEATURE_THE,
CPU_FEATURE_SVE2, CPU_FEATURE_SVE_AES, CPU_FEATURE_SVE_BITPERM,
CPU_FEATURE_SVE_PMULL128, CPU_FEATURE_SVE_SHA3, CPU_FEATURE_SVE_SM4,
CPU_FEATURE_TME, CPU_FEATURE_TRBE, CPU_FEATURE_BRBE,
CPU_FEATURE_RME, CPU_FEATURE_SME, CPU_FEATURE_SME_F64F64,
CPU_FEATURE_SME_FA64, CPU_FEATURE_SME_I16I64, CPU_FEATURE_BRBEV1P1,
CPU_FEATURE_MEC, CPU_FEATURE_SME2, CPU_FEATURE_ABLE,
CPU_FEATURE_BWE, CPU_FEATURE_D128, CPU_FEATURE_EBEP,
CPU_FEATURE_GCS, CPU_FEATURE_ITE, CPU_FEATURE_LSE128,
CPU_FEATURE_LVA3, CPU_FEATURE_SEBEP, CPU_FEATURE_SME2P1,
CPU_FEATURE_SME_F16F16, CPU_FEATURE_SVE2P1, CPU_FEATURE_SVE_B16B16,
CPU_FEATURE_SYSINSTR128, CPU_FEATURE_SYSREG128,
CPU_FEATURE_TRBE_EXT, CPU_FEATURE_ASID2, CPU_FEATURE_BWE2,
CPU_FEATURE_CPA, CPU_FEATURE_CPA2, CPU_FEATURE_E2H0,
CPU_FEATURE_E3DSE, CPU_FEATURE_ETS3, CPU_FEATURE_FAMINMAX,
CPU_FEATURE_FGWTE3, CPU_FEATURE_FP8, CPU_FEATURE_FP8DOT2,
CPU_FEATURE_FP8DOT4, CPU_FEATURE_FP8FMA, CPU_FEATURE_FPMR,
CPU_FEATURE_HACDBS, CPU_FEATURE_HDBSS, CPU_FEATURE_LUT,
CPU_FEATURE_PAUTH_LR, CPU_FEATURE_RME_GPC2, CPU_FEATURE_SME_F8F16,
CPU_FEATURE_SME_F8F32, CPU_FEATURE_SME_LUTV2, CPU_FEATURE_SPMU2,
CPU_FEATURE_SSVE_FP8DOT2, CPU_FEATURE_SSVE_FP8DOT4,
CPU_FEATURE_SSVE_FP8FMA, CPU_FEATURE_STEP2, CPU_FEATURE_TLBIW,
NUM_CPU_FEATURES }
likeβ¦ that's the CPU feature identifiers, all of them, from your x86 classics (CPU_FEATURE_FPU = 0, CPU_FEATURE_SSE, CPU_FEATURE_AVX, the whole CPU_FEATURE_AVX512* squad) all the way through the ARM world (CPU_FEATURE_THUMB, CPU_FEATURE_SVE*, CPU_FEATURE_SME*, the CPU_FEATURE_MTE* family, and every DEBUGV8P*/DEBUGV8P9 bestie). CPU_FEATURE_HYPERVISOR is in there too β that's the one that snitches on whether you're running under a hypervisor. NUM_CPU_FEATURES is the counter at the end so you can loop without guessing. iykyk. π
fr fr: this enum is huge, so don't hardcode counts β use NUM_CPU_FEATURES and let it do the math for you.
enum cpu_hint_t
enum cpu_hint_t { CPU_HINT_SSE_SIZE_AUTH = 0, NUM_CPU_HINTS }
CPU detection hints identifiers. tiny enum, big responsibility. CPU_HINT_SSE_SIZE_AUTH is the hint you flip when you want the SSE size reported as authoritative. π
enum cpu_sgx_feature_t
enum cpu_sgx_feature_t { INTEL_SGX1, INTEL_SGX2, NUM_SGX_FEATURES }
SGX features flags. just INTEL_SGX1, INTEL_SGX2, and NUM_SGX_FEATURES to keep count. short, sweet, iconic. β
enum cpu_error_t
enum cpu_error_t { ERR_OK = 0, ERR_NO_CPUID = -1, ERR_NO_RDTSC = -2,
ERR_NO_MEM = -3, ERR_OPEN = -4, ERR_BADFMT = -5, ERR_NOT_IMP = -6,
ERR_CPU_UNKN = -7, ERR_NO_RDMSR = -8, ERR_NO_DRIVER = -9,
ERR_NO_PERMS = -10, ERR_EXTRACT = -11, ERR_HANDLE = -12, ERR_INVMSR
= -13, ERR_INVCNB = -14, ERR_HANDLE_R = -15, ERR_INVRANGE = -16,
ERR_NOT_FOUND = -17, ERR_IOCTL = -18, ERR_REQUEST = -19 }
these are the common library error codes β the whole mood ring of things that can go wrong. ERR_OK = 0 is the slay, everything else is negative and each one is a different flavour of "bestie, no". π
ERR_OK = 0β we're so back π«ΆERR_NO_CPUID = -1β noCPUIDinstruction availableERR_NO_RDTSC = -2β noRDTSCERR_NO_MEM = -3β out of memoryERR_OPEN = -4β couldn't open somethingERR_BADFMT = -5β the format was not itERR_NOT_IMP = -6β not implementedERR_CPU_UNKN = -7β unknown CPUERR_NO_RDMSR = -8β noRDMSRERR_NO_DRIVER = -9β no driverERR_NO_PERMS = -10β no permissionsERR_EXTRACT = -11β extraction failedERR_HANDLE = -12β handle issueERR_INVMSR = -13β invalid MSRERR_INVCNB = -14β invalid CPU numberERR_HANDLE_R = -15β handle read issueERR_INVRANGE = -16β invalid rangeERR_NOT_FOUND = -17β not found, she's not hereERR_IOCTL = -18β ioctl issueERR_REQUEST = -19β request issue
ngl, when a call comes back negative, go check this list before you spiral β the number tells you exactly which kind of bad day it is. β¨
...and there's one more little enum chillin' in the synopsis before we get to the fun stuff:
enum cpu_msrinfo_request_t { INFO_MPERF, INFO_APERF,
INFO_MIN_MULTIPLIER, INFO_CUR_MULTIPLIER, INFO_MAX_MULTIPLIER,
INFO_TEMPERATURE, INFO_THROTTLING, INFO_VOLTAGE, INFO_BCLK,
INFO_BUS_CLOCK }
π« FUNCTIONS π«
okay bestie, this is the big one β every single function libcpuid hands you, no cap. take a deep breath, we got this π«Ά
int cpuid_get_total_cpus (void)β hands you the total count of logical CPU threads. and yes, it still works even if CPUID itself isn't a thing on this machine. iconic.int cpuid_present (void)β vibe check: is the CPUID instruction even supported here? πvoid cpu_exec_cpuid (uint32_t eax, uint32_t *regs)β literally runs the CPUID instruction for you.void cpu_exec_cpuid_ext (uint32_t *regs)β same energy, but it runs CPUID using the input registers you already handed it.int cpuid_get_raw_data (struct cpu_raw_data_t *data)β scoops the raw CPUID data off the current CPU β¨int cpuid_get_raw_data_core (struct cpu_raw_data_t *data, logical_cpu_t logical_cpu)β same, but for the specific CPU you name. main character selection energy πint cpuid_get_all_raw_data (struct cpu_raw_data_array_t *data)β grabs the raw CPUID data from every CPU. all of them. periodt.int cpuid_serialize_raw_data (struct cpu_raw_data_t *data, const char *filename)β writes that raw CPUID data out to a text file.int cpuid_serialize_all_raw_data (struct cpu_raw_data_array_t *data, const char *filename)β writes all the raw CPUID data out to a text file.int cpuid_deserialize_raw_data (struct cpu_raw_data_t *data, const char *filename)β reads raw CPUID data back in from a file.int cpuid_deserialize_all_raw_data (struct cpu_raw_data_array_t *data, const char *filename)β reads all the raw CPUID data back in from a file.int cpu_identify (struct cpu_raw_data_t *raw, struct cpu_id_t *data)β the moment of truth: identifies the CPU πint cpu_identify_all (struct cpu_raw_data_array_t *raw_array, struct system_id_t *system)β identifies every CPU in the house, no one left out π«Άint cpu_request_core_type (cpu_purpose_t purpose, struct cpu_raw_data_array_t *raw_array, struct cpu_id_t *data)β identifies a specific CPU type for you.const char * cpu_architecture_str (cpu_architecture_t architecture)β gives you the short, cute text version of a CPU architecture.const char * cpu_feature_level_str (cpu_feature_level_t level)β short text version of a CPU feature level.const char * cpu_purpose_str (cpu_purpose_t purpose)β short text version of a CPU purpose.char * affinity_mask_str_r (cpu_affinity_mask_t *affinity_mask, char *buffer, uint32_t buffer_len)β turns a CPU affinity mask into readable text, and it's thread-safe so you can flex it anywhere πͺchar * affinity_mask_str (cpu_affinity_mask_t *affinity_mask)β turns a CPU affinity mask into readable text (non-thread-safe edition).const char * cpu_feature_str (cpu_feature_t feature)β short text version of a CPU flag.const char * cpuid_error (void)β tells you, in words, what the last error was. emotional support error message πvoid cpu_rdtsc (uint64_t *result)β executes RDTSC. that's it, that's the function.void cpu_tsc_mark (struct cpu_mark_t *mark)β stores the TSC and timing info into your mark.void cpu_tsc_unmark (struct cpu_mark_t *mark)β crunches the TSC and timing difference for you.int cpu_clock_by_mark (struct cpu_mark_t *mark)β calculates the CPU clock from that mark.int cpu_clock_by_os (void)β the CPU clock, straight from what the OS is claiming.int cpu_clock_measure (int millis, int quad_check)β measures the CPU clock frequency the hands-on way.int cpu_clock_by_ic (int millis, int runs)β measures the CPU clock frequency using instruction-counting.int cpu_clock_by_tsc (struct cpu_raw_data_t *raw)β measures the CPU clock frequency using the TSC frequency that CPUID reports.int cpu_clock (void)β the CPU clock frequency, all-in-one method, the lazy-girl slay β¨struct cpu_epc_t cpuid_get_epc (int index, const struct cpu_raw_data_t *raw)β fetches the tea on an EPC (Enclave Page Cache) area.const char * cpuid_lib_version (void)β tells you which libcpuid version you're running.libcpuid_warn_fn_t cpuid_set_warn_function (libcpuid_warn_fn_t warn_fun)β sets the function used for printing warnings.void cpuid_set_verbosiness_level (int level)β sets the verbosiness level. (yes, that's the actual spelling, we do not fix it, we respect it π)cpu_vendor_t cpuid_get_vendor (void)β gets the CPU vendor from CPUID, from the current CPU.hypervisor_vendor_t cpuid_get_hypervisor (struct cpu_raw_data_t *raw, struct cpu_id_t *data)β gets the hypervisor vendor from CPUID, from the current CPU.void cpuid_get_cpu_list (cpu_vendor_t vendor, struct cpu_list_t *list)β gives you a list of every known CPU name from one specific vendor πvoid cpuid_free_cpu_list (struct cpu_list_t *list)β frees a CPU list. clean up after yourself bestie π§Ήvoid cpuid_free_raw_data_array (struct cpu_raw_data_array_t *raw_array)β frees a raw array.void cpuid_free_system_id (struct system_id_t *system)β frees a system ID type.struct msr_driver_t * cpu_msr_driver_open (void)β starts/opens the driver you need in order to read MSRs (Model Specific Registers).struct msr_driver_t * cpu_msr_driver_open_core (unsigned core_num)β basicallycpu_msr_driver_open, except it takes one parameter.int cpu_rdmsr (struct msr_driver_t *handle, uint32_t msr_index, uint64_t *result)β reads a Model-Specific Register (MSR).int cpu_rdmsr_range (struct msr_driver_t *handle, uint32_t msr_index, uint8_t highbit, uint8_t lowbit, uint64_t *result)β likecpu_rdmsr, but it pulls out just a range of bits.int cpu_msrinfo (struct msr_driver_t *handle, cpu_msrinfo_request_t which)β reads extended CPU info out of the Model-Specific Registers.int msr_serialize_raw_data (struct msr_driver_t *handle, const char *filename)β writes the raw MSR data out to a text file.int cpu_msr_driver_close (struct msr_driver_t *handle)β closes an open MSR driver. bye bye driver π¦
π DETAILED DESCRIPTION π
LibCPUID provides CPU identification. yes, that's literally it β the whole vibe in one sentence and honestly? iconic. π
π ENUMERATION TYPE DOCUMENTATION π
ποΈ enum cpu_architecture_t
CPU architecture. the big picture of what kind of brain your silicon has:
ARCHITECTURE_X86β x86 CPUARCHITECTURE_ARMβ ARM CPUNUM_CPU_ARCHITECTURESβ valid CPU architecture ids go0..NUM_CPU_ARCHITECTURES - 1
π¨ enum cpu_error_t
describes the common library error codes. when things go wrong, it's one of these:
ERR_OKβ No error πERR_NO_CPUIDβ CPUID instruction is not supportedERR_NO_RDTSCβ RDTSC instruction is not supportedERR_NO_MEMβ Memory allocation failedERR_OPENβ File open operation failedERR_BADFMTβ Bad file formatERR_NOT_IMPβ Not implementedERR_CPU_UNKNβ Unsupported processorERR_NO_RDMSRβ RDMSR instruction is not supportedERR_NO_DRIVERβ RDMSR driver error (generic)ERR_NO_PERMSβ No permissions to install RDMSR driverERR_EXTRACTβ Cannot extract RDMSR driver (read only media?)ERR_HANDLEβ Bad handleERR_INVMSRβ Invalid MSRERR_INVCNBβ Invalid core numberERR_HANDLE_Rβ Error on handle readERR_INVRANGEβ Invalid given rangeERR_NOT_FOUNDβ Requested type not foundERR_IOCTLβ Error on ioctlERR_REQUESTβ Invalid request
πΆ enum cpu_feature_level_t
CPU feature level. it's giving tier list, and here's every tier:
FEATURE_LEVEL_I386β i386FEATURE_LEVEL_I486β i486FEATURE_LEVEL_I586β i586FEATURE_LEVEL_I686β i686FEATURE_LEVEL_X86_64_V1β x86-64-v1FEATURE_LEVEL_X86_64_V2β x86-64-v2FEATURE_LEVEL_X86_64_V3β x86-64-v3FEATURE_LEVEL_X86_64_V4β x86-64-v4FEATURE_LEVEL_ARM_V1β ARMv1FEATURE_LEVEL_ARM_V2β ARMv2FEATURE_LEVEL_ARM_V3β ARMv3FEATURE_LEVEL_ARM_V4β ARMv4FEATURE_LEVEL_ARM_V4Tβ ARMv4TFEATURE_LEVEL_ARM_V5β ARMv5 (obsolete) πFEATURE_LEVEL_ARM_V5Tβ ARMv5TFEATURE_LEVEL_ARM_V5TEβ ARMv5TEFEATURE_LEVEL_ARM_V5TEJβ ARMv5TEJFEATURE_LEVEL_ARM_V6β ARMv6FEATURE_LEVEL_ARM_V6_Mβ ARMv6-MFEATURE_LEVEL_ARM_V7_Aβ ARMv7-AFEATURE_LEVEL_ARM_V7_Mβ ARMv7-MFEATURE_LEVEL_ARM_V7_Rβ ARMv7-RFEATURE_LEVEL_ARM_V7E_Mβ ARMv7E-MFEATURE_LEVEL_ARM_V8_0_Aβ ARMv8.0-AFEATURE_LEVEL_ARM_V8_0_Mβ ARMv8.0-MFEATURE_LEVEL_ARM_V8_0_Rβ ARMv8.0-RFEATURE_LEVEL_ARM_V8_1_Aβ ARMv8.1-AFEATURE_LEVEL_ARM_V8_1_Mβ ARMv8.1-MFEATURE_LEVEL_ARM_V8_2_Aβ ARMv8.2-AFEATURE_LEVEL_ARM_V8_3_Aβ ARMv8.3-AFEATURE_LEVEL_ARM_V8_4_Aβ ARMv8.4-AFEATURE_LEVEL_ARM_V8_5_Aβ ARMv8.5-AFEATURE_LEVEL_ARM_V8_6_Aβ ARMv8.6-AFEATURE_LEVEL_ARM_V8_7_Aβ ARMv8.7-AFEATURE_LEVEL_ARM_V8_8_Aβ ARMv8.8-AFEATURE_LEVEL_ARM_V8_9_Aβ ARMv8.9-AFEATURE_LEVEL_ARM_V9_0_Aβ ARMv9.0-AFEATURE_LEVEL_ARM_V9_1_Aβ ARMv9.1-AFEATURE_LEVEL_ARM_V9_2_Aβ ARMv9.2-AFEATURE_LEVEL_ARM_V9_3_Aβ ARMv9.3-AFEATURE_LEVEL_ARM_V9_4_Aβ ARMv9.4-AFEATURE_LEVEL_ARM_V9_5_Aβ ARMv9.5-ANUM_FEATURE_LEVELSβ valid feature level ids go0..NUM_FEATURE_LEVELS - 1
π·οΈ enum cpu_feature_t
CPU feature identifiers. and bestie, they gave us a whole usage example, so here's exactly how you'd use it:
...
struct cpu_raw_data_t raw;
struct cpu_id_t id;
if (cpuid_get_raw_data(&raw) == 0 && cpu_identify(&raw, &id) == 0) {
if (id.flags[CPU_FEATURE_SSE2]) {
// The CPU has SSE2...
...
} else {
// no SSE2
}
} else {
// processor cannot be determined.
}
and now, the full flag roster π
CPU_FEATURE_FPUβ Floating point unitCPU_FEATURE_VMEβ Virtual mode extensionCPU_FEATURE_DEβ Debugging extensionCPU_FEATURE_PSEβ Page size extensionCPU_FEATURE_TSCβ Time-stamp counterCPU_FEATURE_MSRβ Model-specific regsisters, RDMSR/WRMSR supported (yep, "regsisters" β we keep the typo, it's part of the lore now)CPU_FEATURE_PAEβ Physical address extensionCPU_FEATURE_MCEβ Machine check exceptionCPU_FEATURE_CX8β CMPXCHG8B instruction supportedCPU_FEATURE_APICβ APIC supportCPU_FEATURE_MTRRβ Memory type range registersCPU_FEATURE_SEPβ SYSENTER / SYSEXIT instructions supportedCPU_FEATURE_PGEβ Page global enableCPU_FEATURE_MCAβ Machine check architectureCPU_FEATURE_CMOVβ CMOVxx instructions supportedCPU_FEATURE_PATβ Page attribute tableCPU_FEATURE_PSE36β 36-bit page address extensionCPU_FEATURE_PNβ Processor serial # implemented (Intel P3 only)CPU_FEATURE_CLFLUSHβ theCLFLUSHinstruction is in the house β¨CPU_FEATURE_DTSβ debug store? supported πCPU_FEATURE_ACPIβ ACPI support, aka the power-states girlies πCPU_FEATURE_MMXβ MMX instruction set, supported fr frCPU_FEATURE_FXSRβFXSAVE/FXRSTORare supported, slay πCPU_FEATURE_SSEβ Streaming-SIMD Extensions (SSE), supported π¦CPU_FEATURE_SSE2βSSE2instructions, supported, no capCPU_FEATURE_SSβ self-snoop, iconicCPU_FEATURE_HTβ hyper-threading is supported (tho it might be disabled, so don't come for me π)CPU_FEATURE_TMβ thermal monitor, keeping things chill πΈCPU_FEATURE_IA64β IA64 supported (Itanium only, our niche queen π)CPU_FEATURE_PBEβ pending-break enableCPU_FEATURE_PNIβ PNI (SSE3) instructions, supported β¨CPU_FEATURE_PCLMULβ thePCLMULQDQinstruction, supported πCPU_FEATURE_DTS64β 64-bit debug store, supportedCPU_FEATURE_MONITORβMONITOR/MWAIT, supported πCPU_FEATURE_DS_CPLβ CPL qualified debug storeCPU_FEATURE_VMXβ virtualization technology, supported π₯CPU_FEATURE_SMXβ safer mode exceptionsCPU_FEATURE_ESTβ Enhanced SpeedStepCPU_FEATURE_TM2β thermal monitor 2, the sequel πCPU_FEATURE_SSSE3β SSSE3 instructions supported β and bestie, this is different from SSE3, do not confuse them, I'm begging πCPU_FEATURE_CIDβ context ID, supportedCPU_FEATURE_CX16β theCMPXCHG16Binstruction, supported βCPU_FEATURE_XTPRβ send Task Priority Messages disableCPU_FEATURE_PDCMβ performance capabilities MSR, supportedCPU_FEATURE_DCAβ direct cache access, supported π¦CPU_FEATURE_SSE4_1β SSE 4.1 instructions, supported β¨CPU_FEATURE_SSE4_2β SSE 4.2 instructions, supported β¨CPU_FEATURE_SYSCALLβSYSCALL/SYSRETinstructions, supported πCPU_FEATURE_XDβ execute disable bit, supportedCPU_FEATURE_MOVBEβ theMOVBEinstruction, supportedCPU_FEATURE_POPCNTβ thePOPCNTinstruction, supported, we love a count πCPU_FEATURE_AESβAES*instructions, supported πβ¨CPU_FEATURE_XSAVEβXSAVE/XRSTOR/etc instructions, supported πCPU_FEATURE_OSXSAVEβ a non-privileged copy ofOSXSAVE, supportedCPU_FEATURE_AVXβ advanced vector extensions, supported π₯CPU_FEATURE_MMXEXTβ AMD MMX-extended instructions, supported πCPU_FEATURE_3DNOWβ AMD 3DNow! instructions, supported (the exclamation mark is doing so much π)CPU_FEATURE_3DNOWEXTβ AMD 3DNow! extended instructions, supportedCPU_FEATURE_NXβ no-execute bit, supportedCPU_FEATURE_FXSR_OPTβ FFXSR:FXSAVEandFXRSTORoptimizations β¨CPU_FEATURE_RDTSCPβ theRDTSCPinstruction, supported (AMD-only, exclusive behavior π )CPU_FEATURE_LMβ long mode (x86_64/EM64T), supported πCPU_FEATURE_LAHF_LMβLAHF/SAHFsupported in 64-bit modeCPU_FEATURE_CMP_LEGACYβ core multi-processing legacy modeCPU_FEATURE_SVMβ AMD Secure virtual machine πCPU_FEATURE_ABMβLZCNTinstruction supportCPU_FEATURE_MISALIGNSSEβ misaligned SSE, supportedCPU_FEATURE_SSE4Aβ SSE 4a, straight from AMD πCPU_FEATURE_3DNOWPREFETCHβPREFETCH/PREFETCHWsupport, manifesting ahead of time β¨CPU_FEATURE_OSVWβ OS Visible Workaround (AMD)CPU_FEATURE_IBSβ instruction-based samplingCPU_FEATURE_SSE5β SSE 5 instructions supported β deprecated, and heads up, this will never be 1 π periodtCPU_FEATURE_SKINITβSKINIT/STGI, supportedCPU_FEATURE_WDTβ watchdog timer support πΆCPU_FEATURE_TSβ temperature sensor π‘οΈCPU_FEATURE_FIDβ frequency ID controlCPU_FEATURE_VIDβ voltage ID controlCPU_FEATURE_TTPβTHERMTRIPCPU_FEATURE_TM_AMDβ AMD-specified hardware thermal controlCPU_FEATURE_STCβ software thermal controlCPU_FEATURE_100MHZSTEPSβ 100 MHz multiplier controlCPU_FEATURE_HWPSTATEβ hardware P-state control πCPU_FEATURE_CONSTANT_TSCβ TSC ticks at a constant rate, steady as ever β¨CPU_FEATURE_XOPβ the XOP instruction set (it's the same as the oldCPU_FEATURE_SSE5, glow-up era π )CPU_FEATURE_FMA3β the FMA3 instruction setCPU_FEATURE_FMA4β the FMA4 instruction setCPU_FEATURE_TBMβ trailing bit manipulation instruction supportCPU_FEATURE_F16Cβ 16-bit FP convert instruction supportCPU_FEATURE_RDRANDβ the RdRand instruction π²CPU_FEATURE_X2APICβ x2APIC,APIC_BASE.EXTD, MSRs0000_0800h...0000_0BFFh64-bit ICR (+030hbut not+031h), no DFR (+00Eh),SELF_IPI(+040h) β also see standard level0000_000BhπCPU_FEATURE_CPBβ core performance boost πCPU_FEATURE_APERFMPERFβMPERF/APERFMSRs supportCPU_FEATURE_PFIβ processor Feedback Interface supportCPU_FEATURE_PAβ processor accumulatorCPU_FEATURE_AVX2β AVX2 instructions π₯CPU_FEATURE_BMI1β BMI1 instructionsCPU_FEATURE_BMI2β BMI2 instructionsCPU_FEATURE_HLEβ hardware Lock Elision prefixesCPU_FEATURE_RTMβ restricted Transactional Memory instructionsCPU_FEATURE_AVX512Fβ AVX-512 Foundation, the base of the 512 era πCPU_FEATURE_AVX512DQβ AVX-512 Double/Quad granular insnsCPU_FEATURE_AVX512PFβ AVX-512 Prefetch β¨CPU_FEATURE_AVX512ERβ AVX-512 Exponential/ReciprocalCPU_FEATURE_AVX512CDβ AVX-512 Conflict detectionCPU_FEATURE_SHA_NIβ SHA-1/SHA-256 instructions πCPU_FEATURE_AVX512BWβ AVX-512 Byte/Word granular insnsCPU_FEATURE_AVX512VLβ AVX-512 128/256 vector length extensionsCPU_FEATURE_SGXβ SGX extensions. Heads up: this one is non-autoritative (their spelling bestie, not mine π) β go checkcpu_id_t::sgx::presentto verify presence, fr frCPU_FEATURE_RDSEEDβ theRDSEEDinstruction π±CPU_FEATURE_ADXβ ADX extensions (arbitrary precision)CPU_FEATURE_AVX512VNNIβ AVX-512 Vector Neural Network Instructions π§ β¨CPU_FEATURE_AVX512VBMIβ AVX-512 Vector Bit ManipulationInstructions (version 1) πCPU_FEATURE_AVX512VBMI2β AVX-512 Vector Bit ManipulationInstructions (version 2)CPU_FEATURE_HYPERVISORβ hypervisor present (and it is always zero on physical CPUs, so if you see a 1, you're in someone's guest house π )CPU_FEATURE_SWAPβ ARM: Swap instructions in the ARM instruction setCPU_FEATURE_THUMBβ ARM: Thumb instruction set support πCPU_FEATURE_ADVMULTUβ ARM: Advanced unsigned Multiply instructionsCPU_FEATURE_ADVMULTSβ ARM: Advanced signed Multiply instructionsCPU_FEATURE_JAZELLEβ ARM: Jazelle extension support β¨CPU_FEATURE_DEBUGV6β ARM: support for v6 Debug architectureCPU_FEATURE_DEBUGV6P1β ARM: support for v6.1 Debug architectureCPU_FEATURE_THUMB2β ARM: Thumb-2, instruction set supportCPU_FEATURE_DEBUGV7β ARM: support for v7 Debug architectureCPU_FEATURE_DEBUGV7P1β ARM: support for v7.1 Debug architectureCPU_FEATURE_THUMBEEβ ARM: ThumbEE instruction set supportCPU_FEATURE_DIVIDEβ ARM: Divide instructions βCPU_FEATURE_LPAEβ ARM: Large Physical Address ExtensionCPU_FEATURE_PMUV1β ARM: PMU extension version 1CPU_FEATURE_PMUV2β ARM: PMU extension version 2CPU_FEATURE_ASID16β ARM: 16 bit ASIDCPU_FEATURE_ADVSIMDβ ARM: Advanced SIMD ExtensionCPU_FEATURE_CRC32β ARM: CRC32 instructionsCPU_FEATURE_CSV2_1P1β ARM: Cache Speculation Variant 2CPU_FEATURE_CSV2_1P2β ARM: Cache Speculation Variant 2 version 1.2CPU_FEATURE_CSV2_2β ARM: Cache Speculation Variant 2 version 2CPU_FEATURE_CSV2_3β ARM: Cache Speculation Variant 2 version 3CPU_FEATURE_DOUBLELOCKβ ARM: Double Lock πCPU_FEATURE_ETS2β ARM: Enhanced Translation SynchronizationCPU_FEATURE_FPβ ARM: Floating Point extensionsCPU_FEATURE_MIXEDENDβ ARM: Mixed-endian supportCPU_FEATURE_MIXEDENDEL0β ARM: Mixed-endian support at EL0CPU_FEATURE_PMULLβ ARM: Advanced SIMD PMULL instructionsCPU_FEATURE_PMUV3β ARM: PMU extension version 3CPU_FEATURE_SHA1β ARM: Advanced SIMD SHA1 instructionsCPU_FEATURE_SHA256β ARM: Advanced SIMD SHA256 instructionsCPU_FEATURE_NTLBPAβ ARM: Intermediate caching of translation table walksCPU_FEATURE_HAFDBSβ ARM: Hardware management of the Access flag and dirty stateCPU_FEATURE_HPDSβ ARM: Hierarchical permission disables in translations tablesCPU_FEATURE_LORβ ARM: Limited ordering regionsCPU_FEATURE_LSEβ ARM: Large System ExtensionsCPU_FEATURE_PANβ ARM: Privileged access neverCPU_FEATURE_PMUV3P1β ARM: Armv8.1 PMU extensionsCPU_FEATURE_RDMβ ARM: Advanced SIMD rounding double multiply accumulate instructionsCPU_FEATURE_VHEβ ARM: Virtualization Host ExtensionsCPU_FEATURE_VMID16β ARM: 16-bit VMIDCPU_FEATURE_AA32HPDβ ARM: AArch32 Hierarchical permission disablesCPU_FEATURE_AA32I8MMβ ARM: AArch32 Int8 matrix multiplication instructionsCPU_FEATURE_DPBβ ARM:DC CVAPinstructionCPU_FEATURE_DEBUGV8P2β ARM: Debug v8.2CPU_FEATURE_F32MMβ ARM: Single-precision Matrix MultiplicationCPU_FEATURE_F64MMβ ARM: Double-precision Matrix MultiplicationCPU_FEATURE_FP16β ARM: Half-precision floating-point data processingCPU_FEATURE_HPDS2β ARM: Hierarchical permission disablesCPU_FEATURE_I8MMβ ARM: AArch64 Int8 matrix multiplication instructionsCPU_FEATURE_IESBβ ARM: Implicit Error Synchronization eventCPU_FEATURE_LPAβ ARM: Large PA and IPA supportCPU_FEATURE_LSMAOCβ ARM: AArch32 Load/Store Multiple instruction atomicity and ordering controlsCPU_FEATURE_LVAβ ARM: Large VA supportCPU_FEATURE_PAN2β ARM:AT S1E1RandAT S1E1Winstruction variants affected byPSTATE.PANCPU_FEATURE_RASβ ARM: Reliability, Availability and Serviceability (RAS) Extension β¨CPU_FEATURE_SHA3β ARM: Advanced SIMD SHA3 instructionsCPU_FEATURE_SHA512β ARM: Advanced SIMD SHA512 instructionsCPU_FEATURE_SM3β ARM: Advanced SIMD SM3 instructionsCPU_FEATURE_SM4β ARM: Advanced SIMD SM4 instructionsCPU_FEATURE_SPEβ ARM: Statistical Profiling ExtensionCPU_FEATURE_SVEβ ARM: Scalable Vector Extension π
okay that's the whole flag lineup bestie, every last one of them, and yeah there are a LOT π more coming in the next part, don't go anywhere π«Ά
CPU_FEATURE_TTCNPβ ARM: Translation table Common not private translations πCPU_FEATURE_UAOβ ARM: Unprivileged Access Override controlCPU_FEATURE_XNXβ ARM: Translation table stage 2 Unprivileged Execute-neverCPU_FEATURE_CCIDXβ ARM: Extended cache index πCPU_FEATURE_CONSTPACFIELDβ ARM: PAC algorithm enhancementCPU_FEATURE_EPACβ ARM: Enhanced pointer authenticationCPU_FEATURE_FCMAβ ARM: Floating-point complex number instructions β¨CPU_FEATURE_FPACβ ARM: Faulting on AUT* instructionsCPU_FEATURE_FPACCOMBINEβ ARM: Faulting on combined pointer authentication instructionsCPU_FEATURE_JSCVTβ ARM: JavaScript conversion instructions π¦CPU_FEATURE_LRCPCβ ARM: Load-Acquire RCpc instructionsCPU_FEATURE_PACIMPβ ARM: Pointer authentication - IMPLEMENTATION DEFINED algorithmCPU_FEATURE_PACQARMA3β ARM: Pointer authentication - QARMA3 algorithmCPU_FEATURE_PACQARMA5β ARM: Pointer authentication - QARMA5 algorithmCPU_FEATURE_PAUTHβ ARM: Pointer authentication πCPU_FEATURE_SPEV1P1β ARM: Statistical Profiling Extension version 1CPU_FEATURE_AMUV1β ARM: Activity Monitors Extension version 1CPU_FEATURE_BBMβ ARM: Translation table break-before-make levelsCPU_FEATURE_DITβ ARM: Data Independent Timing instructionsCPU_FEATURE_DEBUGV8P4β ARM: Debug v8.4CPU_FEATURE_DOTPRODβ ARM: Advanced SIMD dot product instructions πCPU_FEATURE_DOUBLEFAULTβ ARM: Double Fault ExtensionCPU_FEATURE_FHMβ ARM: Floating-point half-precision to single-precision multiply-add instructionsCPU_FEATURE_FLAGMβ ARM: Condition flag manipulation instructionsCPU_FEATURE_IDSTβ ARM: ID space trap handlingCPU_FEATURE_LRCPC2β ARM: Load-Acquire RCpc instructions version 2CPU_FEATURE_LSE2β ARM: Large System Extensions version 2CPU_FEATURE_MPAMβ ARM: Memory Partitioning and Monitoring ExtensionCPU_FEATURE_PMUV3P4β ARM: Arm8.4 PMU extensionsCPU_FEATURE_RASV1P1β ARM: RAS extension v1.1CPU_FEATURE_S2FWBβ ARM: Stage 2 forced Write-BackCPU_FEATURE_SEL2β ARM: Secure EL2CPU_FEATURE_TLBIOSβ ARM: TLB invalidate instructions in Outer Shareable domainCPU_FEATURE_TLBIRANGEβ ARM: TLB invalidate range instructionsCPU_FEATURE_TRFβ ARM: Self-hosted Trace extensionsCPU_FEATURE_TTLβ ARM: Translation Table LevelCPU_FEATURE_TTSTβ ARM: Small translation tablesCPU_FEATURE_BTIβ ARM: Branch Target IdentificationCPU_FEATURE_CSV2β ARM: Cache Speculation Variant 2CPU_FEATURE_CSV3β ARM: Cache Speculation Variant 3CPU_FEATURE_DPB2β ARM: DC CVADP instructionCPU_FEATURE_E0PDβ ARM: Preventing EL0 access to halves of address mapsCPU_FEATURE_EVTβ ARM: Enhanced Virtualization TrapsCPU_FEATURE_EXSβ ARM: Context synchronization and exception handlingCPU_FEATURE_FRINTTSβ ARM: Floating-point to integer instructionsCPU_FEATURE_FLAGM2β ARM: Enhancements to flag manipulation instructionsCPU_FEATURE_MTEβ ARM: Memory Tagging Extension π·οΈCPU_FEATURE_MTE2β ARM: Memory Tagging ExtensionCPU_FEATURE_PMUV3P5β ARM: Arm8.5 PMU extensionsCPU_FEATURE_RNGβ ARM: Random number generator π²CPU_FEATURE_RNG_TRAPβ ARM: Trapping support for RNDR/RNDRRSCPU_FEATURE_SBβ ARM: Speculation BarrierCPU_FEATURE_SPECRESβ ARM: Speculation restriction instructionsCPU_FEATURE_SSBSβ ARM: Speculative Store Bypass SafeCPU_FEATURE_SSBS2β ARM: MRS and MSR instructions for SSBS version 2CPU_FEATURE_AA32BF16β ARM: AArch32 BFloat16 instructionsCPU_FEATURE_AMUV1P1β ARM: Activity Monitors Extension version 1.1CPU_FEATURE_BF16β ARM: AArch64 BFloat16 instructionsCPU_FEATURE_DGHβ ARM: Data Gathering HintCPU_FEATURE_ECVβ ARM: Enhanced Counter VirtualizationCPU_FEATURE_FGTβ ARM: Fine Grain TrapsCPU_FEATURE_HPMN0β ARM: Setting of MDCR_EL2.HPMN to zeroCPU_FEATURE_MPAMV0P1β ARM: Memory Partitioning and Monitoring extension version 0.1CPU_FEATURE_MPAMV1P1β ARM: Memory Partitioning and Monitoring extension version 1.1CPU_FEATURE_MTPMUβ ARM: Multi-threaded PMU extensionsCPU_FEATURE_PAUTH2β ARM: Enhancements to pointer authenticationCPU_FEATURE_TWEDβ ARM: Delayed Trapping of WFECPU_FEATURE_AFPβ ARM: Alternate floating-point behaviorCPU_FEATURE_EBF16β ARM: AArch64 Extended BFloat16 behaviorsCPU_FEATURE_HCXβ ARM: Support for the HCRX_EL2 registerCPU_FEATURE_LPA2β ARM: Larger physical address for 4KB and 16KB translation granulesCPU_FEATURE_LS64β ARM: Support for 64-byte loads and stores without statusCPU_FEATURE_LS64_ACCDATAβ ARM: Support for 64-byte EL0 stores with statusCPU_FEATURE_LS64_Vβ ARM: Support for 64-byte stores with statusCPU_FEATURE_MTE3β ARM: MTE Asymmetric Fault HandlingCPU_FEATURE_MTE_ASYM_FAULTβ ARM: Memory tagging asymmetric faultsCPU_FEATURE_PAN3β ARM: Support for SCTLR_ELx.EPANCPU_FEATURE_PMUV3P7β ARM: Armv8.7 PMU extensionsCPU_FEATURE_RPRESβ ARM: Increased precision of FRECPE and FRSQRTECPU_FEATURE_SPEV1P2β ARM: Statistical Profiling Extensions version 1.2CPU_FEATURE_WFXTβ ARM: WFE and WFI instructions with timeout β°CPU_FEATURE_XSβ ARM: XS attributeCPU_FEATURE_CMOWβ ARM: Control for cache maintenance permissionCPU_FEATURE_DEBUGV8P8β ARM: Debug v8.8CPU_FEATURE_HBCβ ARM: Hinted conditional branchesCPU_FEATURE_MOPSβ ARM: Standardization of memory operationsCPU_FEATURE_NMIβ ARM: Non-maskable InterruptsCPU_FEATURE_PMUV3P8β ARM: Armv8.8 PMU extensionsCPU_FEATURE_SCTLR2β ARM: Extension to SCTLR_ELxCPU_FEATURE_SPEV1P3β ARM: Statistical Profiling Extensions version 1.3CPU_FEATURE_TCR2β ARM: Support for TCR2_ELxCPU_FEATURE_TIDCP1β ARM: EL0 use of IMPLEMENTATION DEFINED functionalityCPU_FEATURE_ADERRβ ARM: Asynchronous Device Error ExceptionsCPU_FEATURE_AIEβ ARM: Memory Attribute Index EnhancementCPU_FEATURE_ANERRβ ARM: Asynchronous Normal Error ExceptionsCPU_FEATURE_ATS1Aβ ARM: Address Translation operations that ignore stage 1 permissionsCPU_FEATURE_CLRBHBβ ARM: Support for Clear Branch History instructionCPU_FEATURE_CSSCβ ARM: Common Short Sequence Compression instructions ποΈCPU_FEATURE_DEBUGV8P9β ARM: Debug v8.9CPU_FEATURE_DOUBLEFAULT2β ARM: Double Fault Extension v2CPU_FEATURE_ECBHBβ ARM: Exploitative control using branch history informationCPU_FEATURE_FGT2β ARM: Fine-grained traps 2CPU_FEATURE_HAFTβ ARM: Hardware managed Access Flag for Table descriptorsCPU_FEATURE_LRCPC3β ARM: Load-Acquire RCpc instructions version 3CPU_FEATURE_MTE4β ARM: Enhanced Memory Tagging ExtensionCPU_FEATURE_MTE_ASYNCβ ARM: Asynchronous reporting of Tag Check FaultCPU_FEATURE_MTE_CANONICAL_TAGSβ ARM: Canonical Tag checking for Untagged memoryCPU_FEATURE_MTE_NO_ADDRESS_TAGSβ ARM: Memory tagging with Address tagging disabledCPU_FEATURE_MTE_PERMβ ARM: Allocation tag access permissionCPU_FEATURE_MTE_STORE_ONLYβ ARM: Store-only Tag CheckingCPU_FEATURE_MTE_TAGGED_FARβ ARM: FAR_ELx on a Tag Check FaultCPU_FEATURE_PFARβ ARM: Physical Fault Address Register ExtensionCPU_FEATURE_PMUV3_ICNTRβ ARM: Fixed-function instruction counterCPU_FEATURE_PMUV3_SSβ ARM: PMU Snapshot extensionCPU_FEATURE_PMUV3P9β ARM: Armv8.9 PMU extensionsCPU_FEATURE_PRFMSLCβ ARM: SLC target support for PRFM instructionsCPU_FEATURE_RASV2β ARM: RAS Extension v2CPU_FEATURE_RPRFMβ ARM: Support for Range Prefetch Memory instructionCPU_FEATURE_S1PIEβ ARM: Stage 1 permission indirectionsCPU_FEATURE_S1POEβ ARM: Stage 1 permission overlaysCPU_FEATURE_S2PIEβ ARM: Stage 2 permission indirectionsCPU_FEATURE_S2POEβ ARM: Stage 2 permission overlaysCPU_FEATURE_SPECRES2β ARM: Enhanced speculation restriction instructionsCPU_FEATURE_SPE_DPFZSβ ARM: Disable Cycle Counter on SPE FreezeCPU_FEATURE_SPEV1P4β ARM: Statistical Profiling Extension version 1.4CPU_FEATURE_SPMUβ ARM: System Performance Monitors ExtensionCPU_FEATURE_THEβ ARM: Translation Hardening ExtensionCPU_FEATURE_SVE2β ARM: Scalable Vector Extension version 2 πCPU_FEATURE_SVE_AESβ ARM: Scalable Vector AES instructionsCPU_FEATURE_SVE_BITPERMβ ARM: Scalable Vector Bit Permutes instructionsCPU_FEATURE_SVE_PMULL128β ARM: SVE single-vector Advanced Encryption Standard and 128-bit polynomial multiply long instructionsCPU_FEATURE_SVE_SHA3β ARM: Scalable Vector SHA3 instructionsCPU_FEATURE_SVE_SM4β ARM: Scalable Vector SM4 instructionsCPU_FEATURE_TMEβ ARM: Transactional Memory ExtensionCPU_FEATURE_TRBEβ ARM: Trace Buffer ExtensionCPU_FEATURE_BRBEβ ARM: Branch Record Buffer ExtensionCPU_FEATURE_RMEβ ARM: Realm Management ExtensionCPU_FEATURE_SMEβ ARM: Scalable Matrix ExtensionCPU_FEATURE_SME_F64F64β ARM: Double-precision floating-point outer product instructionsCPU_FEATURE_SME_FA64β ARM: Full A64 instruction set support in Streaming SVE modeCPU_FEATURE_SME_I16I64β ARM: 16-bit to 64-bit integer widening outer product instructionsCPU_FEATURE_BRBEV1P1β ARM: Branch Record Buffer Extension version 1.1CPU_FEATURE_MECβ ARM: Memory Encryption ContextsCPU_FEATURE_SME2β ARM: Scalable Matrix Extensions version 2CPU_FEATURE_ABLEβ ARM: Address Breakpoint Linking ExtensionCPU_FEATURE_BWEβ ARM: Breakpoint and watchpoint enhancements πCPU_FEATURE_D128β ARM: 128-bit Translation Tables, 56 bit PACPU_FEATURE_EBEPβ ARM: Exception-based Event ProfilingCPU_FEATURE_GCSβ ARM: Guarded Control Stack ExtensionCPU_FEATURE_ITEβ ARM: Instrumentation Trace ExtensionCPU_FEATURE_LSE128β ARM: 128-bit AtomicsCPU_FEATURE_LVA3β ARM: 56-bit VACPU_FEATURE_SEBEPβ ARM: Synchronous Exception-based Event ProfilingCPU_FEATURE_SME2P1β ARM: Scalable Matrix Extension version 2.1CPU_FEATURE_SME_F16F16β ARM: Non-widening half-precision FP16 to FP16 arithmetic for SME2CPU_FEATURE_SVE2P1β ARM: Scalable Vector Extensions version 2.1CPU_FEATURE_SVE_B16B16β ARM: Non-widening BFloat16 to BFloat16 arithmetic for SVE2 and SME2CPU_FEATURE_SYSINSTR128β ARM: 128-bit System instructionsCPU_FEATURE_SYSREG128β ARM: 128-bit System registersCPU_FEATURE_TRBE_EXTβ ARM: Trace Buffer external modeCPU_FEATURE_ASID2β ARM: Support for concurrent use of two ASIDsCPU_FEATURE_BWE2β ARM: Breakpoint and watchpoint enhancements 2CPU_FEATURE_CPAβ ARM: Instruction-only Checked Pointer ArithmeticCPU_FEATURE_CPA2β ARM: Checked Pointer ArithmeticCPU_FEATURE_E2H0β ARM: Programming ofHCR_EL2.E2H.CPU_FEATURE_E3DSEβ ARM: Delegated SError exception injectionCPU_FEATURE_ETS3β ARM: Enhanced Translation SynchronizationCPU_FEATURE_FAMINMAXβ ARM: Floating-point maximum and minimum absolute value instructionsCPU_FEATURE_FGWTE3β ARM: Fine-Grained Write Trap EL3CPU_FEATURE_FP8β ARM: FP8 convert instructionsCPU_FEATURE_FP8DOT2β ARM: FP8 2-way dot product to half-precision instructionsCPU_FEATURE_FP8DOT4β ARM: FP8 4-way dot product to single-precision instructionsCPU_FEATURE_FP8FMAβ ARM: FP8 multiply-accumulate to half-precision and single-precision instructionsCPU_FEATURE_FPMRβ ARM: Floating-point Mode RegisterCPU_FEATURE_HACDBSβ ARM: Hardware accelerator for cleaning Dirty stateCPU_FEATURE_HDBSSβ ARM: Hardware Dirty state tracking structureCPU_FEATURE_LUTβ ARM: Lookup table instructions with 2-bit and 4-bit indicesCPU_FEATURE_PAUTH_LRβ ARM: Pointer authentication instructions that allow signing of LR using SP and PC as diversifiersCPU_FEATURE_RME_GPC2β ARM: RME Granule Protection Check 2 ExtensionCPU_FEATURE_SME_F8F16β ARM: SME2 ZA-targeting FP8 multiply-accumulate, dot product, and outer product to half-precision instructionsCPU_FEATURE_SME_F8F32β ARM: SME2 ZA-targeting FP8 multiply-accumulate, dot product, and outer product to single-precision instructionsCPU_FEATURE_SME_LUTV2β ARM: Lookup table instructions with 4-bit indices and 8-bit elementsCPU_FEATURE_SPMU2β ARM: System Performance Monitors Extension version 2CPU_FEATURE_SSVE_FP8DOT2β ARM: SVE FP8 2-way dot product to half-precision instructions in Streaming SVE modeCPU_FEATURE_SSVE_FP8DOT4β ARM: SVE2 FP8 4-way dot product to single-precision instructions in Streaming SVE modeCPU_FEATURE_SSVE_FP8FMAβ ARM: SVE2 FP8 multiply-accumulate to half-precision and single-precision instructions in Streaming SVE modeCPU_FEATURE_STEP2β ARM: Enhanced Software Step ExtensionCPU_FEATURE_TLBIWβ ARM: TLBI VMALL for Dirty state
πΈ enum cpu_hint_t πΈ
CPU detection hints identifiers. Usage: similar to the flags usage
Enumerator
CPU_HINT_SSE_SIZE_AUTHβ SSE unit size is authoritative (not only a Family/Model guesswork, but based on an actual CPUID bit)
π enum cpu_msrinfo_request_t π
Enumerator
INFO_MPERFβ Maximum performance frequency clock. This is a counter, which increments as a proportion of the actual processor speed.INFO_APERFβ Actual performance frequency clock. This accumulates the core clock counts when the core is active.INFO_MIN_MULTIPLIERβ Minimum CPU:FSB ratio for this CPU, multiplied by 100.INFO_CUR_MULTIPLIERβ Current CPU:FSB ratio, multiplied by 100. e.g., a CPU:FSB value of 18.5 reads as "1850".INFO_MAX_MULTIPLIERβ Maximum CPU:FSB ratio for this CPU, multiplied by 100.INFO_TEMPERATUREβ The current core temperature in Celsius.INFO_THROTTLINGβ 1 if the current logical processor is throttling. 0 if it is running normally.INFO_VOLTAGEβ The current core voltage in Volt, multiplied by 100.INFO_BCLKβ SeeINFO_BUS_CLOCK.INFO_BUS_CLOCKβ The main bus clock in MHz, e.g., FSB/QPI/DMI/HT base clock, multiplied by 100.
π¦ enum cpu_purpose_t π¦
CPU purpose.
Enumerator
PURPOSE_GENERALβ general purpose CPUPURPOSE_PERFORMANCEβ performance CPUPURPOSE_EFFICIENCYβ efficiency CPUPURPOSE_LP_EFFICIENCYβ low-power efficiency CPUPURPOSE_U_PERFORMANCEβ ultimate performance CPUNUM_CPU_PURPOSESβ Valid CPU purpose ids:0..NUM_CPU_PURPOSES - 1
π enum cpu_sgx_feature_t π
SGX features flags.
See also
cpu_sgx_t
Usage:
...
struct cpu_raw_data_t raw;
struct cpu_id_t id;
if (cpuid_get_raw_data(&raw) == 0 && cpu_identify(&raw, &id) == 0 && id.sgx.present) {
if (id.sgx.flags[INTEL_SGX1])
// The CPU has SGX1 instructions support...
...
} else {
// no SGX
}
} else {
// processor cannot be determined.
}
Enumerator
INTEL_SGX1β SGX1 instructions supportINTEL_SGX2β SGX2 instructions support
π₯ enum cpu_vendor_t π₯
CPU vendor, as guessed from the Vendor String.
Enumerator
VENDOR_INTELβ Intel CPUVENDOR_AMDβ AMD CPUVENDOR_CYRIXβ Cyrix CPUVENDOR_NEXGENβ NexGen CPUVENDOR_TRANSMETAβ Transmeta CPUVENDOR_UMCβ x86 CPU by UMCVENDOR_CENTAURβ x86 CPU by IDTVENDOR_RISEβ x86 CPU by Rise TechnologyVENDOR_SISβ x86 CPU by SiSVENDOR_NSCβ x86 CPU by National SemiconductorVENDOR_HYGONβ Hygon CPUVENDOR_ARMβ ARM CPUVENDOR_BROADCOMβ Broadcom Corporation CPUVENDOR_CAVIUMβ Cavium Inc. CPUVENDOR_DECβ Digital Equipment Corporation CPUVENDOR_FUJITSUβ Fujitsu Ltd. CPUVENDOR_HISILICONβ HiSilicon Technology Co., Ltd. CPUVENDOR_INFINEONβ Infineon Technologies AG CPUVENDOR_FREESCALEβ Motorola or Freescale Semiconductor Inc. CPUVENDOR_NVIDIAβ NVIDIA Corporation CPUVENDOR_APMβ Applied Micro Circuits Corporation CPUVENDOR_QUALCOMMβ Qualcomm Inc. CPUVENDOR_SAMSUNGβ Samsung Group CPUVENDOR_MARVELLβ Marvell International Ltd. CPUVENDOR_APPLEβ Apple Inc. CPUVENDOR_FARADAYβ Faraday Technology CPUVENDOR_MICROSOFTβ Microsoft Corporation CPUVENDOR_PHYTIUMβ Phytium Technology Co., Ltd CPUVENDOR_AMPEREβ Ampere Computing CPUNUM_CPU_VENDORSβ Valid CPU vendor ids:0..NUM_CPU_VENDORS - 1
π enum hypervisor_vendor_t π
Hypervisor vendor, as guessed from the CPU_FEATURE_HYPERVISOR flag.
Enumerator
HYPERVISOR_NONEβ no hypervisorHYPERVISOR_BHYVEβ FreeBSD bhyve hypervisorHYPERVISOR_HYPERVβ Microsoft Hyper-V or Windows Virtual PC hypervisorHYPERVISOR_KVMβ KVM hypervisorHYPERVISOR_PARALLELSβ Parallels hypervisorHYPERVISOR_QEMUβ QEMU hypervisorHYPERVISOR_VIRTUALBOXβ VirtualBox hypervisorHYPERVISOR_VMWAREβ VMware hypervisorHYPERVISOR_XENβ Xen hypervisorNUM_HYPERVISOR_VENDORSβ Valid hypervisor vendor ids:0..NUM_HYPERVISOR_VENDORS - 1
β¨ Function Documentation β¨
π char * affinity_mask_str (cpu_affinity_mask_t * affinity_mask) π
Returns textual representation of a CPU affinity mask.
Parameters
affinity_maskβ the affinity mask (in hexadecimal), whose textual representation is wanted.
Note
This function is not thread-safe π
Returns
a string like "0000FFFF", "00FF0000", etc.
π§ char * affinity_mask_str_r (cpu_affinity_mask_t * affinity_mask, char * buffer, uint32_t buffer_len) π§
Returns textual representation of a CPU affinity mask (thread-safe)
Parameters
affinity_maskβ Input β the affinity mask (in hexadecimal), whose textual representation is wanted.bufferβ Output β an allocated string where to store the textual representation, like"0000FFFF","00FF0000", etc.buffer_lenβ Input β the size of buffer.
Returns
a pointer on buffer
π const char * cpu_architecture_str (cpu_architecture_t architecture) π
Returns the short textual representation of a CPU architecture.
Parameters
architectureβ the architecture, whose textual representation is wanted.
Returns
a constant string like "x86", "ARM", etc.
π int cpu_clock (void ) π
Get the CPU clock frequency (all-in-one method). This is an all-in-one method for getting the CPU clock frequency. It tries to use the OS for that. If the OS doesn't have this info, it uses cpu_clock_measure with 200ms time interval and quadruple checking.
Returns
the CPU clock frequency in MHz. If every possible method fails, the result is -1.
π₯ int cpu_clock_by_ic (int millis, int runs) π₯
Measure the CPU clock frequency using instruction-counting.
Parameters
millisβ how much time to allocate for each run, in millisecondsrunsβ how many runs to perform
The function performs a busy-wait cycle using a known number of "heavy" (SSE) instructions. These instructions run at (more or less guaranteed) 1 IPC rate, so by running a busy loop for a fixed amount of time, and measuring the amount of instructions done, the CPU clock is accurately measured.
Of course, this function is still affected by the power-saving schemes, so the warnings as of cpu_clock_measure() still apply. However, this function is immune to problems with detection, related to the Intel Nehalem's "Turbo" mode, where the internal clock is raised, but the RDTSC rate is unaffected.
The function will run for about (millis * runs) milliseconds. You can make just a single busy-wait run (runs == 1), but bestieβ¦ task scheduling can show up uninvited and absolutely wreck your counting, so allowing more than one run is the recommended move. And since run length isn't imperative for accurate readings (like, 50ms is genuinely enough), you can totally afford a bunch of short runs β e.g. 10 runs of 50ms, or 20 runs of 25ms. β¨
Recommended values β millis = 50, runs = 4. Want more robustness? Just bump up the number of runs. π
NOTE: on Bulldozer and later CPUs, the busy-wait cycle runs at 1.4 IPC, so the results get skewed. This is corrected internally by dividing the resulting value by 1.4. BUT β this only happens if the thread is executed on a single CMT module. If there are other threads competing for resources, the results are unpredictable. Make sure you run cpu_clock_by_ic() on a CPU that is free from competing threads, or if there are such threads, they shouldn't exceed the number of modules. On a Bulldozer X8, that means 4 threads. π§
Returns β the CPU clock frequency in MHz (within some measurement error margin). If SSE is not supported, the result is -1. If the input parameters are incorrect, or some other internal fault is detected, the result is -2.
int cpu_clock_by_mark (struct cpu_mark_t * mark)
Calculates the CPU clock. π
Parameters
markβ pointer to acpu_mark_tstructure, which has been initialized withcpu_tsc_markand laterstoppedwithcpu_tsc_unmark.
Note
For reliable results, the marked time interval should be at least about 10 ms. β±οΈ
Returns β the CPU clock frequency, in MHz. Due to measurement error, it will differ from the true value in a few least-significant bits. Accuracy depends on the timing interval β the more, the better. If the timing interval is insufficient, the result is -1. Also, see the comment on cpu_clock_measure for additional issues and pitfalls in using RDTSC for CPU frequency measurements. π«Ά
int cpu_clock_by_os (void )
Returns the CPU clock, as reported by the OS. This function uses OS-specific functions to obtain the CPU clock. It may differ from the true clock for several reasons:
- i) The CPU might be in some power saving state, while the OS reports its full-power frequency, or vice-versa.
- ii) In some cases you can raise or lower the CPU frequency with overclocking utilities and the OS will not notice. π
Returns β the CPU clock frequency in MHz. If the OS is not (yet) supported or lacks the necessary reporting machinery, the return value is -1.
int cpu_clock_by_tsc (struct cpu_raw_data_t * raw)
Measure the CPU clock frequency using TSC frequency from CPUID. π
Parameters
rawβ Optional input β a pointer to the raw CPUID data, which is obtained either bycpuid_get_raw_dataorcpuid_deserialize_raw_data. Can also beNULL, in which case the functions callscpuid_get_raw_dataitself.
The function read Time Stamp Counter and Nominal Core Crystal Clock Information Leaf from CPUID. It determines the processor base frequency. π₯
NOTE: only x86 Intel CPUs since Skylake (6th generation of Intel Core processors) are supported. Other vendors do not support this feature. no cap, that's the whole list
Returns β the CPU clock frequency in MHz. If TSC frequency is not supported, the result is -1. If the input parameters are incorrect, or some other internal fault is detected, the result is -2.
int cpu_clock_measure (int millis, int quad_check)
Measure the CPU clock frequency. β¨
Parameters
millisβ How much time to waste in the busy-wait cycle. In millisecs. Useful values10-1000quad_checkβ Do a more thorough measurement if nonzero (see the explanation).
The function performs a busy-wait cycle for the given time and calculates the CPU frequency by the difference of the TSC values. The accuracy of the calculation depends on the length of the busy-wait cycle: more is better, but 100ms should be enough for most purposes.
While this will calculate the CPU frequency correctly in most cases, there are several reasons why it might be incorrect:
- i) RDTSC doesn't guarantee it will run at the same clock as the CPU. Apparently there aren't CPUs at the moment, but still, there's no guarantee.
- ii) The CPU might be in a low-frequency power saving mode, and the CPU might be switched to higher frequency at any time. If this happens during the measurement, the result can be anywhere between the low and high frequencies. Also, if you're interested in the high frequency value only, this function might return the low one instead.
- iii) On SMP systems exhibiting TSC drift (see
cpu_rdtsc)
the quad_check option will run four consecutive measurements and then return the average of the two most-consistent results. The total runtime of the function will still be millis β consider using a bit more time for the timing interval.
Finally, for benchmarking / CPU intensive applications, the best strategy is to use the cpu_tsc_mark() / cpu_tsc_unmark() / cpu_clock_by_mark() method. Begin by mark()-ing about one second after application startup (allowing the power-saving manager to kick in and rise the frequency during that time), then unmark() just before application finishing. The result will most acurately represent at what frequency your app was running. π―
Returns β the CPU clock frequency in MHz (within some measurement error margin). If RDTSC is not supported, the result is -1.
void cpu_exec_cpuid (uint32_t eax, uint32_t * regs)
Executes the CPUID instruction. π
Parameters
eaxβ the value of the EAX register when executing CPUIDregsβ the results will be stored here.regs[0] = EAX,regs[1] = EBX, ...
Note
CPUID will be executed with EAX set to the given value and EBX, ECX, EDX set to zero.
void cpu_exec_cpuid_ext (uint32_t * regs)
Executes the CPUID instruction with the given input registers. π¦
Note
This is just a bit more generic version of cpu_exec_cpuid β it allows you to control all the registers.
Parameters
regsβ Input/output. Prior to executing CPUID, EAX, EBX, ECX and EDX will be set toregs[0],regs[1],regs[2]andregs[3]. After CPUID, this array will contain the results.
const char * cpu_feature_level_str (cpu_feature_level_t level)
Returns the short textual representation of a CPU feature level. πΈ
Parameters
levelβ the feature level, whose textual representation is wanted.
Returns β a constant string like "ARMv8.0-A", "ARMv9.4-A", etc.
const char * cpu_feature_str (cpu_feature_t feature)
Returns the short textual representation of a CPU flag. β
Parameters
featureβ the feature, whose textual representation is wanted.
Returns β a constant string like "fpu", "tsc", "sse2", etc.
Note
the names of the returned flags are compatible with those from /proc/cpuinfo in Linux, with the exception of tm_amd π
int cpu_identify (struct cpu_raw_data_t * raw, struct cpu_id_t * data)
Identifies the CPU. π
Parameters
rawβ Input β a pointer to the raw CPUID data, which is obtained either bycpuid_get_raw_dataorcpuid_deserialize_raw_data. Can also beNULL, in which case the functions callscpuid_get_raw_dataitself.dataβ Output β the decoded CPU features/info is written here.
Note
The function will not fail, even if some of the information cannot be obtained. Even when the CPU is new and thus unknown to libcpuid, some generic info, such as "AMD K9 family CPU" will be written to data.cpu_codename, and most other things, such as the CPU flags, cache sizes, etc. should be detected correctly anyway. However, the function CAN fail, if the CPU is completely alien to libcpuid. π
While cpu_identify() and cpuid_get_raw_data() are fast for most purposes, running them several thousand times per second can hamper performance significantly. Specifically, avoid writing "cpu feature checker" wrapping function, which calls cpu_identify and returns the value of some flag, if that function is going to be called frequently. π
Returns β zero if successful, and some negative number on error. The error message can be obtained by calling cpuid_error.
See also β cpu_error_t
int cpu_identify_all (struct cpu_raw_data_array_t * raw_array, struct system_id_t * system)
Identifies all the CPUs. π
Parameters
raw_arrayβ Input β a pointer to the array of raw CPUID data, which is obtained either bycpuid_get_all_raw_dataorcpuid_deserialize_all_raw_data. Can also beNULL, in which case the functions callscpuid_get_all_raw_dataitself.systemβ Output β the decoded CPU features/info is written here for each CPU type.
Note
The function is similar to cpu_identify. Refer to cpu_identify notes.
As the memory is dynamically allocated, be sure to call cpuid_free_raw_data_array() and cpuid_free_system_id() after you're done with the data π«Ά
Returns β zero if successful, and some negative number on error. The error message can be obtained by calling cpuid_error.
See also β cpu_error_t
int cpu_msr_driver_close (struct msr_driver_t * handle)
Closes an open MSR driver. This function unloads the MSR driver opened by cpu_msr_driver_open and frees any resources associated with it. π§
Parameters
handleβ a handle to the MSR reader driver, as created bycpu_msr_driver_open
Returns β zero if successful, and some negative number on error. The error message can be obtained by calling cpuid_error.
See also β cpu_error_t
struct msr_driver_t * cpu_msr_driver_open (void )
Starts/opens a driver, needed to read MSRs (Model Specific Registers). On systems that support it, this function will create a temporary system driver, that has privileges to execute the RDMSR instruction. After the driver is created, you can read MSRs by calling cpu_rdmsr π₯
Returns β a handle to the driver on success, and NULL on error. The error message can be obtained by calling cpuid_error.
See also β cpu_error_t
struct msr_driver_t * cpu_msr_driver_open_core (unsigned core_num)
Similar to cpu_msr_driver_open, but accept one parameter. This function works on certain operating systems (GNU/Linux, FreeBSD) π
Parameters
core_numspecify the core number for MSR. The first core number is0. The last core number iscpuid_get_total_cpus - 1.
Returns β a handle to the driver on success, and NULL on error. The error message can be obtained by calling cpuid_error.
See also β cpu_error_t
int cpu_msrinfo (struct msr_driver_t * handle, cpu_msrinfo_request_t which)
okay bestie, this one reads extended CPU info straight outta the Model-Specific Registers β¨
Parameters
- handle β a handle to an open MSR driver,
See also
cpu_msr_driver_open
Parameters
- which β which info field should be returned. A list of available information entities is listed in the
cpu_msrinfo_request_tenum.
Return values
- if the requested information is available for the current processor model, the respective value is returned. if no information is available, or the CPU doesn't support the query, the special value
CPU_INVALID_VALUEis returned
Note
This function is not MT-safe. If you intend to call it from multiple threads, guard it through a mutex or a similar primitive. π«Ά
const char * cpu_purpose_str (cpu_purpose_t purpose)
Gives you the short textual glow-up of a CPU purpose π
Parameters
- purpose β the purpose, whose textual representation is wanted.
Returns
a constant string like "general", "performance", "efficiency", etc. π
int cpu_rdmsr (struct msr_driver_t * handle, uint32_t msr_index, uint64_t * result)
Reads a Model-Specific Register (MSR) π If the CPU has MSRs (as indicated by the CPU_FEATURE_MSR flag), you can read a MSR with the given index by calling this function.
There are several prerequisites you must do before reading MSRs: 1) You must ensure the CPU has RDMSR. Check the CPU_FEATURE_MSR flag in cpu_id_t::flags 2) You must ensure that the CPU implements the specific MSR you intend to read. 3) You must open a MSR-reader driver. RDMSR is a privileged instruction and needs ring-0 access in order to work. This temporary driver is created by calling cpu_msr_driver_open
Parameters
- handle β a handle to the MSR reader driver, as created by
cpu_msr_driver_open - msr_index β the numeric ID of the MSR you want to read
- result β a pointer to a 64-bit integer, where the MSR value is stored
Returns
zero if successful, and some negative number on error. The error message can be obtained by calling cpuid_error.
See also
cpu_error_t
int cpu_rdmsr_range (struct msr_driver_t * handle, uint32_t msr_index, uint8_t highbit, uint8_t lowbit, uint64_t * result)
Same energy as cpu_rdmsr, but it extracts a range of bits π¦
Parameters
- handle β a handle to the MSR reader driver, as created by
cpu_msr_driver_open - msr_index β the numeric ID of the MSR you want to read
- highbit β the high bit in range, must be inferior to 64
- lowbit β the low bit in range, must be equal or superior to 0
- result β a pointer to a 64-bit integer, where the MSR value is stored
Returns
zero if successful, and some negative number on error. The error message can be obtained by calling cpuid_error.
See also
cpu_error_t
void cpu_rdtsc (uint64_t * result)
Executes RDTSC β¨ The RDTSC (ReaD Time Stamp Counter) instruction gives access to an internal 64-bit counter, which usually increments at each clock cycle. This can be used for various timing routines, and as a very precise clock source. It is set to zero on system startup. Beware that may not increment at the same frequency as the CPU. Consecutive calls of RDTSC are, however, guaranteed to return monotonically-increasing values. π
Parameters
- result β a pointer to a 64-bit unsigned integer, where the TSC value will be stored
Note
If 100% compatibility is a concern, you must first check if the RDTSC instruction is present (if it is not, your program will crash with"invalid opcode"exception). Only some very old processors (i486, early AMD K5 and some Cyrix CPUs) lack that instruction β they should have become exceedingly rare these days. To verify RDTSC presence, runcpu_identify()and checkflags[CPU_FEATURE_TSC]. π
The monotonically increasing nature of the TSC may be violated on SMP systems, if their TSC clocks run at different rate. If the OS doesn't account for that, the TSC drift may become arbitrary large. π
int cpu_request_core_type (cpu_purpose_t purpose, struct cpu_raw_data_array_t * raw_array, struct cpu_id_t * data)
Identifies a given CPU type πΈ
Parameters
- purpose β Input - a
cpu_purpose_tto request - raw_array β Optional input - a pointer to the array of raw CPUID data, which is obtained either by
cpuid_get_all_raw_dataorcpuid_deserialize_all_raw_data. Can also beNULL, in which case the functions callscpuid_get_all_raw_dataitself. - data β Output - the decoded CPU features/info is written here.
Returns
zero if successful, and some negative number on error (like ERR_NOT_FOUND if CPU type not found). The error message can be obtained by calling cpuid_error.
See also
cpu_error_t
void cpu_tsc_mark (struct cpu_mark_t * mark)
Store TSC and timing info π This function stores the current TSC value and current time info from a precise OS-specific clock source in the cpu_mark_t structure. The sys_clock field contains time with microsecond resolution. The values can later be used to measure time intervals, number of clocks, FPU frequency, etc. β¨
See also
cpu_rdtsc
Parameters
- mark [out] β a pointer to a
cpu_mark_tstructure
void cpu_tsc_unmark (struct cpu_mark_t * mark)
Calculate TSC and timing difference π¦
Parameters
- mark β input/output: a pointer to a
cpu_mark_tstructure, which has already been initialized bycpu_tsc_mark. The difference in TSC and time will be written here.
This function calculates the TSC and time difference, by obtaining the current TSC and timing values and subtracting the contents of the mark structure from them. Results are written in the same structure. π
Example:
...
struct cpu_mark_t mark;
cpu_tsc_mark(&mark);
foo();
cpu_tsc_unmark(&mark);
printf("Foo finished. Executed in %llu cycles and %llu usecs\n",
mark.tsc, mark.sys_clock);
...
int cpuid_deserialize_all_raw_data (struct cpu_raw_data_array_t * data, const char * filename)
Reads all raw CPUID data from file π
Parameters
- data β a pointer to
cpu_raw_data_array_tstructure. The deserialized array data will be written here. - filename β the path of the file, containing the serialized raw data. If empty,
stdinwill be used.
Note
This function may fail, if the file is created by different version of the library. Also, see the notes on cpuid_serialize_all_raw_data. π
As the memory is dynamically allocated, be sure to call cpuid_free_raw_data_array() after you're done with the data β
Returns
zero if successful, and some negative number on error. The error message can be obtained by calling cpuid_error.
See also
cpu_error_t
int cpuid_deserialize_raw_data (struct cpu_raw_data_t * data, const char * filename)
Reads raw CPUID data from file π
Parameters
- data β a pointer to
cpu_raw_data_tstructure. The deserialized data will be written here. - filename β the path of the file, containing the serialized raw data. If empty,
stdinwill be used.
Note
This function may fail, if the file is created by different version of the library. Also, see the notes on cpuid_serialize_raw_data. π
Returns
zero if successful, and some negative number on error. The error message can be obtained by calling cpuid_error.
See also
cpu_error_t
const char * cpuid_error (void )
Returns textual description of the last error π«Ά libcpuid stores an errno-style error status, whose description can be obtained with this function.
Note
This function is not thread-safe π
See also
cpu_error_t
void cpuid_free_cpu_list (struct cpu_list_t * list)
Frees a CPU list π§ This function deletes all the memory associated with a CPU list, as obtained by cpuid_get_cpu_list()
Parameters
- list β the list to be
free()'d.
void cpuid_free_raw_data_array (struct cpu_raw_data_array_t * raw_array)
Frees a raw array β¨ This function deletes all the memory associated with a raw array, as obtained by cpuid_get_all_raw_data(), cpuid_deserialize_all_raw_data() and cpu_identify_all()
Parameters
- raw_array β the raw array to be
free()'d.
void cpuid_free_system_id (struct system_id_t * system)
Frees a system ID type π
This function deletes all the memory associated with a system ID, as obtained by cpu_identify_all()
Parameters
- system β the system ID to be
free()'d.
int cpuid_get_all_raw_data (struct cpu_raw_data_array_t * data)
Obtains the raw CPUID data from all CPUs πΈ
Parameters
- data β a pointer to
cpu_raw_data_array_tstructure
Note
As the memory is dynamically allocated, be sure to call cpuid_free_raw_data_array() after you're done with the data π
Returns
zero if successful, and some negative number on error. The error message can be obtained by calling cpuid_error.
See also
cpu_error_t
void cpuid_get_cpu_list (cpu_vendor_t vendor, struct cpu_list_t * list)
Gets a list of all known CPU names from a specific vendor π This function compiles a list of all known CPU (code)names (i.e. the possible values of cpu_id_t::cpu_codename) for the given vendor.
There are about 100 entries for Intel and AMD, and a few for the other vendors. The list is written out in approximate chronological introduction order of the parts. π¦
Parameters
- vendor β the vendor to be queried
- list [out] β the resulting list will be written here. On failure,
num_entriesis set to zero andnamestoNULL. The error message can be obtained by callingcpuid_error.
See also
cpu_error_t
NOTE: As the memory is dynamically allocated, be sure to call cpuid_free_cpu_list() after you're done with the data β
cpu_list_t
struct cpu_epc_t cpuid_get_epc (int index, const struct cpu_raw_data_t * raw)
Fetches information about an EPC (Enclave Page Cache) area π₯
Parameters
- index β zero-based index, valid range
[0..cpu_id_t.egx.num_epc_sections) - raw β a pointer to fetched raw CPUID data. Needed only for testing, you can safely pass
NULLhere (if you pass a real structure, it will be used for fetching the leaf 12h data ifindex < 2; otherwise the real CPUID instruction will be used).
Returns
the requested data. If the CPU doesn't support SGX, or if index >= cpu_id_t.egx.num_epc_sections, both fields of the returned structure will be zeros. π
References cpuid_get_epc().
Referenced by cpuid_get_epc().
cpuid_get_hypervisor π
hypervisor_vendor_t cpuid_get_hypervisor (struct cpu_raw_data_t * raw,
struct cpu_id_t * data)
okay so this one sniffs out the hypervisor vendor from CPUID on whatever CPU you're currently on. like, who's running the show, bestie? π
Parameters
rawβ optional input, a pointer to the raw CPUID data, which you get from eithercpuid_get_raw_dataorcpuid_deserialize_raw_data. It can also beNULL, and if it is, the function just callscpuid_get_raw_dataitself. self-sufficient queen. β¨dataβ optional input, the decoded CPU features/info gets written here. Can also beNULL, in which case the function callscpu_identifyitself.
Note β if no hypervisor is detected, it might just be hidden, because apparently some hypervisors are shy π. go peek at https://github.com/anrieff/libcpuid/issues/90#issuecomment-296568713.
Returns
HYPERVISOR_UNKNOWNif it failed,HYPERVISOR_NONEif no hypervisor was detected (or it's hiding),- otherwise, the hypervisor vendor type. slay.
See also β hypervisor_vendor_t
cpuid_get_raw_data πΈ
int cpuid_get_raw_data (struct cpu_raw_data_t * data)
grabs the raw CPUID data from the current CPU. the receipts, if you will. π§Ύ
Parameters
dataβ a pointer tocpu_raw_data_tstructure
Returns
zero if it worked, and some negative number on error. want the actual error message? call cpuid_error. π
See also β cpu_error_t
cpuid_get_raw_data_core π
int cpuid_get_raw_data_core (struct cpu_raw_data_t * data, logical_cpu_t
logical_cpu)
same energy as above but for a specific CPU β you get to pick which one, main character energy fr fr.
Parameters
dataβ a pointer tocpu_raw_data_tstructurelogical_cpuβ specify the core number. The first core number is0. The last core number iscpuid_get_total_cpus - 1.
Returns
zero if successful, and some negative number on error. The error message can be obtained by calling cpuid_error.
See also β cpu_error_t
cpuid_get_total_cpus π
int cpuid_get_total_cpus (void )
returns the total number of logical CPU threads β and yes, even if CPUID isn't present. it's giving "I counted anyway" π
under VM, bestie, this number can be nonsense π β andtotal_logical_cpustoo, since they come from the same code. it might not equalNumPhysicalCPUs*NumCoresPerCPU*HyperThreading. why? because no matter how many logical threads the host machine has, you can limit them in the VM to literally any number you want. so yeah. that's the numbercpuid_get_total_cpus()hands back.
Returns
Number of logical CPU threads available. Equals the cpu_id_t::total_logical_cpus.
cpuid_get_vendor π¦
cpu_vendor_t cpuid_get_vendor (void )
obtains the CPU vendor from CPUID from the current CPU. who made you, baby? π
Note β the result is cached. so it remembers. iconic.
Returns
VENDOR_UNKNOWN if it failed, otherwise the CPU vendor type.
See also β cpu_vendor_t
cpuid_lib_version β
const char * cpuid_lib_version (void )
returns the libcpuid version. the fit check for the library itself β¨
Returns
the string representation of the libcpuid version, like "0.1.1"
cpuid_present π
int cpuid_present (void )
checks if the CPUID instruction is even supported. vibe check on the CPU itself π«Ά
Return values
1if CPUID is present0the CPU doesn't have CPUID.
cpuid_serialize_all_raw_data π
int cpuid_serialize_all_raw_data (struct cpu_raw_data_array_t * data, const
char * filename)
writes all the raw CPUID data to a text file. every last crumb. π
Parameters
dataβ a pointer tocpu_raw_data_array_tstructurefilenameβ the path of the file where the serialized data for all CPUs should be written. If empty,stdoutwill be used.
Note β this is intended primarily for debugging. On some processor which is not currently supported or not completely recognized bycpu_identify_all, one can still successfully get the raw data and write it to a file. libcpuid developers can later import this file and debug the detection code as if running on the actual hardware. The file is simple text format of"something=value"pairs. Version info is also written, but the format is not intended to be neither backward- nor forward compatible. so like, don't build anything on it. fr fr.
Returns
zero if successful, and some negative number on error. The error message can be obtained by calling cpuid_error.
See also β cpu_error_t
cpuid_serialize_raw_data πΈ
int cpuid_serialize_raw_data (struct cpu_raw_data_t * data, const char *
filename)
writes the raw CPUID data to a text file. single-CPU edition π
Parameters
dataβ a pointer tocpu_raw_data_tstructurefilenameβ the path of the file where the serialized data should be written. If empty,stdoutwill be used.
Note β again, intended primarily for debugging. On some processor which is not currently supported or not completely recognized bycpu_identify, one can still successfully get the raw data and write it to a file. libcpuid developers can later import this file and debug the detection code as if running on the actual hardware. The file is simple text format of"something=value"pairs. Version info is also written, but the format is not intended to be neither backward- nor forward compatible. you've been warned, bestie π«Ά
Returns
zero if successful, and some negative number on error. The error message can be obtained by calling cpuid_error.
See also β cpu_error_t
cpuid_set_verbosiness_level π
void cpuid_set_verbosiness_level (int level)
sets the verbosiness level. when it's above zero, some functions might print diagnostic info about what they're doing. the higher the level, the more detail gets printed. level zero is guaranteed to omit all such output. the output is written using the same machinery as the warnings. so yes, it yaps β but only as much as you tell it to π¬
See also β cpuid_set_warn_function()
Parameters
levelβ the desired verbosiness level. Useful values0..2inclusive
cpuid_set_warn_function π₯
libcpuid_warn_fn_t cpuid_set_warn_function (libcpuid_warn_fn_t warn_fun)
sets the warning print function. sometimes the internal libcpuid machinery wants to emit useful debug warnings. by default those warnings go to stderr. but you can hand it a custom function to receive them instead. your warnings, your rules π
Parameters
warn_funβ the warning function you want to set. IfNULL, warnings are disabled. The function takesconst char*argument.
Returns
the current warning function. you can use the return value to keep the previous warning function and restore it at your discretion. very "I'll hold onto this for later" of you π
msr_serialize_raw_data π§
int msr_serialize_raw_data (struct msr_driver_t * handle, const char *
filename)
writes the raw MSR data to a text file. model-specific registers, getting the same treatment β¨
Parameters
handleβ a handle to the MSR reader driver, as created bycpu_msr_driver_openfilenameβ the path of the file where the serialized data should be written. If empty,stdoutwill be used.
Note β once again, intended primarily for debugging. On some processor which is not currently supported or not completely recognized bycpu_identify, one can still successfully get the raw data and write it to a file. libcpuid developers can later import this file and debug the detection code as if running on the actual hardware. The file is simple text format of"something=value"pairs. Version info is also written, but the format is not intended to be neither backward- nor forward compatible. π
Returns
zero if successful, and some negative number on error. The error message can be obtained by calling cpuid_error.
See also β cpu_error_t
AUTHOR π«Ά
Generated automatically by Doxygen for libcpuid from the source code. not a human typing this out, just Doxygen doing its little robot thing π€π
and that's a wrap on the whole page, bestie!! πβ¨ this was libcpuid, Version 0.8.2, page libcpuid(3) β go forth and identify some CPUs, you absolute icon ππ
π¦ where this page comes from
- fedora 43: libcpuid-devel 0.8.2-1.fc43 Β· BSD-2-Clause
- fedora 43: libcpuid-devel 0.8.2-1.fc43 Β· BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms