From f1a8ce9fda66ec5a3295a4b79ff3f3ec0195d994 Mon Sep 17 00:00:00 2001 From: hunt Date: Wed, 18 May 2005 00:25:31 +0000 Subject: 2005-05-17 Martin Hunt * map.c (needed_space): Use do_div(). (_stp_map_print_histogram): Ditto. (_stp_map_print): Ditto. * map-values.c (_stp_map_add_int64_stat): Use do_div() when computing histogram bucket. * map-keys.c (_stp_map_key): Fix some warnings on 32-bit machines by using key_data casts. --- runtime/map.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'runtime/map.c') diff --git a/runtime/map.c b/runtime/map.c index 6f6116f5..dfb98bfb 100644 --- a/runtime/map.c +++ b/runtime/map.c @@ -434,7 +434,8 @@ static int needed_space(int64_t v) v = -v; } while (v) { - v /= 10; + /* v /= 10; */ + do_div (v, 10); space++; } return space; @@ -466,8 +467,10 @@ void _stp_map_print_histogram (MAP map, stat *s) if (max <= HIST_WIDTH) scale = 1; else { - scale = max / HIST_WIDTH; - if (max % HIST_WIDTH) scale++; + int64_t tmp = max; + int rem = do_div (tmp, HIST_WIDTH); + scale = tmp; + if (rem) scale++; } cnt_space = needed_space (max); @@ -497,7 +500,11 @@ void _stp_map_print_histogram (MAP map, stat *s) reprint (val_space - needed_space(val), " "); _stp_printf("%d", val); _stp_print_cstr (" |"); - v = s->histogram[i] / scale; + + /* v = s->histogram[i] / scale; */ + v = s->histogram[i]; + do_div (v, scale); + reprint (v, "@"); reprint (HIST_WIDTH - v + 1 + cnt_space - needed_space(s->histogram[i]), " "); _stp_printf ("%lld\n", s->histogram[i]); @@ -544,8 +551,10 @@ void _stp_map_print (MAP map, const char *name) #ifdef NEED_STAT_VALS else { stat *s = _stp_get_stat(ptr); + int64_t avg = s->sum; + do_div (avg, (int)s->count); /* FIXME: check for overflow */ _stp_printf("count:%lld sum:%lld avg:%lld min:%lld max:%lld\n", - s->count, s->sum, s->sum/s->count, s->min, s->max); + s->count, s->sum, avg, s->min, s->max); _stp_print_flush(); _stp_map_print_histogram (map, s); } -- cgit