void abstract_cpu::account_freq(uint64_t freq, uint64_t duration) { struct frequency *state = NULL; unsigned int i; for (i = 0; i < pstates.size(); i++) { if (freq == pstates[i]->freq) { state = pstates[i]; break; } } if (!state) { state = new(std::nothrow) struct frequency; if (!state) return; memset(state, 0, sizeof(*state)); pstates.push_back(state); state->freq = freq; hz_to_human(freq, state->human_name); if (freq == 0) strcpy(state->human_name, _("Idle")); if (is_turbo(freq, max_frequency, max_minus_one_frequency)) sprintf(state->human_name, _("Turbo Mode")); state->after_count = 1; } state->time_after += duration; }
static char *HzToHuman(unsigned long hz) { static char buffer[1024]; memset(buffer, 0, 1024); unsigned long long Hz; Hz = hz; /* default: just put the Number in */ sprintf(buffer,_("%9lli"), Hz); if (Hz>1000) sprintf(buffer, _("%6lli Mhz"), (Hz+500)/1000); if (Hz>1500000) sprintf(buffer, _("%6.2f Ghz"), (Hz+5000.0)/1000000); if (is_turbo(hz)) sprintf(buffer, "%s", _("Turbo Mode")); return buffer; }