Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 92278
Collapse All | Expand All

(-)kcpuload-1.99/kcpuload/kcpuproc.cpp (-23 / +55 lines)
Lines 28-33 Link Here
28
#endif
28
#endif
29
#endif
29
#endif
30
30
31
#ifdef Q_OS_LINUX
32
#include <linux/version.h>
33
#endif
34
31
/**
35
/**
32
 * Linux
36
 * Linux
33
 * -----
37
 * -----
Lines 75-86 Link Here
75
79
76
KCPUProc::KCPUProc() {
80
KCPUProc::KCPUProc() {
77
    smp = false;
81
    smp = false;
78
    UT = ST = NT = IT = 0;
82
	linux26 = ( strncmp(UTS_RELEASE,"2.6",3) >= 0 ) ? true : false;
79
    UT0 = ST0 = NT0 = IT0 = 0;
83
    UT = ST = NT = IT = WT = HT = SOT = 0;
80
    UT1 = ST1 = NT1 = IT1 = 0;
84
    UT0 = ST0 = NT0 = IT0 = WT0 = HT0 = SOT0 = 0;
81
    cUT = cST = cNT = cIT = 0;
85
    UT1 = ST1 = NT1 = IT1 = WT1 = HT1 = SOT1 = 0;
82
    cUT0 = cST0 = cNT0 = cIT0 = 0;
86
    cUT = cST = cNT = cIT = cWT = cHT = cSOT = 0;
83
    cUT1 = cST1 = cNT1 = cIT1 = 0;
87
    cUT0 = cST0 = cNT0 = cIT0 = cWT0 = cHT0 = cSOT0 = 0;
88
    cUT1 = cST1 = cNT1 = cIT1 = cWT1 = cHT1 = cSOT1 = 0;
84
    tot = tot0 = tot1 = 0;
89
    tot = tot0 = tot1 = 0;
85
90
86
    // Look for SMP support and take a current tick reading.
91
    // Look for SMP support and take a current tick reading.
Lines 97-111 Link Here
97
#ifdef Q_OS_LINUX
102
#ifdef Q_OS_LINUX
98
    if ((fd = fopen("/proc/stat", "r")) == 0)
103
    if ((fd = fopen("/proc/stat", "r")) == 0)
99
        return;
104
        return;
100
105
	if (linux26) {
101
    fscanf(fd, "%32s %d %d %d %d", tag, &cUT, &cNT, &cST, &cIT);
106
	    fscanf(fd, "%32s %d %d %d %d %d %d %d", tag, &cUT, &cNT, &cST, &cIT, &cWT, &cHT, &cSOT);
102
    fscanf(fd, "%32s %d %d %d %d", tag, &cUT0, &cNT0, &cST0, &cIT0);
107
    	fscanf(fd, "%32s %d %d %d %d %d %d %d", tag, &cUT0, &cNT0, &cST0, &cIT0, &cWT0, &cHT0, &cSOT0);
103
108
	}else {
109
	    fscanf(fd, "%32s %d %d %d %d", tag, &cUT, &cNT, &cST, &cIT);
110
    	fscanf(fd, "%32s %d %d %d %d", tag, &cUT0, &cNT0, &cST0, &cIT0);
111
	}
104
    if (strcmp(tagCPU0, tag) != 0)
112
    if (strcmp(tagCPU0, tag) != 0)
105
        return;
113
        return;
106
114
	if (linux26)
107
    fscanf(fd, "%32s %d %d %d %d", tag, &cUT1, &cNT1, &cST1, &cIT1);
115
	    fscanf(fd, "%32s %d %d %d %d %d %d %d", tag, &cUT1, &cNT1, &cST1, &cIT1, &cWT1, &cHT1, &cSOT1);
108
116
	else
117
		fscanf(fd, "%32s %d %d %d %d %d %d %d", tag, &cUT1, &cNT1, &cST1, &cIT1);
118
	
109
    if (strcmp(tagCPU1, tag) == 0)
119
    if (strcmp(tagCPU1, tag) == 0)
110
        smp = true;
120
        smp = true;
111
#endif
121
#endif
Lines 142-165 Link Here
142
        ST = cST;
152
        ST = cST;
143
        NT = cNT;
153
        NT = cNT;
144
        IT = cIT;
154
        IT = cIT;
145
155
		WT = cWT;
156
		HT = cHT;
157
		SOT = cSOT;
158
		
146
        UT0 = cUT0;
159
        UT0 = cUT0;
147
        ST0 = cST0;
160
        ST0 = cST0;
148
        NT0 = cNT0;
161
        NT0 = cNT0;
149
        IT0 = cIT0;
162
        IT0 = cIT0;
163
		WT0 = cWT0;
164
		HT0 = cHT0;
165
		SOT0 = cSOT0;
150
166
151
        UT1 = cUT1;
167
        UT1 = cUT1;
152
        ST1 = cST1;
168
        ST1 = cST1;
153
        NT1 = cNT1;
169
        NT1 = cNT1;
154
        IT1 = cIT1;
170
        IT1 = cIT1;
171
		WT1 = cWT1;
172
		HT1 = cHT1;
173
		SOT1 = cSOT1;
155
174
156
        // Take a fresh set of current readings (SMP mode).
175
        // Take a fresh set of current readings (SMP mode).
157
176
158
        // ========== Linux-specific (begin) ==========
177
        // ========== Linux-specific (begin) ==========
159
#ifdef Q_OS_LINUX
178
#ifdef Q_OS_LINUX
160
        fscanf(fd, "%32s %d %d %d %d", tag, &cUT, &cNT, &cST, &cIT);
179
		if (linux26) {
161
        fscanf(fd, "%32s %d %d %d %d", tag, &cUT0, &cNT0, &cST0, &cIT0);
180
	        fscanf(fd, "%32s %d %d %d %d %d %d %d", tag, &cUT, &cNT, &cST, &cIT, &cWT, &cHT, &cSOT);
162
        fscanf(fd, "%32s %d %d %d %d", tag, &cUT1, &cNT1, &cST1, &cIT1);
181
    	    fscanf(fd, "%32s %d %d %d %d %d %d %d", tag, &cUT0, &cNT0, &cST0, &cIT, &cWT0, &cHT0, &cSOT0);
182
        	fscanf(fd, "%32s %d %d %d %d %d %d %d", tag, &cUT1, &cNT1, &cST1, &cIT1, &cWT1, &cHT1, &cSOT1);
183
		}else {
184
	        fscanf(fd, "%32s %d %d %d %d", tag, &cUT, &cNT, &cST, &cIT);
185
    	    fscanf(fd, "%32s %d %d %d %d", tag, &cUT0, &cNT0, &cST0, &cIT);
186
        	fscanf(fd, "%32s %d %d %d %d", tag, &cUT1, &cNT1, &cST1, &cIT1);
187
		}
163
#endif
188
#endif
164
        // ========== Linux-specific (end) ==========
189
        // ========== Linux-specific (end) ==========
165
190
Lines 170-190 Link Here
170
        // ========== BSD-specific (end) ==========
195
        // ========== BSD-specific (end) ==========
171
196
172
        // Calculate final totals.
197
        // Calculate final totals.
173
        tot = (cUT - UT) + (cST - ST) + (cNT - NT) + (cIT - IT);
198
        tot = (cUT - UT) + (cST - ST) + (cNT - NT) + (cIT - IT) + (cWT - WT) + (cHT - HT) + (cSOT - SOT);
174
        tot0 = (cUT0 - UT0) + (cST0 - ST0) + (cNT0 - NT0) + (cIT0 - IT0);
199
        tot0 = (cUT0 - UT0) + (cST0 - ST0) + (cNT0 - NT0) + (cIT0 - IT0) + (cWT0 - WT0) + (cHT0 - HT0) + (cSOT0 - SOT0);
175
        tot1 = (cUT1 - UT1) + (cST1 - ST1) + (cNT1 - NT1) + (cIT1 - IT1);
200
        tot1 = (cUT1 - UT1) + (cST1 - ST1) + (cNT1 - NT1) + (cIT1 - IT1) + (cWT1 - WT1) + (cHT1 - HT1) + (cSOT1 - SOT1);
176
    } else {
201
    } else {
177
        // The current readings must now become the previous readings.
202
        // The current readings must now become the previous readings.
178
        UT = cUT;
203
        UT = cUT;
179
        ST = cST;
204
        ST = cST;
180
        NT = cNT;
205
        NT = cNT;
181
        IT = cIT;
206
        IT = cIT;
182
207
		WT = cWT;
208
		HT = cHT;
209
		SOT = cSOT;
210
		
183
        // Take a fresh set of current readings (uni-processor mode).
211
        // Take a fresh set of current readings (uni-processor mode).
184
212
185
        // ========== Linux-specific (begin) ==========
213
        // ========== Linux-specific (begin) ==========
186
#ifdef Q_OS_LINUX
214
#ifdef Q_OS_LINUX
187
        fscanf(fd, "%32s %d %d %d %d", tag, &cUT, &cNT, &cST, &cIT);
215
		if (linux26)
216
	        fscanf(fd, "%32s %d %d %d %d %d %d %d", tag, &cUT, &cNT, &cST, &cIT, &cWT, &cHT, &cSOT);
217
		else
218
	        fscanf(fd, "%32s %d %d %d %d", tag, &cUT, &cNT, &cST, &cIT);
219
188
#endif
220
#endif
189
        // ========== Linux-specific (end) ==========
221
        // ========== Linux-specific (end) ==========
190
222
Lines 210-216 Link Here
210
        // ========== BSD-specific (end) ==========
242
        // ========== BSD-specific (end) ==========
211
243
212
        // Calculate final totals.
244
        // Calculate final totals.
213
        tot = (cUT - UT) + (cST - ST) + (cNT - NT) + (cIT - IT);
245
        tot = (cUT - UT) + (cST - ST) + (cNT - NT) + (cIT - IT) + (cWT - WT) + (cHT - HT) + (cSOT - SOT) ;
214
    }
246
    }
215
247
216
    // Clean up after taking readings.
248
    // Clean up after taking readings.
(-)kcpuload-1.99/kcpuload/kcpuproc.h (-6 / +9 lines)
Lines 100-111 Link Here
100
    bool smp;
100
    bool smp;
101
        /**< Does this system appear to have SMP? */
101
        /**< Does this system appear to have SMP? */
102
102
103
	bool linux26;
104
		/** diffrent data format on 2.6 kernels */
105
	
103
    /**
106
    /**
104
     * Variables used in all modes.
107
     * Variables used in all modes.
105
     */
108
     */
106
    int UT, ST, NT, IT;
109
    int UT, ST, NT, IT, WT, HT, SOT;
107
        /**< Previous user/system/nice/idle tick readings for all CPUs. */
110
        /**< Previous user/system/nice/idle tick readings for all CPUs. */
108
    int cUT, cST, cNT, cIT;
111
    int cUT, cST, cNT, cIT, cWT, cHT, cSOT;
109
        /**< Current user/system/nice/idle tick readings for all CPUs. */
112
        /**< Current user/system/nice/idle tick readings for all CPUs. */
110
    int tot;
113
    int tot;
111
        /**< Difference between tick totals for the current and previous
114
        /**< Difference between tick totals for the current and previous
Lines 114-130 Link Here
114
    /**
117
    /**
115
     * Variables used only with SMP.
118
     * Variables used only with SMP.
116
     */
119
     */
117
    int UT0, ST0, NT0, IT0;
120
    int UT0, ST0, NT0, IT0, WT0, HT0, SOT0;
118
        /**< Previous user/system/nice/idle tick readings for CPU 0. */
121
        /**< Previous user/system/nice/idle tick readings for CPU 0. */
119
    int cUT0, cST0, cNT0, cIT0;
122
    int cUT0, cST0, cNT0, cIT0, cWT0, cHT0, cSOT0;
120
        /**< Current user/system/nice/idle tick readings for CPU 0. */
123
        /**< Current user/system/nice/idle tick readings for CPU 0. */
121
    int tot0;
124
    int tot0;
122
        /**< Difference between tick totals for the current and previous
125
        /**< Difference between tick totals for the current and previous
123
             readings for CPU 0. */
126
             readings for CPU 0. */
124
127
125
    int UT1, ST1, NT1, IT1;
128
    int UT1, ST1, NT1, IT1, WT1, HT1, SOT1;
126
        /**< Previous user/system/nice/idle tick readings for CPU 1. */
129
        /**< Previous user/system/nice/idle tick readings for CPU 1. */
127
    int cUT1, cST1, cNT1, cIT1;
130
    int cUT1, cST1, cNT1, cIT1, cWT1, cHT1, cSOT1;
128
        /**< Current user/system/nice/idle tick readings for CPU 1. */
131
        /**< Current user/system/nice/idle tick readings for CPU 1. */
129
    int tot1;
132
    int tot1;
130
        /**< Difference between tick totals for the current and previous
133
        /**< Difference between tick totals for the current and previous

Return to bug 92278