| 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; |
| 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"); |