Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/sysutils/conky conky: Make getting CPU freq work on mo...
details: https://anonhg.NetBSD.org/pkgsrc/rev/8c8413154e74
branches: trunk
changeset: 437711:8c8413154e74
user: nia <nia%pkgsrc.org@localhost>
date: Sun Aug 30 11:04:48 2020 +0000
description:
conky: Make getting CPU freq work on more NetBSD systems (notably mine)
diffstat:
sysutils/conky/Makefile | 4 +-
sysutils/conky/distinfo | 4 +-
sysutils/conky/patches/patch-src_netbsd.c | 286 +++++++++++++++--------------
3 files changed, 153 insertions(+), 141 deletions(-)
diffs (truncated from 476 to 300 lines):
diff -r 3199d0aa5ece -r 8c8413154e74 sysutils/conky/Makefile
--- a/sysutils/conky/Makefile Sun Aug 30 10:42:58 2020 +0000
+++ b/sysutils/conky/Makefile Sun Aug 30 11:04:48 2020 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.50 2020/08/27 11:25:29 nia Exp $
+# $NetBSD: Makefile,v 1.51 2020/08/30 11:04:48 nia Exp $
#
DISTNAME= conky-1.9.0
-PKGREVISION= 43
+PKGREVISION= 44
CATEGORIES= sysutils
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=conky/}
EXTRACT_SUFX= .tar.bz2
diff -r 3199d0aa5ece -r 8c8413154e74 sysutils/conky/distinfo
--- a/sysutils/conky/distinfo Sun Aug 30 10:42:58 2020 +0000
+++ b/sysutils/conky/distinfo Sun Aug 30 11:04:48 2020 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.8 2020/08/27 11:25:29 nia Exp $
+$NetBSD: distinfo,v 1.9 2020/08/30 11:04:48 nia Exp $
SHA1 (conky-1.9.0.tar.bz2) = 2069cbdb8e7224fcbf3c6b1ddebf64a51634b4cc
RMD160 (conky-1.9.0.tar.bz2) = 2df0e60d4236ed667bdae876e11ba28d05914e25
@@ -11,7 +11,7 @@
SHA1 (patch-src_conky.c) = e4c9173661cca437af0febbcae94eec72dc0ea4a
SHA1 (patch-src_core.c) = a64ff7cb05d7b6b62aea41e486c0a719e2c93faf
SHA1 (patch-src_fs.c) = 104fd3788f319689026702d6a149410184072e24
-SHA1 (patch-src_netbsd.c) = 3cacc27e8ae6e20fe70385b764928767dab289d7
+SHA1 (patch-src_netbsd.c) = d9a23952c51eaa711b14c36f2b354972cd0b89bc
SHA1 (patch-src_netbsd.h) = dee5c466ab5cc267f1da94848b0a8b598303dfe4
SHA1 (patch-src_read__tcp.c) = 32fca1b7fdfdb2568b056705c7129807e281b0cc
SHA1 (patch-src_text__object.h) = 7f7e3684e21f9618a8ede37525f4a48f47a92050
diff -r 3199d0aa5ece -r 8c8413154e74 sysutils/conky/patches/patch-src_netbsd.c
--- a/sysutils/conky/patches/patch-src_netbsd.c Sun Aug 30 10:42:58 2020 +0000
+++ b/sysutils/conky/patches/patch-src_netbsd.c Sun Aug 30 11:04:48 2020 +0000
@@ -1,10 +1,10 @@
-$NetBSD: patch-src_netbsd.c,v 1.4 2020/08/27 11:25:29 nia Exp $
+$NetBSD: patch-src_netbsd.c,v 1.5 2020/08/30 11:04:48 nia Exp $
Many fixes and addons for conky to work on NetBSD.
--- src/netbsd.c.orig 2012-05-03 21:08:27.000000000 +0000
+++ src/netbsd.c
-@@ -30,337 +30,803 @@
+@@ -30,337 +30,815 @@
#include "netbsd.h"
#include "net_stat.h"
@@ -12,17 +12,28 @@
+#include <sys/types.h>
+#include <sys/statvfs.h>
+#include <ifaddrs.h>
-
--static kvm_t *kd = NULL;
--int kd_init = 0, nkd_init = 0;
--u_int32_t sensvalue;
--char errbuf[_POSIX2_LINE_MAX];
++
+#define P_BOOL 0
+#define P_UINT8 1
+#define P_INT64 2
+#define P_STRING 3
-
--static int init_kvm(void)
++
++static char const *freq_sysctls[] = {
++#if defined(__powerpc__)
++ "machdep.intrepid.frequency.current",
++#endif
++#if defined(__mips__)
++ "machdep.loongson.frequency.current",
++#endif
++#if defined(__i386__) || defined(__x86_64__)
++ "machdep.est.frequency.current",
++ "machdep.powernow.frequency.current",
++#endif
++ "machdep.cpu.frequency.current",
++ "machdep.frequency.current",
++ NULL
++};
++
+typedef struct Devquery {
+ int type;
+ char *dev;
@@ -35,9 +46,14 @@
+static short cpu_setup = 0;
+
+int sysmon_fd;
-+
+
+-static kvm_t *kd = NULL;
+-int kd_init = 0, nkd_init = 0;
+-u_int32_t sensvalue;
+-char errbuf[_POSIX2_LINE_MAX];
+static inline void proc_find_top(struct process **cpu, struct process **mem);
-+
+
+-static int init_kvm(void)
+int8_t envsys_get_val(Devquery, void *);
+
+void
@@ -146,7 +162,9 @@
+ * report inactive memory as memeasyfree.
+ */
+ info.memeasyfree -= info.bufmem;
-+
+
+- if (sep == NULL) {
+- warn("memory allocation failed");
+ return 0;
+}
+
@@ -158,9 +176,7 @@
+ long long r, t, last_recv, last_trans;
+ struct ifaddrs *ifap, *ifa;
+ struct if_data *ifd;
-
-- if (sep == NULL) {
-- warn("memory allocation failed");
++
+ /* get delta */
+ delta = current_update_time - last_update_time;
+ if (delta <= 0.0001) {
@@ -434,7 +450,8 @@
+ total += cp_time[j];
+
+ used = total - cp_time[CP_IDLE];
-+
+
+- ns->last_read_recv = ifnet.if_ibytes;
+ if ((total - cpu[0].oldtotal) != 0) {
+ info.cpu_usage[0] = ((double) (used - cpu[0].oldused)) /
+ (double) (total - cpu[0].oldtotal);
@@ -462,12 +479,11 @@
+ for (j = 0; j < CPUSTATES; j++)
+ total += cp_time[i*CPUSTATES + j];
-- ns->last_read_recv = ifnet.if_ibytes;
-+ used = total - cp_time[i*CPUSTATES + CP_IDLE];
-
- if (ifnet.if_obytes < ns->last_read_trans) {
- ns->trans += ((long long) 4294967295U - ns->last_read_trans) +
- ifnet.if_obytes;
++ used = total - cp_time[i*CPUSTATES + CP_IDLE];
++
+ if ((total - cpu[i+1].oldtotal) != 0) {
+ info.cpu_usage[i+1] = ((double) (used - cpu[i+1].oldused)) /
+ (double) (total - cpu[i+1].oldtotal);
@@ -492,111 +508,85 @@
+int update_load_average(void)
+{
+ double v[3];
-+
-+ getloadavg(v, 3);
- ns->recv_speed = (ns->recv - last_recv) / delta;
- ns->trans_speed = (ns->trans - last_trans) / delta;
+- }
++ getloadavg(v, 3);
++
+ info.loadavg[0] = (float) v[0];
+ info.loadavg[1] = (float) v[1];
+ info.loadavg[2] = (float) v[2];
+
+ return 0;
-+}
-+
+ }
+
+-void update_total_processes()
+int open_acpi_temperature(const char *name)
-+{
+ {
+- /* It's easier to use kvm here than sysctl */
+ (void)name; /* useless on NetBSD */
+ return -1;
+}
-+
+
+- int n_processes;
+int get_entropy_avail(unsigned int *val)
+{
+ return 1;
+}
-+
+
+- info.procs = 0;
+int get_entropy_poolsize(unsigned int *val)
+{
+ return 1;
+}
-+
-+/* void */
-+char
-+get_freq(char *p_client_buffer, size_t client_buffer_size,
-+ const char *p_format, int divisor, unsigned int cpu)
-+{
-+ int freq = cpu;
-+
-+ if (!p_client_buffer || client_buffer_size <= 0 || !p_format
-+ || divisor <= 0) {
-+ return 0;
- }
-+
-+ size_t size = sizeof(freq);
-+
-+ if (sysctlbyname("machdep.est.frequency.current",
-+ NULL, &size, NULL, 0) == 0) {
-+ sysctlbyname("machdep.est.frequency.current", &freq, &size, NULL, 0);
-+ snprintf(p_client_buffer, client_buffer_size, p_format,
-+ (float) freq / divisor);
-+ } else if (sysctlbyname("machdep.tsc_freq", NULL, &size, NULL, 0) == 0) {
-+ sysctlbyname("machdep.tsc_freq", &freq, &size, NULL, 0);
-+ snprintf(p_client_buffer, client_buffer_size, p_format,
-+ (float) freq / (1000000 * divisor));
-+ } else
-+ snprintf(p_client_buffer, client_buffer_size, p_format, 0.0f);
-+
-+ return 1;
- }
-
--void update_total_processes()
-+void update_diskio()
- {
-- /* It's easier to use kvm here than sysctl */
-+ return; /* XXX: implement? hifi: not sure how */
-+}
-
-- int n_processes;
-+int update_top()
-+{
-+ proc_find_top(info.cpu, info.memu);
-
-- info.procs = 0;
-+ return 0;
-+}
- if (init_kvm() < 0) {
- return;
-- } else {
++char
++get_freq(char *p_client_buffer, size_t client_buffer_size,
++ const char *p_format, int divisor, unsigned int cpu) {
++ const char **s;
++ char name[64];
++ int freq = 0;
++ size_t freq_size = sizeof(freq);
++
++ snprintf(name, sizeof(name), "machdep.cpufreq.cpu%u.current", cpu - 1);
++ if (sysctlbyname(name, &freq, &freq_size, NULL, 0) == -1) {
++ for (s = freq_sysctls; *s != NULL; ++s) {
++ if (sysctlbyname(*s, &freq, &freq_size, NULL, 0) != -1)
++ break;
++ }
++ }
++ if (freq > 0) {
++ snprintf(p_client_buffer, client_buffer_size, p_format,
++ (float)freq / divisor);
+ } else {
- kvm_getproc2(kd, KERN_PROC_ALL, 0, sizeof(struct kinfo_proc2),
- &n_processes);
-+int comparecpu(const void *a, const void *b)
-+{
-+ if (((struct process *) a)->amount > ((struct process *) b)->amount) {
-+ return -1;
-+ }
-+ if (((struct process *) a)->amount < ((struct process *) b)->amount) {
-+ return 1;
++ snprintf(p_client_buffer, client_buffer_size, p_format, 0.0f);
}
++ return 1;
++}
- info.procs = n_processes;
-+ return 0;
++
++void update_diskio()
++{
++ return; /* XXX: implement? hifi: not sure how */
}
-void update_running_processes()
-+int comparemem(const void *a, const void *b)
++int update_top()
{
- struct kinfo_proc2 *p;
- int n_processes;
- int i, cnt = 0;
-+ if (((struct process *) a)->rss > ((struct process *) b)->rss) {
-+ return -1;
-+ }
++ proc_find_top(info.cpu, info.memu);
- info.run_procs = 0;
-+ if (((struct process *) a)->rss < ((struct process *) b)->rss) {
-+ return 1;
-+ }
++ return 0;
++}
Home |
Main Index |
Thread Index |
Old Index