diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-12 15:11:50 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-12 15:11:50 +0200 |
commit | fe73798135d30561f9985278ecc46d41c8ff492e (patch) | |
tree | 76242fc43b78c16838a3f3754986cb9c898e5a6d /procps/top.c | |
parent | 27726cb6aad8e4cb48ceae80d36a5ebaf61e6daa (diff) | |
download | busybox-w32-fe73798135d30561f9985278ecc46d41c8ff492e.tar.gz busybox-w32-fe73798135d30561f9985278ecc46d41c8ff492e.tar.bz2 busybox-w32-fe73798135d30561f9985278ecc46d41c8ff492e.zip |
top: remove GCCisms
function old new delta
display_process_list 1447 1448 +1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'procps/top.c')
-rw-r--r-- | procps/top.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/procps/top.c b/procps/top.c index 7133e5c99..a1ad7881e 100644 --- a/procps/top.c +++ b/procps/top.c | |||
@@ -348,13 +348,15 @@ static void display_cpus(int scr_width, char *scrbuf, int *lines_rem_p) | |||
348 | unsigned total_diff; | 348 | unsigned total_diff; |
349 | jiffy_counts_t *p_jif, *p_prev_jif; | 349 | jiffy_counts_t *p_jif, *p_prev_jif; |
350 | int i; | 350 | int i; |
351 | |||
352 | # if ENABLE_FEATURE_TOP_SMP_CPU | 351 | # if ENABLE_FEATURE_TOP_SMP_CPU |
353 | int n_cpu_lines; | 352 | int n_cpu_lines; |
354 | # endif | 353 | # endif |
355 | 354 | ||
356 | /* using (unsigned) casts to make operations cheaper */ | 355 | /* using (unsigned) casts to make operations cheaper */ |
357 | # define CALC_TOT_DIFF ((unsigned)(p_jif->total - p_prev_jif->total) ? : 1) | 356 | # define CALC_TOTAL_DIFF do { \ |
357 | total_diff = (unsigned)(p_jif->total - p_prev_jif->total); \ | ||
358 | if (total_diff == 0) total_diff = 1; \ | ||
359 | } while (0) | ||
358 | 360 | ||
359 | # if ENABLE_FEATURE_TOP_DECIMALS | 361 | # if ENABLE_FEATURE_TOP_DECIMALS |
360 | # define CALC_STAT(xxx) char xxx[8] | 362 | # define CALC_STAT(xxx) char xxx[8] |
@@ -381,7 +383,7 @@ static void display_cpus(int scr_width, char *scrbuf, int *lines_rem_p) | |||
381 | p_jif = &cpu_jif[i]; | 383 | p_jif = &cpu_jif[i]; |
382 | p_prev_jif = &cpu_prev_jif[i]; | 384 | p_prev_jif = &cpu_prev_jif[i]; |
383 | # endif | 385 | # endif |
384 | total_diff = CALC_TOT_DIFF; | 386 | CALC_TOTAL_DIFF; |
385 | 387 | ||
386 | { /* Need a block: CALC_STAT are declarations */ | 388 | { /* Need a block: CALC_STAT are declarations */ |
387 | CALC_STAT(usr); | 389 | CALC_STAT(usr); |
@@ -511,6 +513,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) | |||
511 | /* xxx_shift and xxx_scale variables allow us to replace | 513 | /* xxx_shift and xxx_scale variables allow us to replace |
512 | * expensive divides with multiply and shift */ | 514 | * expensive divides with multiply and shift */ |
513 | unsigned pmem_shift, pmem_scale, pmem_half; | 515 | unsigned pmem_shift, pmem_scale, pmem_half; |
516 | unsigned tmp_unsigned; | ||
514 | #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 517 | #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
515 | unsigned pcpu_shift, pcpu_scale, pcpu_half; | 518 | unsigned pcpu_shift, pcpu_scale, pcpu_half; |
516 | unsigned busy_jifs; | 519 | unsigned busy_jifs; |
@@ -565,12 +568,16 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) | |||
565 | * we assume that unsigned is at least 32-bit. | 568 | * we assume that unsigned is at least 32-bit. |
566 | */ | 569 | */ |
567 | pcpu_shift = 6; | 570 | pcpu_shift = 6; |
568 | pcpu_scale = (UPSCALE*64 * (uint16_t)busy_jifs ? : 1); | 571 | pcpu_scale = UPSCALE*64 * (uint16_t)busy_jifs; |
572 | if (pcpu_scale == 0) | ||
573 | pcpu_scale = 1; | ||
569 | while (pcpu_scale < (1U << (BITS_PER_INT-2))) { | 574 | while (pcpu_scale < (1U << (BITS_PER_INT-2))) { |
570 | pcpu_scale *= 4; | 575 | pcpu_scale *= 4; |
571 | pcpu_shift += 2; | 576 | pcpu_shift += 2; |
572 | } | 577 | } |
573 | pcpu_scale /= ( (uint16_t)(cur_jif.total - prev_jif.total) * total_pcpu ? : 1); | 578 | tmp_unsigned = (uint16_t)(cur_jif.total - prev_jif.total) * total_pcpu; |
579 | if (tmp_unsigned != 0) | ||
580 | pcpu_scale /= tmp_unsigned; | ||
574 | /* we want (s->pcpu * pcpu_scale) to never overflow */ | 581 | /* we want (s->pcpu * pcpu_scale) to never overflow */ |
575 | while (pcpu_scale >= 1024) { | 582 | while (pcpu_scale >= 1024) { |
576 | pcpu_scale /= 4; | 583 | pcpu_scale /= 4; |