1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-26 12:27:52 +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 ""; return "";
} }
char *get_freq() float get_freq()
{ {
/* First, try to obtain CPU frequency via dev.cpu.0.freq sysctl /* First, try to obtain CPU frequency via dev.cpu.0.freq sysctl
* (cpufreq(4)). If failed, do i386 magic. */ * (cpufreq(4)). If failed, do i386 magic. */
int freq; int freq;
char *cpuspeed;
if ((cpuspeed = malloc(8)) == NULL) if (GETSYSCTL("dev.cpu.0.freq", freq) == 0)
CRIT_ERR("get_freq()"); return (float)freq;
if (GETSYSCTL("dev.cpu.0.freq", freq) == 0) {
snprintf(cpuspeed, 8, "%d", freq);
return cpuspeed;
}
#if defined(i386) || defined(__i386__)
else { else {
#if defined(i386) || defined(__i386__)
int i; int i;
i = 0; i = 0;
if ((i = get_cpu_speed()) > 0) { if ((i = get_cpu_speed()) > 0) {
if (i < 1000000) { return (float)(i / 1000);
i += 50; /* for rounding */
snprintf(cpuspeed, 8, "%d.%d", i / 1000,
(i / 100) % 10);
} else } else
snprintf(cpuspeed, 8, "%d", i / 1000); return 0;
} else
cpuspeed = "";
return cpuspeed;
} }
#else #else
return ""; return 0;
}
#endif /* i386 */ #endif /* i386 */
} }