Hi all,
Solaris 10
gcc 3.4.5 (blastwave package)
The following code works fine when compiled with -m32. However, when
compiled with -m64 the load average values are totally wonky (as in
huge, wrong numbers). I tinkered with changing the cast, but that
didn't seem to matter. Any ideas?
/* loadavgtest.c
*
* Built with gcc -Wall -lkstat -m64 loadavgtest.c -o loadavgtest
*/
#include <stdio.h>
#include <kstat.h>
int main(){
kstat_ctl_t* kc;
kstat_t* ksp;
kstat_named_t* kn1;
kstat_named_t* kn5;
kstat_named_t* kn15;
kc = kstat_open();
if(kc == 0){
printf("kstat_open() error\n");
return -1;
}
ksp = kstat_lookup(kc, "unix", 0, "system_misc");
if(ksp == 0){
printf("kstat_lookup() error\n");
return -1;
}
if(kstat_read(kc,ksp,0) == -1){
printf("kstat_read() error\n");
return -1;
}
kn1 = kstat_data_lookup(ksp, "avenrun_1min");
kn5 = kstat_data_lookup(ksp, "avenrun_5min");
kn15 = kstat_data_lookup(ksp, "avenrun_15min");
if( (kn1 == 0) || (kn5 == 0) || (kn15 == 0) ){
printf("kstat_lookup() error\n");
return -1;
}
printf("1 val: %f\n", (double)kn1->value.ul/256);
printf("5 val: %f\n", (double)kn1->value.ul/256);
printf("15 val: %f\n", (double)kn1->value.ul/256);
return 0;
Thanks,Quote:}
Dan