1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-25 12:10:03 +00:00

Make get_freq() return float.

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@168 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Roman Bogorodskiy 2005-08-24 20:52:55 +00:00
parent 5b5ec148b3
commit 632224e9c6

View File

@ -421,39 +421,27 @@ char *get_adt746x_fan()
return "";
}
char *get_freq()
float get_freq()
{
/* First, try to obtain CPU frequency via dev.cpu.0.freq sysctl
* (cpufreq(4)). If failed, do i386 magic. */
int freq;
char *cpuspeed;
if ((cpuspeed = malloc(8)) == NULL)
CRIT_ERR("get_freq()");
if (GETSYSCTL("dev.cpu.0.freq", freq) == 0) {
snprintf(cpuspeed, 8, "%d", freq);
return cpuspeed;
}
#if defined(i386) || defined(__i386__)
if (GETSYSCTL("dev.cpu.0.freq", freq) == 0)
return (float)freq;
else {
#if defined(i386) || defined(__i386__)
int i;
i = 0;
if ((i = get_cpu_speed()) > 0) {
if (i < 1000000) {
i += 50; /* for rounding */
snprintf(cpuspeed, 8, "%d.%d", i / 1000,
(i / 100) % 10);
} else
snprintf(cpuspeed, 8, "%d", i / 1000);
return (float)(i / 1000);
} else
cpuspeed = "";
return cpuspeed;
return 0;
}
#else
return "";
return 0;
}
#endif /* i386 */
}