get cpu mhz for darwin
This commit is contained in:
		
							parent
							
								
									1921b62a7b
								
							
						
					
					
						commit
						c7061cc660
					
				@ -1350,12 +1350,16 @@ int sigar_cpu_info_list_get(sigar_t *sigar,
 | 
			
		||||
    char model[128], vendor[128], *ptr;
 | 
			
		||||
 | 
			
		||||
    size = sizeof(mhz);
 | 
			
		||||
    if (!sysctlbyname(CTL_HW_FREQ, &mhz, &size, NULL, 0)) {
 | 
			
		||||
        mhz /= 1000000;
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
    if (sysctlbyname(CTL_HW_FREQ, &mhz, &size, NULL, 0) < 0) {
 | 
			
		||||
        int mib[] = { CTL_HW, HW_CPU_FREQ };
 | 
			
		||||
        size = sizeof(mhz);
 | 
			
		||||
        if (sysctl(mib, NMIB(mib), &mhz, &size, NULL, 0) < 0) {
 | 
			
		||||
            mhz = SIGAR_FIELD_NOTIMPL;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if (mhz != SIGAR_FIELD_NOTIMPL) {
 | 
			
		||||
        mhz /= 1000000;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    size = sizeof(model);
 | 
			
		||||
    if (sysctlbyname("hw.model", &model, &size, NULL, 0) == -1) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user