aboutsummaryrefslogtreecommitdiff
path: root/procps
diff options
context:
space:
mode:
Diffstat (limited to 'procps')
-rw-r--r--procps/top.c56
1 files changed, 29 insertions, 27 deletions
diff --git a/procps/top.c b/procps/top.c
index e9ccac0cd..85699b027 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -219,7 +219,9 @@ static unsigned long display_generic(int scr_width)
219 char buf[80]; 219 char buf[80];
220 char scrbuf[80]; 220 char scrbuf[80];
221 unsigned long total, used, mfree, shared, buffers, cached; 221 unsigned long total, used, mfree, shared, buffers, cached;
222#if ENABLE_FEATURE_TOP_DECIMALS || ENABLE_FEATURE_TOP_CPU_GLOBAL_PERCENTS
222 unsigned total_diff; 223 unsigned total_diff;
224#endif
223 225
224#if ENABLE_FEATURE_TOP_DECIMALS 226#if ENABLE_FEATURE_TOP_DECIMALS
225 /* formats 7 char string (8 with terminating NUL) */ 227 /* formats 7 char string (8 with terminating NUL) */
@@ -305,12 +307,12 @@ static unsigned long display_generic(int scr_width)
305 /* clear screen & go to top */ 307 /* clear screen & go to top */
306 printf(OPT_BATCH_MODE ? "%s\n" : "\e[H\e[J%s\n", scrbuf); 308 printf(OPT_BATCH_MODE ? "%s\n" : "\e[H\e[J%s\n", scrbuf);
307 309
308 if (ENABLE_FEATURE_TOP_CPU_GLOBAL_PERCENTS) { 310#if ENABLE_FEATURE_TOP_CPU_GLOBAL_PERCENTS
309 /* 311 /*
310 * xxx% = (jif.xxx - prev_jif.xxx) / (jif.total - prev_jif.total) * 100% 312 * xxx% = (jif.xxx - prev_jif.xxx) / (jif.total - prev_jif.total) * 100%
311 */ 313 */
312 /* using (unsigned) casts to make operations cheaper */ 314 /* using (unsigned) casts to make operations cheaper */
313 total_diff = ((unsigned)(jif.total - prev_jif.total) ? : 1); 315 total_diff = ((unsigned)(jif.total - prev_jif.total) ? : 1);
314#if ENABLE_FEATURE_TOP_DECIMALS 316#if ENABLE_FEATURE_TOP_DECIMALS
315/* Generated code is approx +0.3k */ 317/* Generated code is approx +0.3k */
316#define CALC_STAT(xxx) char xxx[8] 318#define CALC_STAT(xxx) char xxx[8]
@@ -321,30 +323,30 @@ static unsigned long display_generic(int scr_width)
321#define SHOW_STAT(xxx) xxx 323#define SHOW_STAT(xxx) xxx
322#define FMT "%4u%% " 324#define FMT "%4u%% "
323#endif 325#endif
324 { /* need block: CALC_STAT are declarations */ 326 { /* need block: CALC_STAT are declarations */
325 CALC_STAT(usr); 327 CALC_STAT(usr);
326 CALC_STAT(sys); 328 CALC_STAT(sys);
327 CALC_STAT(nic); 329 CALC_STAT(nic);
328 CALC_STAT(idle); 330 CALC_STAT(idle);
329 CALC_STAT(iowait); 331 CALC_STAT(iowait);
330 CALC_STAT(irq); 332 CALC_STAT(irq);
331 CALC_STAT(softirq); 333 CALC_STAT(softirq);
332 //CALC_STAT(steal); 334 //CALC_STAT(steal);
333 335
334 snprintf(scrbuf, scr_width, 336 snprintf(scrbuf, scr_width,
335 /* Barely fits in 79 chars when in "decimals" mode. */ 337 /* Barely fits in 79 chars when in "decimals" mode. */
336 "CPU:"FMT"usr"FMT"sys"FMT"nice"FMT"idle"FMT"io"FMT"irq"FMT"softirq", 338 "CPU:"FMT"usr"FMT"sys"FMT"nice"FMT"idle"FMT"io"FMT"irq"FMT"softirq",
337 SHOW_STAT(usr), SHOW_STAT(sys), SHOW_STAT(nic), SHOW_STAT(idle), 339 SHOW_STAT(usr), SHOW_STAT(sys), SHOW_STAT(nic), SHOW_STAT(idle),
338 SHOW_STAT(iowait), SHOW_STAT(irq), SHOW_STAT(softirq) 340 SHOW_STAT(iowait), SHOW_STAT(irq), SHOW_STAT(softirq)
339 //, SHOW_STAT(steal) - what is this 'steal' thing? 341 //, SHOW_STAT(steal) - what is this 'steal' thing?
340 // I doubt anyone wants to know it 342 // I doubt anyone wants to know it
341 ); 343 );
342 } 344 }
343 puts(scrbuf); 345 puts(scrbuf);
344#undef SHOW_STAT 346#undef SHOW_STAT
345#undef CALC_STAT 347#undef CALC_STAT
346#undef FMT 348#undef FMT
347 } 349#endif
348 350
349 /* read load average as a string */ 351 /* read load average as a string */
350 buf[0] = '\0'; 352 buf[0] = '\0';