#include "cpu_model.h"
#if !(defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || \
defined(_M_X64))
#error This file is intended only for x86-based targets
#endif
#if defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER)
#include <assert.h>
#if (defined(__GNUC__) || defined(__clang__)) && !defined(_MSC_VER)
#include <cpuid.h>
#endif
#ifdef _MSC_VER
#include <intrin.h>
#endif
enum VendorSignatures { … };
enum ProcessorVendors { … };
enum ProcessorTypes { … };
enum ProcessorSubtypes { … };
enum ProcessorFeatures { … };
static bool getX86CpuIDAndInfo(unsigned value, unsigned *rEAX, unsigned *rEBX,
unsigned *rECX, unsigned *rEDX) { … }
static bool getX86CpuIDAndInfoEx(unsigned value, unsigned subleaf,
unsigned *rEAX, unsigned *rEBX, unsigned *rECX,
unsigned *rEDX) { … }
static bool getX86XCR0(unsigned *rEAX, unsigned *rEDX) { … }
static void detectX86FamilyModel(unsigned EAX, unsigned *Family,
unsigned *Model) { … }
#define testFeature …
static const char *getIntelProcessorTypeAndSubtype(unsigned Family,
unsigned Model,
const unsigned *Features,
unsigned *Type,
unsigned *Subtype) { … }
static const char *getAMDProcessorTypeAndSubtype(unsigned Family,
unsigned Model,
const unsigned *Features,
unsigned *Type,
unsigned *Subtype) { … }
#undef testFeature
static void getAvailableFeatures(unsigned ECX, unsigned EDX, unsigned MaxLeaf,
unsigned *Features) { … }
#ifndef _WIN32
__attribute__((visibility("hidden")))
#endif
int __cpu_indicator_init(void) CONSTRUCTOR_ATTRIBUTE;
#ifndef _WIN32
__attribute__((visibility("hidden")))
#endif
struct __processor_model { … } __cpu_model = …;
#ifndef _WIN32
__attribute__((visibility("hidden")))
#endif
unsigned __cpu_features2[(CPU_FEATURE_MAX - 1) / 32];
int CONSTRUCTOR_ATTRIBUTE __cpu_indicator_init(void) { … }
#endif