Skip to content
Permalink
Browse files

Add function cpu_vendor() to define vendor-specific code

  • Loading branch information...
X0rg committed Oct 6, 2015
1 parent 33f1d1c commit f9051cda76471093c8f7a784e4bb39e37b9abece
Showing with 21 additions and 0 deletions.
  1. +15 −0 libcpuid/libcpuid_util.c
  2. +6 −0 libcpuid/libcpuid_util.h
@@ -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;
@@ -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.

0 comments on commit f9051cd

Please sign in to comment.
You can’t perform that action at this time.