~ubuntu-branches/ubuntu/trusty/linuxlogo/trusty

« back to all changes in this revision

Viewing changes to libsysinfo-0.1.0/FreeBSD/cpuinfo_bsd.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2008-06-20 09:19:00 UTC
  • mfrom: (4.1.2 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080620091900-4xzuv7c7ntxvs7wt
Tags: 5.03-4
* Adding patch to fix FTBFS on s390x.
* Updating to standards 3.8.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
#include <stdio.h>
3
 
#include <ctype.h>
4
 
#include <unistd.h>
5
 
#include <sys/stat.h>
6
 
#include <sys/utsname.h>
7
 
#include <sys/sysctl.h>
8
 
#include <string.h>
9
 
 
10
 
#include "sysinfo.h"
11
 
#include "generic.h"
12
 
 
13
 
#define SIZE(x) sizeof(x)/sizeof(x[0])
14
 
 
15
 
extern float external_bogomips(void);
16
 
 
17
 
int get_cpu_info(cpu_info_t *cpu_info) {
18
 
 
19
 
   int val_int;
20
 
   int val_len;
21
 
   
22
 
/*   char bogomips_total[BUFSIZ]="???";
23
 
   char bogo_total[BUFSIZ];
24
 
   
25
 
   struct utsname buf;
26
 
*/
27
 
   char val_str[100];
28
 
 
29
 
   int ctl_cpu[] = { CTL_HW, HW_MODEL };
30
 
   int ctl_ncpu[] = { CTL_HW, HW_NCPU };
31
 
   
32
 
   val_len = SIZE(val_str);
33
 
   if (sysctl(ctl_cpu, SIZE(ctl_cpu), val_str, &val_len,0,0))
34
 
     perror("sysctl");
35
 
   else
36
 
     strncpy(cpu_info->chip_type,val_str,63);
37
 
   
38
 
   val_len = sizeof(val_int);   
39
 
   if (sysctl(ctl_ncpu, SIZE(ctl_ncpu), &val_int, &val_len,0,0))
40
 
     perror("sysctl");
41
 
   else
42
 
     cpu_info->num_cpus = val_int;
43
 
 
44
 
   
45
 
   cpu_info->bogomips=external_bogomips();
46
 
   cpu_info->megahertz=0.0;
47
 
   
48
 
   return 0;
49
 
   
50
 
}
51
 
      
52