1
0
Fork 0
mirror of https://github.com/anrieff/libcpuid synced 2024-11-10 22:59:13 +00:00

Add function cpu_vendor() to define vendor-specific code

This commit is contained in:
Xorg 2015-10-06 14:50:28 +02:00
parent 79fcdba98e
commit 6c8dfd306f
2 changed files with 21 additions and 0 deletions

View file

@ -174,6 +174,21 @@ int match_pattern(const char* s, const char* p)
return 0;
}
int cpu_vendor(void)
{
int r;
struct cpu_raw_data_t raw;
struct cpu_id_t data;
if ((r = cpuid_get_raw_data(&raw)) < 0)
return set_error(r);
if ((r = cpu_identify(&raw, &data)) < 0)
return set_error(r);
if (0 <= data.vendor && data.vendor < NUM_CPU_VENDORS)
return data.vendor;
else
return set_error(r);
}
struct cpu_id_t* get_cached_cpuid(void)
{
static int initialized = 0;

View file

@ -70,6 +70,12 @@ void generic_get_cpu_list(const struct match_entry_t* matchtable, int count,
*/
int match_pattern(const char* haystack, const char* pattern);
/*
* Get the CPU vendor
* Return val: see enum cpu_vendor_t
*/
int cpu_vendor(void);
/*
* Gets an initialized cpu_id_t. It is cached, so that internal libcpuid
* machinery doesn't need to issue cpu_identify more than once.