1
0
Fork 0
mirror of https://github.com/anrieff/libcpuid synced 2024-12-16 16:35:45 +00:00
a small C library for x86 CPU detection and feature extraction
Find a file
2024-07-07 17:48:41 +02:00
.github/workflows Revert "CI: disable docs pipeline for now" 2024-07-01 09:46:38 +02:00
cmake Add CMake 2020-02-06 10:32:25 +02:00
contrib/MSR Driver Remove all trailling spaces 2020-05-09 17:34:07 +02:00
cpuid_tool Add cpu_feature_level_t enumerated values for x86 CPUs 2024-06-29 17:01:50 +02:00
libcpuid Improve ARM core ID identification and add cpuid_get_raw_data_core() 2024-07-07 17:48:41 +02:00
tests Improve ARM core ID identification and add cpuid_get_raw_data_core() 2024-07-07 17:48:41 +02:00
utils utils: move bump_version.sh 2024-06-29 19:03:09 +02:00
.gitignore Support for hybrid CPU (#166) 2022-09-15 18:37:08 +02:00
AUTHORS Moving the repository one level deeper 2008-11-06 18:17:20 +00:00
ChangeLog Release version 0.6.5 2024-04-28 12:23:59 +02:00
cmake-format.py Add config file for cmake-format 2020-05-21 18:42:42 +02:00
CMakeLists.txt Do not warn about deprecated declarations in cpu_ident_internal() 2024-06-30 13:51:50 +02:00
configure.ac Add initial support for ARM CPUs 2024-06-28 20:41:00 +02:00
CONTRIBUTING.md Update README.md and add CONTRIBUTING.md 2024-06-30 13:42:24 +02:00
COPYING Moving the repository one level deeper 2008-11-06 18:17:20 +00:00
libcpuid.dsw Remove all trailling spaces 2020-05-09 17:34:07 +02:00
libcpuid.pc.in Incorrect path in .pc file - fixed; Clarified documentation a bit 2008-11-28 16:17:29 +00:00
libcpuid_vc10.sln Remove all trailling spaces 2020-05-09 17:34:07 +02:00
libcpuid_vc71.sln Remove all trailling spaces 2020-05-09 17:34:07 +02:00
Makefile.am Support for hybrid CPU (#166) 2022-09-15 18:37:08 +02:00
Readme.md README: update URLs 2024-07-01 09:46:13 +02:00

libcpuid

libcpuid provides CPU identification. Supported CPU architectures are:

  • x86:
    • 32-bit CPUs (IA-32, also known as i386, i486, i586 and i686)
    • 64-bit CPUs (x86_64, also known as x64, AMD64, and Intel 64)
  • ARM (since v0.7.0):
    • 64-bit CPUs (ARM64, also known as AArch64)

For details about the programming API, you might want to take a look at the project's website on sourceforge (https://libcpuid.sourceforge.net). There you'd find a short tutorial, as well as the full API reference.

Getting started

You have two ways to get libcpuid:

  • build it from sources
  • download a pre-compiled binary

Sources

Prerequisites

Using libcpuid requires no dependencies on any of the supported OSes. Building it requires build tool commands to be available, which is a matter of installing a few common packages with related names (e.g. automake, autoconf, libtool, cmake). It also requires a POSIX-compatible shell. On NetBSD, you may need to install one (credits to @brucelilly):

  1. Install a POSIX-compatible shell such as ksh93
pkg_add ast-ksh || pkgin in ast-ksh
  1. Export CONFIG_SHELL with correct path if required:
export CONFIG_SHELL=/usr/pkg/bin/ksh93

Configuring after checkout

Two build systems are supported, use the one you prefer.

By using autotools

Under POSIX systems, where you download the sources, there's no configure script to run. This is because it isn't a good practice to keep such scripts in a source control system. To create it, you need to run the following commands once, after you checkout the libcpuid sources from GitHub:

libtoolize
autoreconf --install

You need to have autoconf, automake and libtool installed.

After that you can run ./configure and make - this will build the library.

make dist will create a tarball (with "configure" inside) with the sources.

By using CMake

Basic example to build and install libcpuid by using CMake:

cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build build
cmake --install build # may need administrative privileges, install under /usr/local by default

Downloads

You can find latest versioned archives here, with binaries for macOS and Windows.

Binary packages

Also, libcpuid is available for following systems in official repositories:

Below, the full lists of repositories:
Packaging status

Build tool

  • Vcpkg: vcpkg install cpuid

Contributing

Refer to the dedicated page.

Users

So far, I'm aware of the following projects which utilize libcpuid (listed alphabetically):

We'd love to hear from you if you are also using libcpuid and want your project listed above.