~ubuntu-branches/ubuntu/hardy/sysstat/hardy

« back to all changes in this revision

Viewing changes to common.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Luberda
  • Date: 2006-05-29 20:11:57 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060529201157-e6mxz13s36uq4fzd
Tags: 6.1.3-1
* New upstream version (development):
  + daily data files format has changed again.
* debian/control: Standards-Version: 3.7.2 (no changes needed).
* debian/watch: prefer downloads from the upstream site.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * sar, sadc, sadf, mpstat and iostat common routines.
3
 
 * (C) 1999-2005 by Sebastien GODARD (sysstat <at> wanadoo.fr)
 
3
 * (C) 1999-2006 by Sebastien GODARD (sysstat <at> wanadoo.fr)
4
4
 *
5
5
 ***************************************************************************
6
6
 * This program is free software; you can redistribute it and/or modify it *
83
83
 
84
84
/*
85
85
 ***************************************************************************
86
 
 * Return the number of processors used on the machine
87
 
 * (0 means one proc, 1 means two proc, etc.)
 
86
 * Return the number of processors used on the machine:
 
87
 * 0: one proc and non SMP kernel
 
88
 * 1: one proc and SMP kernel, or SMP machine with all but one offlined CPU
 
89
 * 2: two proc...
88
90
 * As far as I know, there are two possibilities for this:
89
91
 * 1) Use /proc/stat (this is what we are doing here) or
90
92
 * 2) Use /proc/cpuinfo
91
 
 * (I haven't heard of a better method to guess it...)
92
93
 ***************************************************************************
93
94
 */
94
95
int get_cpu_nr(unsigned int max_nr_cpus)
111
112
      }
112
113
   }
113
114
 
114
 
   /*
115
 
    * cpu_nr initial value: -1
116
 
    * If cpu_nr < 0 then there is only one proc.
117
 
    * If cpu_nr > 0 then this is an SMP machine.
118
 
    * If cpu_nr = 0 then there is only one proc but this is a Linux 2.2 SMP or
119
 
    * Linux 2.4 kernel.
120
 
    */
121
 
   if (cpu_nr < 0)
122
 
      cpu_nr = 0;
123
 
 
124
 
   if (cpu_nr >= max_nr_cpus) {
 
115
   if ((cpu_nr + 1) > max_nr_cpus) {
125
116
      fprintf(stderr, _("Cannot handle so many processors!\n"));
126
117
      exit(1);
127
118
   }
128
119
 
129
120
   fclose(fp);
130
121
 
131
 
   return cpu_nr;
 
122
   return (cpu_nr + 1);
132
123
}
133
124
 
134
125