Gentoo Archives: gentoo-commits

From: "Jeremy Olexa (darkside)" <darkside@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in x11-plugins/wmload/files: wmload-0.9.2-prefix.patch wmload.solaris.patch
Date: Wed, 25 Aug 2010 15:54:08
Message-Id: 20100825155404.87A4020051@flycatcher.gentoo.org
1 darkside 10/08/25 15:54:04
2
3 Added: wmload-0.9.2-prefix.patch wmload.solaris.patch
4 Log:
5 Migrate changes from Gentoo Prefix overlay. KEYWORDS, EAPI3, specific patches. Approved by maintainer. Also respect LDFLAGS as an extra QA commit.
6 (Portage version: 2.1.8.3/cvs/Linux x86_64)
7
8 Revision Changes Path
9 1.1 x11-plugins/wmload/files/wmload-0.9.2-prefix.patch
10
11 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/x11-plugins/wmload/files/wmload-0.9.2-prefix.patch?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/x11-plugins/wmload/files/wmload-0.9.2-prefix.patch?rev=1.1&content-type=text/plain
13
14 Index: wmload-0.9.2-prefix.patch
15 ===================================================================
16 --- Imakefile
17 +++ Imakefile
18 @@ -2,7 +2,7 @@
19 DESTDIR = /usr/local
20 BINDIR = /bin
21
22 -XPMLIB = -L/usr/lib/X11 -lXpm -lm
23 +XPMLIB = `pkg-config xpm --libs` -lm
24 DEPLIBS = $(DEPXLIB)
25
26 LOCAL_LIBRARIES = $(XPMLIB) $(XLIB)
27
28
29
30 1.1 x11-plugins/wmload/files/wmload.solaris.patch
31
32 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/x11-plugins/wmload/files/wmload.solaris.patch?rev=1.1&view=markup
33 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/x11-plugins/wmload/files/wmload.solaris.patch?rev=1.1&content-type=text/plain
34
35 Index: wmload.solaris.patch
36 ===================================================================
37 * original: http://www.rampant.org/~dp/software/wmload.solaris.patch
38
39 --- wmload.c
40 +++ wmload.c
41 @@ -6,6 +6,11 @@
42 #include <math.h>
43 #include <fcntl.h>
44 #include <X11/Xatom.h>
45 +#ifdef sun
46 +#include <sys/types.h>
47 +#include <sys/sysinfo.h>
48 +#include <kstat.h>
49 +#endif
50
51 #include "back.xpm"
52 #include "mask2.xbm"
53 @@ -214,7 +219,7 @@
54 NormalGC = XCreateGC(dpy, Root, gcm, &gcv);
55
56 if (ONLYSHAPE) { /* try to make shaped window here */
57 - pixmask = XCreateBitmapFromData(dpy, win, mask2_bits, mask2_width,
58 + pixmask = XCreateBitmapFromData(dpy, win, (char *)mask2_bits, mask2_width,
59 mask2_height);
60 XShapeCombineMask(dpy, win, ShapeBounding, 0, 0, pixmask, ShapeSet);
61 XShapeCombineMask(dpy, iconwin, ShapeBounding, 0, 0, pixmask, ShapeSet);
62 @@ -410,6 +415,107 @@
63 return (char *)p;
64 }
65
66 +#ifdef sun
67 +
68 +static kstat_ctl_t *kc;
69 +static kstat_t **cpu_ksp_list;
70 +static int ncpus;
71 +
72 +void
73 +cpu_stats_init()
74 +{
75 + int i = 0;
76 + kstat_t *ksp;
77 + static int kstats_ready = 0;
78 +
79 + if (!kstats_ready) {
80 + if ((kc = kstat_open()) == NULL) {
81 + fprintf(stderr,"wmload: can't open /dev/kstat\n");
82 + exit (1);
83 + }
84 + kstats_ready = 1;
85 + }
86 +
87 + for (ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) {
88 + if (strcmp(ksp->ks_module, "cpu_stat") == 0)
89 + i++;
90 + }
91 +
92 + if (cpu_ksp_list) {
93 + free(cpu_ksp_list);
94 + }
95 + cpu_ksp_list = (kstat_t **) calloc(i * sizeof (kstat_t *), 1);
96 + ncpus = i;
97 +
98 + /*
99 + * stash the ksp for each CPU.
100 + */
101 + i = 0;
102 + for (ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) {
103 + if (strcmp(ksp->ks_module, "cpu_stat") == 0) {
104 + cpu_ksp_list[i] = ksp;
105 + i++;
106 + }
107 + }
108 +}
109 +
110 +int
111 +get_cpu_stats()
112 +{
113 + int i;
114 + cpu_stat_t stat;
115 + static int firsttime = 1;
116 +
117 + if (firsttime) {
118 + firsttime = 0;
119 + return (1); /* force code to go initialize kstat stuff */
120 + }
121 +
122 + /*
123 + * Read each cpu's data. If the chain has changed (a state change
124 + * has happened, maybe a new cpu was added to the system), then
125 + * return 1. This will cause the code to reinitialize the cpu_ksp_list
126 + * array. word.
127 + */
128 + cp_time[0] = cp_time[1] = cp_time[2] = cp_time[3] = 0;
129 + for (i = 0; i < ncpus; i++) {
130 + if (kstat_read(kc, cpu_ksp_list[i], (void *) &stat) == -1)
131 + return (1);
132 + cp_time[0] += stat.cpu_sysinfo.cpu[CPU_USER]; /* user */
133 + cp_time[1] += stat.cpu_sysinfo.cpu[CPU_WAIT]; /* "nice" */
134 + cp_time[2] += stat.cpu_sysinfo.cpu[CPU_KERNEL]; /* sys */
135 + cp_time[3] += stat.cpu_sysinfo.cpu[CPU_IDLE]; /* idle ("free")*/
136 + }
137 + return (0);
138 +}
139 +
140 +void GetLoad(int Maximum, int *usr, int *nice, int *sys, int *free)
141 +{
142 + int total;
143 +
144 + while (get_cpu_stats() != 0) {
145 + cpu_stats_init();
146 + }
147 +
148 + *usr = cp_time[0] - last[0];
149 + *nice = cp_time[1] - last[1];
150 + *sys = cp_time[2] - last[2];
151 + *free = cp_time[3] - last[3];
152 +
153 + /* printf("[%d %d %d %d]\n", *usr, *nice, *sys, *free); */
154 +
155 + total = *usr + *nice + *sys + *free;
156 + last[0] = cp_time[0];
157 + last[1] = cp_time[1];
158 + last[2] = cp_time[2];
159 + last[3] = cp_time[3];
160 +
161 + *usr = rint(Maximum * (float)(*usr) /total);
162 + *nice =rint(Maximum * (float)(*nice) /total);
163 + *sys = rint(Maximum * (float)(*sys) /total);
164 + *free = rint(Maximum * (float)(*free) /total);
165 +}
166 +#else /* sun */
167 void GetLoad(int Maximum, int *usr, int *nice, int *sys, int *free)
168 {
169 char buffer[100];/*[4096+1];*/
170 @@ -445,6 +551,7 @@
171 *sys = rint(Maximum * (float)(*sys) /total);
172 *free = rint(Maximum * (float)(*free) /total);
173 }
174 +#endif
175
176 void InsertLoad()
177 {