"Fossies" - the Fresh Open Source Software Archive

Member "linux_logo-6.0/libsysinfo-0.3.0/Linux/cpuinfo_m32r.c" (8 May 2020, 2100 Bytes) of package /linux/misc/linux_logo-6.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /* Handle m32r architecture */
    2 
    3 #include <stdio.h>
    4 #include <string.h>
    5 #include <stdlib.h>  /* atof */
    6 
    7 #include "../sysinfo.h"
    8 #include "../include/generic.h"
    9 
   10 int get_cpu_info(struct cpu_info_type *cpu_info) {
   11 
   12     FILE *fff;
   13     char temp_string[BUFSIZ];
   14     char vendor_string[BUFSIZ],model_string[BUFSIZ];
   15     int cpu_count=0;
   16     float megahertz=0.0,bogomips=0.0;
   17    
   18     vendor_string[0]=model_string[0]=0;
   19 
   20     strncpy(vendor_string,"m32r",5);
   21    
   22        /* We get all of our info here from /proc/cpuinfo */
   23     if ((fff=fopen(get_cpuinfo_file(),"r") )!=NULL) {
   24        
   25        while ( (fgets(temp_string,BUFSIZ,fff)!=NULL) ) {
   26     
   27       if ( !(strncmp(temp_string,"cpu family",10))) {
   28          strncpy(model_string,parse_line(temp_string),BUFSIZ);
   29          clip_lf(model_string,BUFSIZ);
   30       }
   31           
   32       if ( !(strncmp(temp_string,"CPU clock",9))) {
   33          megahertz=atof(parse_line(temp_string));        
   34       }
   35 
   36          /* Ugh why must people play with capitalization */
   37       if ( !(strncmp(temp_string,"bogomips",8)) ||
   38            !(strncmp(temp_string,"BogoMips",8)) ||
   39            !(strncmp(temp_string,"BogoMIPS",8))) {
   40          bogomips+=atof(parse_line(temp_string));
   41          cpu_count++;  /* Cheating way to detect number of CPUs */
   42       }
   43        }
   44     }
   45 
   46     strncpy(cpu_info->chip_vendor,vendor_string,SYSINFO_CHIP_VENDOR_SIZE);
   47     strncpy(cpu_info->chip_type,model_string,SYSINFO_CHIP_TYPE_SIZE);
   48    
   49     cpu_info->num_cpus=cpu_count;
   50     cpu_info->megahertz=megahertz;
   51     cpu_info->bogomips=bogomips;
   52 
   53     return 0;
   54    
   55 }
   56 
   57 int get_hardware(char *hardware_string) {
   58     
   59     char temp_string[BUFSIZ];
   60     FILE *fff;
   61    
   62     if ((fff=fopen(get_cpuinfo_file(),"r") )!=NULL) {
   63        
   64        while ( (fgets(temp_string,BUFSIZ,fff)!=NULL) ) {
   65           
   66       if (!(strncmp(temp_string,"system type",11))) {
   67              strncpy(hardware_string,parse_line(temp_string),
   68              SYSINFO_HARDWARE_STRING_SIZE);
   69       }
   70        }
   71     }
   72     return 1;
   73 }
   74 
   75     /* Some architectures might have better ways of detecting RAM size */
   76 long long get_arch_specific_mem_size(void) {
   77        /* We use sysinfo */
   78        return MEM_USE_SYSINFO;
   79 }