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.29 by ats, Sun Jul 18 21:31:32 2004 UTC vs.
Revision 1.30 by tdb, Mon Nov 1 18:30:17 2004 UTC

# Line 45 | Line 45
45   #include <sys/time.h>
46   #include <uvm/uvm.h>
47   #endif
48 + #ifdef HPUX
49 + #include <sys/param.h>
50 + #include <sys/pstat.h>
51 + #include <unistd.h>
52 + #endif
53  
54   sg_mem_stats *sg_get_mem_stats(){
55  
56          static sg_mem_stats mem_stat;
57  
58 + #ifdef HPUX
59 +        struct pst_static pstat_static;
60 +        struct pst_dynamic pstat_dynamic;
61 +        long long pagesize;
62 + #endif
63   #ifdef SOLARIS
64          kstat_ctl_t *kc;
65          kstat_t *ksp;
# Line 75 | Line 85 | sg_mem_stats *sg_get_mem_stats(){
85          struct uvmexp *uvm;
86   #endif
87  
88 + #ifdef HPUX
89 +        if((pagesize=sysconf(_SC_PAGESIZE)) == -1){
90 +                sg_set_error_with_errno(SG_ERROR_SYSCONF, "_SC_PAGESIZE");
91 +                return NULL;
92 +        }
93 +
94 +        if (pstat_getdynamic(&pstat_dynamic, sizeof(pstat_dynamic), 1, 0) == -1) {
95 +                sg_set_error_with_errno(SG_ERROR_PSTAT, "pstat_dynamic");
96 +                return NULL;
97 +        }
98 +        if (pstat_getstatic(&pstat_static, sizeof(pstat_static), 1, 0) == -1) {
99 +                sg_set_error_with_errno(SG_ERROR_PSTAT, "pstat_static");
100 +                return NULL;
101 +        }
102 +
103 +        mem_stat.total = ((long long) pstat_static.physical_memory) * pagesize;
104 +        mem_stat.free = ((long long) pstat_dynamic.psd_free) * pagesize;
105 +        mem_stat.used = mem_stat.total - mem_stat.free;
106 + #endif
107   #ifdef SOLARIS
108          if((pagesize=sysconf(_SC_PAGESIZE)) == -1){
109                  sg_set_error_with_errno(SG_ERROR_SYSCONF, "_SC_PAGESIZE");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines