diff --git a/src/os/solaris/sigar_os.h b/src/os/solaris/sigar_os.h index e54c8ac1..124fd005 100644 --- a/src/os/solaris/sigar_os.h +++ b/src/os/solaris/sigar_os.h @@ -259,11 +259,19 @@ struct sigar_t { #define KSTAT_UINT ui32 #endif -#define kSTAT_uint(v, type) \ - ((sigar->koffsets.type[v] == -2) ? 0 : \ - ((kstat_named_t *)ksp->ks_data + sigar->koffsets.type[v])->value.KSTAT_UINT) +#define kSTAT_exists(v, type) \ + (sigar->koffsets.type[v] != -2) -#define kSYSTEM(v) kSTAT_uint(v, system) +#define kSTAT_ptr(v, type) \ + ((kstat_named_t *)ksp->ks_data + sigar->koffsets.type[v]) + +#define kSTAT_uint(v, type) \ + (kSTAT_exists(v, type) ? kSTAT_ptr(v, type)->value.KSTAT_UINT : 0) + +#define kSTAT_ui32(v, type) \ + (kSTAT_exists(v, type) ? kSTAT_ptr(v, type)->value.ui32 : 0) + +#define kSYSTEM(v) kSTAT_ui32(v, system) #define kMEMPAGES(v) kSTAT_uint(v, mempages) diff --git a/src/os/solaris/solaris_sigar.c b/src/os/solaris/solaris_sigar.c index 3e9761df..cf85eb7c 100644 --- a/src/os/solaris/solaris_sigar.c +++ b/src/os/solaris/solaris_sigar.c @@ -358,7 +358,7 @@ int sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist) { kstat_ctl_t *kc = sigar->kc; kstat_t *ksp; - ulong cpuinfo[CPU_STATES]; + uint_t cpuinfo[CPU_STATES]; unsigned int i; int is_debug = SIGAR_LOG_IS_DEBUG(sigar); int reported_virtual = 0;