Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Nov 2013 11:40:15 +0000 (UTC)
From:      Boris Samorodov <bsam@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r332696 - in head/x11/fbpanel: . files
Message-ID:  <201311041140.rA4BeFMG045090@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bsam
Date: Mon Nov  4 11:40:15 2013
New Revision: 332696
URL: http://svnweb.freebsd.org/changeset/ports/332696

Log:
  . fix cpu plugin (core dumped without the fix);
  . bump PORTREVISION;
  . take maintainership.
  
  Submitted by:	bsam (me, via e-mail)
  Approved by:	nemysis (former maintainer)

Modified:
  head/x11/fbpanel/Makefile
  head/x11/fbpanel/files/patch-plugins__cpu__cpu.c

Modified: head/x11/fbpanel/Makefile
==============================================================================
--- head/x11/fbpanel/Makefile	Mon Nov  4 11:36:02 2013	(r332695)
+++ head/x11/fbpanel/Makefile	Mon Nov  4 11:40:15 2013	(r332696)
@@ -3,13 +3,13 @@
 
 PORTNAME=	fbpanel
 PORTVERSION=	6.1
-PORTREVISION=	2
+PORTREVISION=	3
 CATEGORIES=	x11
 MASTER_SITES=	SF
 EXTRACT_SUFX=	.tbz2
 
-MAINTAINER=	nemysis@gmx.ch
-COMMENT=	Lightweight, NETWM compliant X11 desktop panel
+MAINTAINER=	bsam@FreeBSD.org
+COMMENT=	Lightweight, NEtWM compliant X11 desktop panel
 
 LICENSE=	MIT
 

Modified: head/x11/fbpanel/files/patch-plugins__cpu__cpu.c
==============================================================================
--- head/x11/fbpanel/files/patch-plugins__cpu__cpu.c	Mon Nov  4 11:36:02 2013	(r332695)
+++ head/x11/fbpanel/files/patch-plugins__cpu__cpu.c	Mon Nov  4 11:40:15 2013	(r332696)
@@ -1,5 +1,5 @@
 --- ./plugins/cpu/cpu.c.orig	2010-03-07 00:14:04.000000000 -0800
-+++ ./plugins/cpu/cpu.c	2010-11-17 11:06:07.000000000 -0800
++++ ./plugins/cpu/cpu.c	2013-11-04 01:56:23.388313800 +0400
 @@ -18,9 +18,20 @@
   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
   *
@@ -22,24 +22,7 @@
  
  #include "misc.h"
  #include "../chart/chart.h"
-@@ -29,9 +40,16 @@
- #include "dbg.h"
- 
- /* cpu.c */
-+#if defined __FreeBSD__
-+struct cpu_stat {
-+    gulong u, n, s, i; // user, nice, system, idle
-+};
-+#else
- struct cpu_stat {
-     gulong u, n, s, i, w; // user, nice, system, idle, wait
- };
-+#endif
-+
- 
- typedef struct {
-     chart_priv chart;
-@@ -84,6 +102,65 @@
+@@ -84,6 +102,59 @@
      RET(TRUE);
  
  }
@@ -47,11 +30,11 @@
 +static int
 +cpu_get_load(cpu_priv * c)
 +{
-+	static int	mib[2] = {-1, -1}, init = 0, j, realhz;
++	static int	mib[2] = {-1, -1}, init = 0, j;
 +	long		ct[CPUSTATES];
 +
 +	gfloat		a      , b;
-+	struct cpu_stat	cpu, cpu_diff;
++	struct cpu_stat	cpu;
 +	float		total;
 +	gchar		buf[40];
 +
@@ -59,19 +42,16 @@
 +	total = 0;
 +
 +	if (init == 0) {
-+		struct clockinfo ci;
-+		j = sizeof(ci);
-+		if (sysctlbyname("kern.clockrate", &ci, &j, NULL, 0) == -1) {
-+			DBG("Couldn't get kern.clockrate");
-+			RET(FALSE);
-+		} else
-+			realhz = ci.stathz ? ci.stathz : ci.hz;
-+
 +		j = 2;
 +		if (sysctlnametomib("kern.cp_time", mib, &j) == -1) {
 +			DBG("Couldn't get mib for kern.cp_time");
 +			RET(FALSE);
 +		}
++		c->cpu_prev.u = 0;
++		c->cpu_prev.n = 0;
++		c->cpu_prev.s = 0;
++		c->cpu_prev.i = 0;
++		c->cpu_prev.w = 0;
 +		init = 1;
 +		j = sizeof(ct);
 +	}
@@ -79,20 +59,17 @@
 +		DBG("Couldn't get cpu stats");
 +		RET(FALSE);
 +	}
-+	cpu.u = ct[CP_USER] / realhz;
-+	cpu.n = ct[CP_NICE] / realhz;
-+	cpu.s = ct[CP_SYS] / realhz;
-+	cpu.i = ct[CP_IDLE] / realhz;
-+
-+	cpu_diff.u = cpu.u - c->cpu_prev.u;
-+	cpu_diff.n = cpu.n - c->cpu_prev.n;
-+	cpu_diff.s = cpu.s - c->cpu_prev.s;
-+	cpu_diff.i = cpu.i - c->cpu_prev.i;
-+	c->cpu_prev = cpu;
-+
-+	a = cpu_diff.u + cpu_diff.n + cpu_diff.s;
-+	b = a + cpu_diff.i;
-+	total = b ? a / b : 1.0;
++
++	a = ct[CP_USER] + ct[CP_NICE] + ct[CP_SYS] + ct[CP_INTR] -
++            (c->cpu_prev.u + c->cpu_prev.n + c->cpu_prev.s + c->cpu_prev.i);
++	b = a + ct[CP_IDLE] - c->cpu_prev.w;
++	total = b ? (float)a / b : 1.0;
++
++	c->cpu_prev.u = ct[CP_USER];
++	c->cpu_prev.n = ct[CP_NICE];
++	c->cpu_prev.s = ct[CP_SYS] ;
++	c->cpu_prev.i = ct[CP_INTR];
++	c->cpu_prev.w = ct[CP_IDLE];
 +
 +end:
 +	DBG("total=%f a=%f b=%f\n", total, a, b);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201311041140.rA4BeFMG045090>