diff --git a/cpuid_tool/cpuid_tool.c b/cpuid_tool/cpuid_tool.c
index 27e145d..8f2930f 100644
--- a/cpuid_tool/cpuid_tool.c
+++ b/cpuid_tool/cpuid_tool.c
@@ -137,6 +137,7 @@ const int sz_match = (sizeof(matchtable) / sizeof(matchtable[0]));
static void usage(void)
{
+ int line_fill, l, i;
printf("Usage: cpuid_tool [options]\n\n");
printf("Options:\n");
printf(" -h,--help - Show this help\n");
@@ -152,7 +153,7 @@ static void usage(void)
printf("\n");
printf("Query switches (generate 1 line of ouput per switch; in order of appearance):");
- int line_fill = 80, l, i;
+ line_fill = 80;
for (i = 0; i < sz_match; i++) {
l = (int) strlen(matchtable[i].synopsis);
if (line_fill + l > 76) {
@@ -177,6 +178,8 @@ static int parse_cmdline(int argc, char** argv)
fprintf(stderr, "Error: %s\n\n", msg); \
fprintf(stderr, "Use -h to get a list of supported options\n"); \
return -1;
+
+ int i, j, recog;
if (argc == 1) {
/* Default command line options */
need_output = 1;
@@ -186,7 +189,6 @@ static int parse_cmdline(int argc, char** argv)
need_verbose = 1;
return 1;
}
- int i, j, recog;
for (i = 1; i < argc; i++) {
char *arg = argv[i];
recog = 0;
@@ -389,11 +391,12 @@ int main(int argc, char** argv)
int parseres = parse_cmdline(argc, argv);
int i, readres, writeres;
int only_clock_queries;
- if (parseres != 1)
- return parseres;
struct cpu_raw_data_t raw;
struct cpu_id_t data;
-
+
+ if (parseres != 1)
+ return parseres;
+
/* In quiet mode, disable libcpuid warning messages: */
if (need_quiet)
cpuid_set_warn_function(NULL);
diff --git a/cpuid_tool/cpuid_tool.vcproj b/cpuid_tool/cpuid_tool.vcproj
new file mode 100644
index 0000000..9dce5c0
--- /dev/null
+++ b/cpuid_tool/cpuid_tool.vcproj
@@ -0,0 +1,207 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/libcpuid.sln b/libcpuid.sln
new file mode 100644
index 0000000..efe37dc
--- /dev/null
+++ b/libcpuid.sln
@@ -0,0 +1,28 @@
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcpuid", "libcpuid\libcpuid.vcproj", "{92BDBA37-96E3-4D85-B762-185E4407BB49}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpuid_tool", "cpuid_tool\cpuid_tool.vcproj", "{854A36FB-EA23-4165-9110-A55EB97C6377}"
+ ProjectSection(ProjectDependencies) = postProject
+ {92BDBA37-96E3-4D85-B762-185E4407BB49} = {92BDBA37-96E3-4D85-B762-185E4407BB49}
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {92BDBA37-96E3-4D85-B762-185E4407BB49}.Debug|Win32.ActiveCfg = Debug|Win32
+ {92BDBA37-96E3-4D85-B762-185E4407BB49}.Debug|Win32.Build.0 = Debug|Win32
+ {92BDBA37-96E3-4D85-B762-185E4407BB49}.Release|Win32.ActiveCfg = Release|Win32
+ {92BDBA37-96E3-4D85-B762-185E4407BB49}.Release|Win32.Build.0 = Release|Win32
+ {854A36FB-EA23-4165-9110-A55EB97C6377}.Debug|Win32.ActiveCfg = Debug|Win32
+ {854A36FB-EA23-4165-9110-A55EB97C6377}.Debug|Win32.Build.0 = Debug|Win32
+ {854A36FB-EA23-4165-9110-A55EB97C6377}.Release|Win32.ActiveCfg = Release|Win32
+ {854A36FB-EA23-4165-9110-A55EB97C6377}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/libcpuid/cpuid_main.c b/libcpuid/cpuid_main.c
index 7c8c38b..783fb03 100644
--- a/libcpuid/cpuid_main.c
+++ b/libcpuid/cpuid_main.c
@@ -191,13 +191,8 @@ static void load_features_common(struct cpu_raw_data_t* raw, struct cpu_id_t* da
static int cpuid_basic_identify(struct cpu_raw_data_t* raw, struct cpu_id_t* data)
{
- int i, j;
-
- memcpy(data->vendor_str + 0, &raw->basic_cpuid[0][1], 4);
- memcpy(data->vendor_str + 4, &raw->basic_cpuid[0][3], 4);
- memcpy(data->vendor_str + 8, &raw->basic_cpuid[0][2], 4);
- data->vendor_str[12] = 0;
- /* Determine vendor: */
+ int i, j, basic, xmodel, xfamily, ext;
+ char brandstr[64] = {0};
const struct { cpu_vendor_t vendor; char match[16]; }
matchtable[NUM_CPU_VENDORS] = {
/* source: http://www.sandpile.org/ia32/cpuid.htm */
@@ -212,6 +207,12 @@ static int cpuid_basic_identify(struct cpu_raw_data_t* raw, struct cpu_id_t* dat
{ VENDOR_SIS , "SiS SiS SiS " },
{ VENDOR_NSC , "Geode by NSC" },
};
+
+ memcpy(data->vendor_str + 0, &raw->basic_cpuid[0][1], 4);
+ memcpy(data->vendor_str + 4, &raw->basic_cpuid[0][3], 4);
+ memcpy(data->vendor_str + 8, &raw->basic_cpuid[0][2], 4);
+ data->vendor_str[12] = 0;
+ /* Determine vendor: */
data->vendor = VENDOR_UNKNOWN;
for (i = 0; i < NUM_CPU_VENDORS; i++)
if (!strcmp(data->vendor_str, matchtable[i].match)) {
@@ -220,8 +221,7 @@ static int cpuid_basic_identify(struct cpu_raw_data_t* raw, struct cpu_id_t* dat
}
if (data->vendor == VENDOR_UNKNOWN)
return set_error(ERR_CPU_UNKN);
- int basic = raw->basic_cpuid[0][0];
- int xmodel, xfamily;
+ basic = raw->basic_cpuid[0][0];
if (basic >= 1) {
data->family = (raw->basic_cpuid[1][0] >> 8) & 0xf;
data->model = (raw->basic_cpuid[1][0] >> 4) & 0xf;
@@ -234,10 +234,9 @@ static int cpuid_basic_identify(struct cpu_raw_data_t* raw, struct cpu_id_t* dat
data->ext_family = data->family + xfamily;
data->ext_model = data->model + (xmodel << 4);
}
- int ext = raw->ext_cpuid[0][0] - 0x8000000;
+ ext = raw->ext_cpuid[0][0] - 0x8000000;
/* obtain the brand string, if present: */
- char brandstr[64] = {0};
if (ext >= 4) {
for (i = 0; i < 3; i++)
for (j = 0; j < 4; j++)
@@ -342,7 +341,7 @@ int cpuid_deserialize_raw_data(struct cpu_raw_data_t* data, const char* filename
if (!f) return set_error(ERR_OPEN);
while (fgets(line, sizeof(line), f)) {
++cur_line;
- len = strlen(line);
+ len = (int) strlen(line);
if (len < 2) continue;
if (line[len - 1] == '\n')
line[--len] = '\0';
diff --git a/libcpuid/libcpuid.vcproj b/libcpuid/libcpuid.vcproj
new file mode 100644
index 0000000..c4ae998
--- /dev/null
+++ b/libcpuid/libcpuid.vcproj
@@ -0,0 +1,221 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/libcpuid/libcpuid_util.c b/libcpuid/libcpuid_util.c
index 10de3cf..447172d 100644
--- a/libcpuid/libcpuid_util.c
+++ b/libcpuid/libcpuid_util.c
@@ -48,9 +48,9 @@ libcpuid_warn_fn_t _warn_fun = default_warn;
void warnf(const char* format, ...)
{
- if (!_warn_fun) return;
char buff[1024];
va_list va;
+ if (!_warn_fun) return;
va_start(va, format);
vsnprintf(buff, sizeof(buff), format, va);
va_end(va);
diff --git a/libcpuid/recog_intel.c b/libcpuid/recog_intel.c
index ebb267a..47ab01b 100644
--- a/libcpuid/recog_intel.c
+++ b/libcpuid/recog_intel.c
@@ -443,28 +443,35 @@ static void decode_intel_codename(struct cpu_raw_data_t* raw, struct cpu_id_t* d
intel_code_t code = NO_CODE;
int i;
const char* bs = data->brand_str;
+ const struct { int cache_size; intel_code_t code; } match_cache[] = {
+ { 512, CORE_DUO_512K },
+ { 1024, CORE_DUO_1024K },
+ { 2048, ALLENDALE },
+ { 3072, PENRYN },
+ { 6144, WOLFDALE },
+ };
+ const struct { intel_code_t c; const char *search; } matchtable[] = {
+ { XEONMP, "Xeon MP" },
+ { XEONMP, "Xeon(TM) MP" },
+ { XEON, "Xeon" },
+ { CELERON, "Celeron" },
+ { MOBILE_PENTIUM_M, "Pentium(R) M" },
+ { PENTIUM_D, "Pentium(R) D" },
+ { PENTIUM, "Pentium" },
+ { CORE_SOLO, "Genuine Intel(R) CPU" },
+ { CORE_SOLO, "Intel(R) Core(TM)2" },
+ { ATOM_DIAMONDVILLE, "Atom(TM) CPU 2" },
+ { ATOM_DIAMONDVILLE, "Atom(TM) CPU N" },
+ { ATOM_DUALCORE, "Atom(TM) CPU 3" },
+ { ATOM_SILVERTHORNE, "Atom(TM) CPU Z" },
+ };
+
if (strstr(bs, "Mobile")) {
if (strstr(bs, "Celeron"))
code = MOBILE_CELERON;
else if (strstr(bs, "Pentium"))
code = MOBILE_PENTIUM;
} else {
- const struct { intel_code_t c; const char *search; }
- matchtable[] = {
- { XEONMP, "Xeon MP" },
- { XEONMP, "Xeon(TM) MP" },
- { XEON, "Xeon" },
- { CELERON, "Celeron" },
- { MOBILE_PENTIUM_M, "Pentium(R) M" },
- { PENTIUM_D, "Pentium(R) D" },
- { PENTIUM, "Pentium" },
- { CORE_SOLO, "Genuine Intel(R) CPU" },
- { CORE_SOLO, "Intel(R) Core(TM)2" },
- { ATOM_DIAMONDVILLE, "Atom(TM) CPU 2" },
- { ATOM_DIAMONDVILLE, "Atom(TM) CPU N" },
- { ATOM_DUALCORE, "Atom(TM) CPU 3" },
- { ATOM_SILVERTHORNE, "Atom(TM) CPU Z" },
- };
for (i = 0; i < COUNT_OF(matchtable); i++)
if (strstr(bs, matchtable[i].search)) {
code = matchtable[i].c;
@@ -497,14 +504,7 @@ static void decode_intel_codename(struct cpu_raw_data_t* raw, struct cpu_id_t* d
code = MORE_THAN_QUADCORE; break;
}
}
- const struct { int cache_size; intel_code_t code; }
- match_cache[] = {
- { 512, CORE_DUO_512K },
- { 1024, CORE_DUO_1024K },
- { 2048, ALLENDALE },
- { 3072, PENRYN },
- { 6144, WOLFDALE },
- };
+
if (code == CORE_DUO && data->l2_cache != 4096) {
for (i = 0; i < COUNT_OF(match_cache); i++) {
if (match_cache[i].cache_size == data->l2_cache) {