Gentoo Archives: gentoo-commits

From: "Bernard Cafarelli (voyageur)" <voyageur@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in x11-plugins/wmfire/files: wmfire-1.2.4-lastprocessor_SMP.patch
Date: Mon, 27 Feb 2012 14:58:44
Message-Id: 20120227145833.B8E552004C@flycatcher.gentoo.org
1 voyageur 12/02/27 14:58:33
2
3 Added: wmfire-1.2.4-lastprocessor_SMP.patch
4 Log:
5 Fix display for SMP systems, report and patch by wbk in bug #404323
6
7 (Portage version: 2.2.0_alpha89/cvs/Linux x86_64)
8
9 Revision Changes Path
10 1.1 x11-plugins/wmfire/files/wmfire-1.2.4-lastprocessor_SMP.patch
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/x11-plugins/wmfire/files/wmfire-1.2.4-lastprocessor_SMP.patch?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/x11-plugins/wmfire/files/wmfire-1.2.4-lastprocessor_SMP.patch?rev=1.1&content-type=text/plain
14
15 Index: wmfire-1.2.4-lastprocessor_SMP.patch
16 ===================================================================
17 --- wmfire-1.2.4/src/wmfire.c.orig 2005-12-04 11:39:16.000000000 +0100
18 +++ wmfire-1.2.4/src/wmfire.c 2012-02-27 15:48:05.136807354 +0100
19 @@ -63,6 +63,10 @@
20 #define FIRE_NET 3
21 #define FIRE_FILE 4
22
23 +/* wbk 20120220 - cleaning up "next cpu" logic */
24 +#define CPU_AV -1 /* needs to be 1st CPU - 1 */
25 +#define CPU_NEXT -2 /* arbitrary but must be < CPU_AV */
26 +
27 #define NET_SPD_PPP 56
28 #define NET_SPD_ETH 100
29
30 @@ -104,7 +108,8 @@
31 int update_mem();
32 int update_net();
33 int update_file();
34 -int change_cpu(int);
35 +void change_cpu(int);
36 +int more_cpus();
37 void change_flame(int);
38 GdkCursor *setup_cursor();
39 void burn_spot(int, int, int);
40 @@ -130,8 +135,7 @@
41
42 int monitor = FIRE_CPU;
43 int load = 100;
44 -int cpu_av = 1;
45 -int cpu_id = 0;
46 +int cpu_id = CPU_AV; /* wbk - special value instead of separate flag */
47 int cpu_nice = 1;
48 char net_dev[16] = "ppp0";
49 int net_spd = 0;
50 @@ -224,8 +228,15 @@
51 next = 0;
52
53 if (!lock) {
54 - if (monitor == FIRE_CPU && change_cpu(-1))
55 - monitor = FIRE_MEM;
56 + if (monitor == FIRE_CPU)
57 + {
58 + /* First, check if we have more CPU's to monitor. If none, *
59 + * move along to FIRE_MEM. Regardless, after this check, we *
60 + * call change_cpu() to increment or reset CPU number. */
61 + if (!more_cpus())
62 + monitor = FIRE_MEM;
63 + change_cpu(CPU_NEXT);
64 + }
65 else if (monitor == FIRE_MEM)
66 monitor = FIRE_NET;
67 else if (monitor == FIRE_NET)
68 @@ -285,7 +296,7 @@
69
70 glibtop_get_cpu(&cpu);
71
72 - if (cpu_av) {
73 + if (cpu_id == CPU_AV) {
74 if (cpu_nice)
75 load = cpu.user + cpu.nice + cpu.sys;
76 else
77 @@ -383,30 +394,46 @@
78 /* Change CPU monitor */
79 /******************************************/
80
81 -int
82 +void
83 change_cpu(int which)
84 {
85 - glibtop_cpu cpu;
86 + /* wbk 20120221 - Changed return type to void. Use more_cpus() *
87 + * for tests instead. Mixing test logic with changing the CPU *
88 + * was causing CPU's to be skipped in calling function. */
89
90 + /* wbk - Even though we never use the cpu struct, I think this *
91 + * call may be necessary to set up glibtop_global_server? */
92 + glibtop_cpu cpu;
93 glibtop_get_cpu(&cpu);
94
95 /* This should work, but I have a lonely uniprocessor system */
96 + /* wbk - tested with a quad core. */
97
98 - if (which >= 0) {
99 + if (which != CPU_NEXT) /* was run with command-line CPU specifier */
100 cpu_id = which;
101 - cpu_av = 0;
102 - } else {
103 - cpu_id++;
104 - cpu_av = 0;
105 - }
106 + else /* negative value "special case" for which */
107 + cpu_id++;
108
109 - if (cpu_id >= glibtop_global_server->ncpu || cpu_id >= GLIBTOP_NCPU) {
110 - cpu_id = 0;
111 - cpu_av = 1;
112 - return 1;
113 - }
114 + /* Since we already incremented cpu_id, we are comparing a *
115 + * 1-index with 0-index value essentially. But since GLIBTOP_NCPU *
116 + * is 1-indexed, keep >= for it. (a bit of an oversimplification: *
117 + * cpu_id is still definitely regarded as 0-indexed elsewhere. We *
118 + * index an array with it later, so this is important) */
119 + if (cpu_id > glibtop_global_server->ncpu || cpu_id >= GLIBTOP_NCPU)
120 + cpu_id = CPU_AV;
121
122 - return 0;
123 + return;
124 +}
125 +
126 +int
127 +more_cpus()
128 +{
129 + /* returns positive if next CPU would be valid, Negative if *
130 + * already monitoring highest-numbered CPU or if more cores than *
131 + * glibtop supports. */
132 + int next_cpu = cpu_id + 1;
133 + return !(next_cpu > glibtop_global_server->ncpu
134 + || next_cpu >= GLIBTOP_NCPU);
135 }
136
137 /******************************************/
138 @@ -494,7 +521,7 @@
139 if (proximity++ > 100) {
140
141 if (monitor == FIRE_CPU) {
142 - if (cpu_av) {
143 + if (cpu_id == CPU_AV) {
144 /* Horizontal bar for average cpu */
145 memset(&bm.cmap[27 * XMAX + 20], 255, 16);
146 memset(&bm.cmap[28 * XMAX + 20], 255, 16);