"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libsysinfo-0.2.2/Linux/cpuinfo_alpha.c" between
linux_logo-5.11.tar.gz and linux_logo-6.0.tar.gz

About: Linux_Logo - an ANSI Color Penguin Logo that can be run at bootup. Also shows some system info.

cpuinfo_alpha.c  (linux_logo-5.11):cpuinfo_alpha.c  (linux_logo-6.0)
skipping to change at line 14 skipping to change at line 14
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> /* atof */ #include <stdlib.h> /* atof */
#include "../sysinfo.h" #include "../sysinfo.h"
#include "../include/generic.h" #include "../include/generic.h"
int get_cpu_info(struct cpu_info_type *cpu_info) { int get_cpu_info(struct cpu_info_type *cpu_info) {
FILE *fff; FILE *fff;
char temp_string[BUFSIZ]; char temp_string[BUFSIZ];
char vendor_string[BUFSIZ],model_string[BUFSIZ],hardware_string[BUFSIZ]; char vendor_string[BUFSIZ],model_string[BUFSIZ],hardware_string[BUFSIZ];
int cpu_count=0; int cpu_count=0;
float megahertz=0.0,bogomips=0.0; float megahertz=0.0,bogomips=0.0;
vendor_string[0]=model_string[0]=hardware_string[0]=0; vendor_string[0]=model_string[0]=hardware_string[0]=0;
/* We get all of our info here from /proc/cpuinfo */ /* We get all of our info here from /proc/cpuinfo */
if ((fff=fopen(get_cpuinfo_file(),"r") )!=NULL) { if ((fff=fopen(get_cpuinfo_file(),"r") )!=NULL) {
while ( (fgets(temp_string,255,fff)!=NULL) ) { while ( (fgets(temp_string,255,fff)!=NULL) ) {
if ( !(strncmp(temp_string,"cpu model",9))) { if ( !(strncmp(temp_string,"cpu model",9))) {
strncpy(model_string,parse_line(temp_string),BUFSIZ); strncpy(model_string,parse_line(temp_string),BUFS
clip_lf(model_string,BUFSIZ); IZ-1);
} clip_lf(model_string,BUFSIZ);
else if ( !(strncmp(temp_string,"cpu ",5)) || }
!(strncmp(temp_string,"cpu\t",4))) { else if ( !(strncmp(temp_string,"cpu ",5)) ||
strncpy(vendor_string,parse_line(temp_string),BUFSIZ); !(strncmp(temp_string,"cpu\t",4))) {
clip_lf(vendor_string,BUFSIZ); strncpy(vendor_string,parse_line(temp_string),BUF
} SIZ-1);
clip_lf(vendor_string,BUFSIZ);
if (!(strncmp(temp_string,"cpus detected",13))) { }
cpu_count=atoi(parse_line(temp_string));
} if (!(strncmp(temp_string,"cpus detected",13))) {
/* Older cpuinfo */ cpu_count=atoi(parse_line(temp_string));
if (!(strncmp(temp_string,"CPUs probed",11))) { }
sscanf(temp_string,"%*s %*s %i",&cpu_count);
} /* Older cpuinfo */
if (!(strncmp(temp_string,"CPUs probed",11))) {
if (!(strncmp(temp_string,"cycle frequency",15))) { sscanf(temp_string,"%*s %*s %i",&cpu_count);
megahertz=atof(parse_line(temp_string)); }
}
if (!(strncmp(temp_string,"cycle frequency",15))) {
/* Ugh why must people play with capitalization */ megahertz=atof(parse_line(temp_string));
if ( !(strncmp(temp_string,"bogomips",8)) || }
!(strncmp(temp_string,"BogoMips",8)) ||
!(strncmp(temp_string,"BogoMIPS",8))) { /* Ugh why must people play with capitalization */
bogomips+=atof(parse_line(temp_string)); if ( !(strncmp(temp_string,"bogomips",8)) ||
cpu_count++; /* Cheating way to detect number of intel CPU's */ !(strncmp(temp_string,"BogoMips",8)) ||
} !(strncmp(temp_string,"BogoMIPS",8))) {
}
} bogomips+=atof(parse_line(temp_string));
/* Cheating way to detect number of intel CPUs */
strncpy(cpu_info->chip_vendor,vendor_string,SYSINFO_CHIP_VENDOR_SIZE); cpu_count++;
strncpy(cpu_info->chip_type,model_string,SYSINFO_CHIP_TYPE_SIZE); }
}
/* Sanity check. You can't run Linux w/o a cpu can you? */ }
/* an ev5 cpuinfo I have says "cpus detected: 0" */
if (cpu_count==0) cpu_count=1; strncpy_truncate(cpu_info->chip_vendor,vendor_string,SYSINFO_CHIP_VENDOR_
SIZE);
cpu_info->num_cpus=cpu_count; strncpy_truncate(cpu_info->chip_type,model_string,SYSINFO_CHIP_TYPE_SIZE)
cpu_info->megahertz=megahertz/1000000.0; ;
cpu_info->bogomips=bogomips;
/* Sanity check. You can't run Linux w/o a cpu can you? */
/* an ev5 cpuinfo I have says "cpus detected: 0" */
if (cpu_count==0) cpu_count=1;
cpu_info->num_cpus=cpu_count;
cpu_info->megahertz=megahertz/1000000.0;
cpu_info->bogomips=bogomips;
return 0; return 0;
} }
int get_hardware(char *hardware_string) { int get_hardware(char *hardware_string) {
char temp_string[BUFSIZ]; char temp_string[BUFSIZ];
FILE *fff; FILE *fff;
if ((fff=fopen(get_cpuinfo_file(),"r") )!=NULL) { if ((fff=fopen(get_cpuinfo_file(),"r") )!=NULL) {
while ( (fgets(temp_string,BUFSIZ,fff)!=NULL) ) { while ( (fgets(temp_string,BUFSIZ,fff)!=NULL) ) {
if (!(strncmp(temp_string,"platform string",15))) { if (!(strncmp(temp_string,"platform string",15))) {
strncpy(hardware_string,parse_line(temp_string), strncpy(hardware_string,parse_line(temp_string),
SYSINFO_HARDWARE_STRING_SIZE); SYSINFO_HARDWARE_STRING_SIZE);
} }
} }
} }
return 1; return 1;
} }
/* Some architectures might have better ways of detecting RAM size */ /* Some architectures might have better ways of detecting RAM size */
long long get_arch_specific_mem_size(void) { long long get_arch_specific_mem_size(void) {
/* We have no special way of detecting RAM */ /* We have no special way of detecting RAM */
return 0; return 0;
} }
 End of changes. 9 change blocks. 
70 lines changed or deleted 77 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)