summaryrefslogtreecommitdiffstats
path: root/runtime/stat.c
diff options
context:
space:
mode:
authorhunt <hunt>2007-09-12 18:37:47 +0000
committerhunt <hunt>2007-09-12 18:37:47 +0000
commit3a18979dd18ba8cdd96367d2ad18c456f26c6f20 (patch)
tree9b345453171b5a796ecf65c59f052f9e9373c87a /runtime/stat.c
parent674f70a0371c1f97a83c66268d03332ebbf9e62f (diff)
downloadsystemtap-steved-3a18979dd18ba8cdd96367d2ad18c456f26c6f20.tar.gz
systemtap-steved-3a18979dd18ba8cdd96367d2ad18c456f26c6f20.tar.xz
systemtap-steved-3a18979dd18ba8cdd96367d2ad18c456f26c6f20.zip
2007-09-12 Martin Hunt <hunt@redhat.com>
* map-stat.c (_stp_map_new_hstat_log): Set buckets to HIST_LOG_BUCKETS. (_stp_pmap_new_hstat_log): Ditto. (_stp_map_new_hstat_linear): Call _stp_stat_calc_buckets(). (_stp_pmap_new_hstat_linear): Ditto. * stat.h (STP_MAX_BUCKETS): Define.. (HIST_LOG_BUCKETS): Define. * stat.c (_stp_stat_init): Call _stp_stat_calc_buckets(). * stat-common.c (_stp_stat_calc_buckets): New function. Common bucket calculation and error reporting code. (_stp_bucket_to_val): New function. (_stp_val_to_bucket): Renamed and now handles negative numbers. (_stp_stat_print_histogram): Handle negative values in log histograms. (__stp_stat_add): Cleanup.. * map-gen.c (_stp_map_new): Remove buckets param for HIST_LOG. * pmap-gen.c (_stp_pmap_new): Ditto.
Diffstat (limited to 'runtime/stat.c')
-rw-r--r--runtime/stat.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/runtime/stat.c b/runtime/stat.c
index f4e205aa..3df1d063 100644
--- a/runtime/stat.c
+++ b/runtime/stat.c
@@ -85,21 +85,15 @@ Stat _stp_stat_init (int type, ...)
va_start (ap, type);
if (type == HIST_LOG) {
- buckets = va_arg(ap, int);
+ buckets = HIST_LOG_BUCKETS;
} else {
start = va_arg(ap, int);
stop = va_arg(ap, int);
interval = va_arg(ap, int);
- if (interval == 0) {
- _stp_warn("histogram: interval cannot be zero.\n");
- return NULL;
- }
- buckets = (stop - start) / interval;
- if ((stop - start) % interval) buckets++;
- if (buckets > 128) {
- _stp_warn("histogram: Interval is too small. Maximum buckets is 128.\n");
+
+ buckets = _stp_stat_calc_buckets(stop, start, interval);
+ if (!buckets)
return NULL;
- }
}
va_end (ap);
}