Skip to content

πŸ“š a nanoscopic C library for x86/x86_64 CPU feature detection

License

Notifications You must be signed in to change notification settings

rfgplk/nanoflagsx86

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

nanoflags_logo

nanoflagsx86

πŸ“š Nanoscopic CPUID library

This is a (truly) tiny C library for detecting CPU features in 675 sloc. The simplest possible drop-in replacement for any other cpuid reading library, in lieu of reading /proc/cpuinfo

Absolutely no dependencies, except the following, which your system must provide:

<unistd.h>
<sched.h>
<sys/types.h>

... otherwise all code was written from scratch, and is directly provided under src/.

This will detect features on pretty much all x86 cpu's, but as of now it's still missing naming support for more modern >2020 cores, which I'll get around to adding eventually.

Compliant with C99.

Usage

#include "src/x86.h"

int
main(void) {
    processor_t cpu;
    info(&cpu); // for general processor features
    spec(&cpu); // for per unit spec, such as cache features
    // that's it
    printf("Family: %d\n", cpu.family);
    printf("SSE: %d\n", cpu.features.sse);
    printf("SSE2: %d\n", cpu.features.sse2); // and so on
    printf("Frequency: %lld\n", cpu.core[0].freq); // can iterate per core, every core is treated as an ind. unit
}

About

πŸ“š a nanoscopic C library for x86/x86_64 CPU feature detection

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages