parent
10fa3b1878
commit
ed029357d1
|
@ -40,22 +40,25 @@ int xs_parse_cpu(char *model, char *vendor, double *freq)
|
||||||
#if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || defined(__alpha__) || defined(__ia64__) || defined(__parisc__) || defined(__sparc__)
|
#if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || defined(__alpha__) || defined(__ia64__) || defined(__parisc__) || defined(__sparc__)
|
||||||
char buffer[bsize];
|
char buffer[bsize];
|
||||||
#endif
|
#endif
|
||||||
#if defined(__powerpc__)
|
FILE *fp;
|
||||||
char *pos = NULL;
|
|
||||||
#endif
|
fp = fopen("/proc/cpuinfo", "r");
|
||||||
FILE *fp = fopen("/proc/cpuinfo", "r");
|
|
||||||
if(fp == NULL)
|
if(fp == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
#if defined(__i386__) || defined(__x86_64__)
|
#if defined(__i386__) || defined(__x86_64__)
|
||||||
|
|
||||||
while(fgets(buffer, bsize, fp) != NULL)
|
while(fgets(buffer, bsize, fp) != NULL)
|
||||||
{
|
{
|
||||||
find_match_char(buffer, "model name", model);
|
find_match_char(buffer, "model name", model);
|
||||||
find_match_char(buffer, "vendor_id", vendor);
|
find_match_char(buffer, "vendor_id", vendor);
|
||||||
find_match_double(buffer, "cpu MHz", freq);
|
find_match_double(buffer, "cpu MHz", freq);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#ifdef __powerpc__
|
#elif defined(__powerpc__)
|
||||||
|
{
|
||||||
|
char *pos;
|
||||||
|
|
||||||
while(fgets(buffer, bsize, fp) != NULL)
|
while(fgets(buffer, bsize, fp) != NULL)
|
||||||
{
|
{
|
||||||
find_match_char(buffer, "cpu", model);
|
find_match_char(buffer, "cpu", model);
|
||||||
|
@ -63,9 +66,11 @@ int xs_parse_cpu(char *model, char *vendor, double *freq)
|
||||||
find_match_double(buffer, "clock", freq);
|
find_match_double(buffer, "clock", freq);
|
||||||
}
|
}
|
||||||
pos = strstr(model, ",");
|
pos = strstr(model, ",");
|
||||||
if (pos != NULL) *pos = '\0';
|
if (pos != NULL)
|
||||||
#endif
|
*pos = '\0';
|
||||||
#ifdef __alpha__
|
}
|
||||||
|
#elif defined( __alpha__)
|
||||||
|
|
||||||
while(fgets(buffer, bsize, fp) != NULL)
|
while(fgets(buffer, bsize, fp) != NULL)
|
||||||
{
|
{
|
||||||
find_match_char(buffer, "cpu model", model);
|
find_match_char(buffer, "cpu model", model);
|
||||||
|
@ -73,27 +78,31 @@ int xs_parse_cpu(char *model, char *vendor, double *freq)
|
||||||
find_match_double(buffer, "cycle frequency [Hz]", freq);
|
find_match_double(buffer, "cycle frequency [Hz]", freq);
|
||||||
}
|
}
|
||||||
*freq = *freq / 1000000;
|
*freq = *freq / 1000000;
|
||||||
#endif
|
|
||||||
#ifdef __ia64__
|
#elif defined(__ia64__)
|
||||||
|
|
||||||
while(fgets(buffer, bsize, fp) != NULL)
|
while(fgets(buffer, bsize, fp) != NULL)
|
||||||
{
|
{
|
||||||
find_match_char(buffer, "model", model);
|
find_match_char(buffer, "model", model);
|
||||||
find_match_char(buffer, "vendor", vendor);
|
find_match_char(buffer, "vendor", vendor);
|
||||||
find_match_double(buffer, "cpu MHz", freq);
|
find_match_double(buffer, "cpu MHz", freq);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#ifdef __parisc__
|
#elif defined(__parisc__)
|
||||||
|
|
||||||
while(fgets(buffer, bsize, fp) != NULL)
|
while(fgets(buffer, bsize, fp) != NULL)
|
||||||
{
|
{
|
||||||
find_match_char(buffer, "cpu ", model);
|
find_match_char(buffer, "cpu ", model);
|
||||||
find_match_char(buffer, "cpu family", vendor);
|
find_match_char(buffer, "cpu family", vendor);
|
||||||
find_match_double(buffer, "cpu MHz", freq);
|
find_match_double(buffer, "cpu MHz", freq);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#ifdef __sparc__
|
#elif defined(__sparc__)
|
||||||
|
{
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *entry;
|
struct dirent *entry;
|
||||||
FILE *fp2;
|
FILE *fp2;
|
||||||
|
|
||||||
while(fgets(buffer, bsize, fp) != NULL)
|
while(fgets(buffer, bsize, fp) != NULL)
|
||||||
{
|
{
|
||||||
find_match_char(buffer, "cpu ", model);
|
find_match_char(buffer, "cpu ", model);
|
||||||
|
@ -101,9 +110,15 @@ int xs_parse_cpu(char *model, char *vendor, double *freq)
|
||||||
find_match_double_hex(buffer, "Cpu0ClkTck", freq);
|
find_match_double_hex(buffer, "Cpu0ClkTck", freq);
|
||||||
}
|
}
|
||||||
*freq = *freq / 1000000;
|
*freq = *freq / 1000000;
|
||||||
#endif
|
}
|
||||||
fclose(fp);
|
#else
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
return 1; /* Unsupported */
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue