~ubuntu-branches/ubuntu/utopic/linuxlogo/utopic

« back to all changes in this revision

Viewing changes to libsysinfo-0.2.1/Linux/cpuinfo_m32r.c

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Reichle-Schmehl
  • Date: 2010-03-10 11:25:34 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20100310112534-sbweh2jsk041w73u
Tags: 5.10-1
* New upstream release.
* Drop patches/01-s390x.patch and patches/02-sh.patch
  (both were pplied upstream)
* remove quilt, as we don't have any more patches
* Add $remote_fs to Required-Start and Required-Stop of the init scripts
  LSB header
* Bump standards version (no changes needed)

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 int get_arch_specific_mem_size(void) {
77
 
       /* We have no special way of detecting RAM */
78
 
       return get_mem_size_sysinfo();
79
 
}