mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-26 04:17:33 +00:00
- On FreeBSD, first try dev.cpu.0.freq sysctl (see cpufreq(4) for details)
to detect CPU frequency and only then do i386 magic - Minor cleanup git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@159 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
79e6886e1c
commit
9c56581089
@ -1,4 +1,9 @@
|
||||
#include "conky.h"
|
||||
/** freebsd.c
|
||||
* Contains FreeBSD specific stuff
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
@ -20,6 +25,8 @@
|
||||
#include <sys/socket.h>
|
||||
#include <ifaddrs.h>
|
||||
|
||||
#include "conky.h"
|
||||
|
||||
#define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var))
|
||||
#define KELVTOC(x) ((x - 2732) / 10.0)
|
||||
|
||||
@ -59,8 +66,7 @@ static unsigned int get_cpu_speed(void)
|
||||
|
||||
return ((tscstop - tscstart) / ((stop - start) / 1000.0));
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* i386 */
|
||||
|
||||
static int getsysctl(char *name, void *ptr, size_t len)
|
||||
{
|
||||
@ -80,7 +86,6 @@ static kvm_t *kd = NULL;
|
||||
struct ifmibdata *data = NULL;
|
||||
size_t len = 0;
|
||||
|
||||
|
||||
static int swapmode(int *retavail, int *retfree)
|
||||
{
|
||||
int n;
|
||||
@ -119,12 +124,10 @@ static int swapmode(int *retavail, int *retfree)
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
void prepare_update()
|
||||
{
|
||||
}
|
||||
|
||||
/*double get_uptime() */
|
||||
void update_uptime()
|
||||
{
|
||||
int mib[2] = { CTL_KERN, KERN_BOOTTIME };
|
||||
@ -142,7 +145,6 @@ void update_uptime()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void update_meminfo()
|
||||
{
|
||||
int total_pages, inactive_pages, free_pages;
|
||||
@ -237,8 +239,6 @@ void update_net_stats()
|
||||
|
||||
void update_total_processes()
|
||||
{
|
||||
/* It's easier to use kvm here than sysctl */
|
||||
|
||||
int n_processes;
|
||||
static int kd_init = 1;
|
||||
|
||||
@ -423,31 +423,38 @@ char *get_adt746x_fan()
|
||||
|
||||
char *get_freq()
|
||||
{
|
||||
#if defined(i386) || defined(__i386__)
|
||||
int i;
|
||||
/* 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 = (char *) malloc(16)) == NULL) {
|
||||
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__)
|
||||
else {
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
if ((i = get_cpu_speed()) > 0) {
|
||||
if (i < 1000000) {
|
||||
i += 50; /* for rounding */
|
||||
snprintf(cpuspeed, 15, "%d.%d MHz", i / 1000,
|
||||
snprintf(cpuspeed, 8, "%d.%d", i / 1000,
|
||||
(i / 100) % 10);
|
||||
} else {
|
||||
snprintf(cpuspeed, 15, "%d MHz", i / 1000);
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
snprintf(cpuspeed, 8, "%d", i / 1000);
|
||||
} else
|
||||
cpuspeed = "";
|
||||
}
|
||||
|
||||
return cpuspeed;
|
||||
}
|
||||
#else
|
||||
return "";
|
||||
#endif
|
||||
#endif /* i386 */
|
||||
}
|
||||
|
||||
void update_top()
|
||||
|
Loading…
Reference in New Issue
Block a user