[Pkg-wmaker-commits] [wmbubble] 197/207: flanderize

Doug Torrance dtorrance-guest at moszumanska.debian.org
Mon Aug 24 04:18:34 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmbubble.

commit ce1573abcc0c3cf2a41f20dccdef3bfd2d662c6e
Author: Robert Jacobs <rnjacobs at mit.edu>
Date:   Fri Dec 19 14:39:49 2014 -0800

    flanderize
---
 bubblemon.c |  6 +++---
 sys_linux.c | 31 ++++++++++++++++++++++---------
 2 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/bubblemon.c b/bubblemon.c
index a8c8e5e..15754fc 100644
--- a/bubblemon.c
+++ b/bubblemon.c
@@ -625,7 +625,7 @@ void make_new_bubblemon_dockapp(void) {
 	build_graphs();
 
 	sscanf(datefont_xpm[0],"%u %u %u %u",&maxwidth,&yy,&datefont_offset,&cc);
-	if (cc != 1) abort(); /* fuck that */
+	if (cc != 1) abort(); /* wat */
 
 	datefont_offset++; /* include header line */
 
@@ -885,7 +885,7 @@ void draw_from_xpm(char **xpm, unsigned char *whither, unsigned int targetw,
 	char transparent=0;
 
 	sscanf(xpm[0],"%u %u %u %u",&xx,&yy,&ncolors,&cpp);
-	if (cpp != 1) abort(); /* fuck that */
+	if (cpp != 1) abort(); /* wat */
 	if (xpmx+xpmw > xx || xpmy+xpmh > yy) return;
 
 	for (yy=1;yy<=ncolors;yy++) {
@@ -1049,7 +1049,7 @@ void roll_history(void)  {
 void draw_cpudigit(int what, unsigned char *whither) {
 	unsigned int y;
 	unsigned char *from = digits + what * 3 * 6;;
-	for (y = 0; y < 9; y++) { /* magic numbers suck. */
+	for (y = 0; y < 9; y++) { /* magic numbers :( */
 		memcpy(whither,from,21);
 		whither += 3*25;
 		from += 3*95;
diff --git a/sys_linux.c b/sys_linux.c
index 7b34e09..1d6b309 100644
--- a/sys_linux.c
+++ b/sys_linux.c
@@ -35,6 +35,18 @@ int system_cpu(void) {
 	FILE *stat;
 
 	stat = fopen("/proc/stat", "r");
+	/* first row: across all cores; first columns: "cpu"
+	   subsequent columns:
+    user: normal processes executing in user mode
+    nice: niced processes executing in user mode
+    system: processes executing in kernel mode
+    idle: twiddling thumbs
+    iowait: waiting for I/O to complete
+    irq: servicing interrupts
+    softirq: servicing softirqs
+
+    for some reason we ignore iowait, irq, and softirq. is that reasonable?
+ */
 	if (fscanf(stat, "%*s %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64,
 		   &ab, &ac, &ad, &ae) == EOF) {
 		fprintf(stderr, "EOF when reading /proc/stat\n");
@@ -48,7 +60,7 @@ int system_cpu(void) {
 	load = ab + ac + ad;	/* cpu.user + cpu.sys; */
 	total = ab + ac + ad + ae;	/* cpu.total; */
 
-	/* "i" is an index into a load history */
+	/* circular buffer; "i" is an index into a load history */
 	i = bm.loadIndex;
 	oload = bm.load[i];
 	ototal = bm.total[i];
@@ -58,10 +70,11 @@ int system_cpu(void) {
 	bm.loadIndex = (i + 1) % bm.samples;
 
 	/*
-	  Because the load returned from libgtop is a value accumulated
-	  over time, and not the current load, the current load percentage
-	  is calculated as the extra amount of work that has been performed
-	  since the last sample. yah, right, what the fuck does that mean?
+	  Because the load above is an accumulated value over time, and not the
+	  current load, the current load percentage is calculated as the extra
+	  amount of work that has been performed since the last sample.
+
+	  In this case, we compare the current numbers to "bm.samples" ago.
 	*/
 	if (ototal == 0)		/* ototal == 0 means that this is the first time we get here */
 		cpuload = 0;
@@ -78,19 +91,19 @@ void system_memory(void) {
 	FILE *mem;
 
 	/* put this in permanent storage instead of stack */
-	static char shit[2048];
+	static char meminfo[2048];
 
 	/* we might as well get both swap and memory at the same time.
 	 * sure beats opening the same file twice */
 	mem = fopen("/proc/meminfo", "r");
-	memset(shit, 0, sizeof(shit));
-	if (fread(shit, 2048, 1, mem) < 2048) {
+	memset(meminfo, 0, sizeof(meminfo));
+	if (fread(meminfo, 2048, 1, mem) < 2048) {
 		if (ferror(mem)) {
 			fprintf(stderr, "error reading /proc/meminfo\n");
 			return;
 		}
 	}
-	p = strstr(shit, "MemTotal");
+	p = strstr(meminfo, "MemTotal");
 	if (p) {
 		sscanf(p, "MemTotal:%"PRIu64, &bm.mem_max);
 		bm.mem_max <<= 10;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbubble.git



More information about the Pkg-wmaker-commits mailing list