diff options
author | hunt <hunt> | 2005-05-18 00:25:31 +0000 |
---|---|---|
committer | hunt <hunt> | 2005-05-18 00:25:31 +0000 |
commit | f1a8ce9fda66ec5a3295a4b79ff3f3ec0195d994 (patch) | |
tree | 3218fc90339d9f3ba7cb543d4992a6b27f5bd206 | |
parent | 042803219fdd22aed9a134d46788ed01d29e1d7c (diff) | |
download | systemtap-steved-f1a8ce9fda66ec5a3295a4b79ff3f3ec0195d994.tar.gz systemtap-steved-f1a8ce9fda66ec5a3295a4b79ff3f3ec0195d994.tar.xz systemtap-steved-f1a8ce9fda66ec5a3295a4b79ff3f3ec0195d994.zip |
2005-05-17 Martin Hunt <hunt@redhat.com>
* 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.
-rw-r--r-- | runtime/ChangeLog | 12 | ||||
-rw-r--r-- | runtime/list.c | 2 | ||||
-rw-r--r-- | runtime/map-keys.c | 18 | ||||
-rw-r--r-- | runtime/map-values.c | 5 | ||||
-rw-r--r-- | runtime/map.c | 19 |
5 files changed, 36 insertions, 20 deletions
diff --git a/runtime/ChangeLog b/runtime/ChangeLog index cb062f99..c78a7bca 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,15 @@ +2005-05-17 Martin Hunt <hunt@redhat.com> + + * 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. + 2005-03-30 Martin Hunt <hunt@redhat.com> * scbuf.c: Make functions use per-cpu buffers as documented. diff --git a/runtime/list.c b/runtime/list.c index b26653ed..2ab3f2ea 100644 --- a/runtime/list.c +++ b/runtime/list.c @@ -6,7 +6,7 @@ #endif #if !defined(NEED_STRING_VALS) && !defined(NEED_INT64_VALS) -#error Before including list.c, "#define VALUE_TYPE" to "INT64" or "STRING and include "map-values.c" +#error Before including list.c, "#define VALUE_TYPE" to "INT64" or "STRING" and include "map-values.c" #endif #include "map.c" diff --git a/runtime/map-keys.c b/runtime/map-keys.c index 37308179..b51118ec 100644 --- a/runtime/map-keys.c +++ b/runtime/map-keys.c @@ -323,14 +323,6 @@ MAP KEYSYM(_stp_map_new) (unsigned max_entries, int valtype, ...) } -#define SETKEYS2(key, n) { \ - if (__builtin_types_compatible_p (typeof (key), char[])) { \ - map->c_key[n].strp = (char *)key; \ - } else { \ - map->c_key[n].val = (int64_t)key; \ - } \ - } - void KEYSYM(_stp_map_key) (MAP map, ALLKEYSD(key)) { unsigned int hv; @@ -369,15 +361,15 @@ void KEYSYM(_stp_map_key) (MAP map, ALLKEYSD(key)) } dbug ("key not found\n"); - SETKEYS2 (key1, 0); + map->c_key[0] = (key_data)key1; #if KEY_ARITY > 1 - SETKEYS2 (key2, 1); + map->c_key[1] = (key_data)key2; #if KEY_ARITY > 2 - SETKEYS2 (key3, 2); + map->c_key[2] = (key_data)key3; #if KEY_ARITY > 3 - SETKEYS2 (key4, 3); + map->c_key[3] = (key_data)key4; #if KEY_ARITY > 4 - SETKEYS2 (key5, 4); + map->c_key[4] = (key_data)key5; #endif #endif #endif diff --git a/runtime/map-values.c b/runtime/map-values.c index 3d6af134..6f8adf11 100644 --- a/runtime/map-values.c +++ b/runtime/map-values.c @@ -103,7 +103,10 @@ void VALSYM(_stp_map_add_int64) (MAP map, int64_t val) d->histogram[n]++; break; case HIST_LINEAR: - n = (val - map->hist_start) / map->hist_int; + /* n = (val - map->hist_start) / map->hist_int; */ + val -= map->hist_start; + do_div (val, map->hist_int); + n = val; if (n < 0) n = 0; if (n >= map->hist_buckets) 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); } |