Search code examples
ccross-platformcpuid

Detecting CPU capability without assembly


I've been looking at ways to determine the CPU, and its capabilities (e.g. SEE, SSE2, etc).

However all the ways I've found involved assembly code using the cpuid instruction. Given the different ways of doing assembly in C/C++ between compilers and even targets (no inline assembly for 64-bit targets under VC), I'd rather avoid that.

Is there some simple library around, or OS functions (for both Windows and Linux) for getting this information?

Currently I'm only interested in platforms using the x86 and x86-64 CPU's, and I definitely need to support at least AMD and Intel.


Solution

  • EDIT: At first, I googled for "libcpuid" remembering a conversation with peer programmers, and the google search pointed me to this sourceforge page which looks quite outdated. Then I noticed it was the project page of "libcpu".

    Actually, there really is a libcpuid that might suit your needs.


    Last time I looked for such a library, I found crisscross. It's C++ though.

    There is also geekinfo.

    But I don't know a cross-platform library that just does cpuid.