ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/memory_stats.c
(Generate patch)

Comparing projects/libstatgrab/src/libstatgrab/memory_stats.c (file contents):
Revision 1.13 by ats, Sun Oct 19 02:11:50 2003 UTC vs.
Revision 1.14 by ats, Mon Oct 20 18:13:35 2003 UTC

# Line 32 | Line 32
32   #include <stdio.h>
33   #include <string.h>
34   #endif
35 #ifdef ALLBSD
35   #ifdef FREEBSD
36   #include <sys/types.h>
37   #include <sys/sysctl.h>
39 #else
40 #include <sys/param.h>
41 #include <sys/sysctl.h>
42 #endif
38   #include <unistd.h>
39   #endif
40  
# Line 58 | Line 53 | mem_stat_t *get_memory_stats(){
53          char *line_ptr;
54          FILE *f;
55   #endif
61 #ifdef ALLBSD
62        int mib[2];
56   #ifdef FREEBSD
57 +        int mib[2];
58 +        u_long physmem;
59 +        size_t size;
60          u_int free_count;
61          u_int cache_count;
62          u_int inactive_count;
# Line 69 | Line 65 | mem_stat_t *get_memory_stats(){
65   #ifdef NETBSD
66          struct uvmexp *uvm;
67   #endif
72        u_long physmem;
73        size_t size;
74 #endif
68  
69   #ifdef SOLARIS
70          if((pagesize=sysconf(_SC_PAGESIZE)) == -1){
# Line 128 | Line 121 | mem_stat_t *get_memory_stats(){
121  
122   #endif
123  
124 < #ifdef ALLBSD
124 > #ifdef FREEBSD
125          /* Returns bytes */
126          mib[0] = CTL_HW;
127          mib[1] = HW_PHYSMEM;
# Line 139 | Line 132 | mem_stat_t *get_memory_stats(){
132          mem_stat.total = physmem;
133  
134          /*returns pages*/
142 #ifdef FREEBSD
135          size = sizeof free_count;
136          if (sysctlbyname("vm.stats.vm.v_free_count", &free_count, &size, NULL, 0) < 0){
137                  return NULL;
# Line 171 | Line 163 | mem_stat_t *get_memory_stats(){
163          mem_stat.free=(free_count*pagesize)+(inactive_count*pagesize);
164          mem_stat.used=physmem-mem_stat.free;
165   #endif
166 +
167   #ifdef NETBSD
175        /* FIXME This is not consistent with the FreeBSD logic above. */
168          if ((uvm = get_uvmexp()) == NULL) {
169                  return NULL;
170          }
171 +        mem_stat.total = uvm->pagesize * uvm->npages;
172          mem_stat.cache = uvm->pagesize * (uvm->filepages + uvm->execpages);
173 <        mem_stat.free = uvm->pagesize * uvm->free;
174 <        mem_stat.used = uvm->pagesize * (uvm->npages - uvm->free);
173 >        mem_stat.free = uvm->pagesize * (uvm->free + uvm->inactive);
174 >        mem_stat.used = mem_stat.total - mem_stat.free;
175   #endif
183 #endif
176  
177          return &mem_stat;
186
178   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines