src/jdk.management/solaris/native/libmanagement_ext/UnixOperatingSystem.c
branchihse-warnings-cflags-branch
changeset 56230 489867818774
parent 47216 71c04702a3d5
equal deleted inserted replaced
56229:0015bf3a82e0 56230:489867818774
    49 
    49 
    50 static cpuload_t   *cpu_loads = NULL;
    50 static cpuload_t   *cpu_loads = NULL;
    51 static unsigned int num_cpus;
    51 static unsigned int num_cpus;
    52 static kstat_ctl_t *kstat_ctrl = NULL;
    52 static kstat_ctl_t *kstat_ctrl = NULL;
    53 
    53 
    54 static void map_cpu_kstat_counters() {
    54 static void map_cpu_kstat_counters(void) {
    55     kstat_t     *kstat;
    55     kstat_t     *kstat;
    56     int          i;
    56     int          i;
    57 
    57 
    58     // Get number of CPU(s)
    58     // Get number of CPU(s)
    59     if ((num_cpus = sysconf(_SC_NPROCESSORS_ONLN)) == -1) {
    59     if ((num_cpus = sysconf(_SC_NPROCESSORS_ONLN)) == -1) {
    84             cpu_loads[i++].kstat = kstat;
    84             cpu_loads[i++].kstat = kstat;
    85         }
    85         }
    86     }
    86     }
    87 }
    87 }
    88 
    88 
    89 static int init_cpu_kstat_counters() {
    89 static int init_cpu_kstat_counters(void) {
    90     static int initialized = 0;
    90     static int initialized = 0;
    91 
    91 
    92     // Concurrence in this method is prevented by the lock in
    92     // Concurrence in this method is prevented by the lock in
    93     // the calling method get_cpu_load();
    93     // the calling method get_cpu_load();
    94     if(!initialized) {
    94     if(!initialized) {
    98         }
    98         }
    99     }
    99     }
   100     return initialized ? 0 : -1;
   100     return initialized ? 0 : -1;
   101 }
   101 }
   102 
   102 
   103 static void update_cpu_kstat_counters() {
   103 static void update_cpu_kstat_counters(void) {
   104     if(kstat_chain_update(kstat_ctrl) != 0) {
   104     if(kstat_chain_update(kstat_ctrl) != 0) {
   105         free(cpu_loads);
   105         free(cpu_loads);
   106         map_cpu_kstat_counters();
   106         map_cpu_kstat_counters();
   107     }
   107     }
   108 }
   108 }