From 662c097803a6ab6e3c234e357fd9a82676701fac Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Sun, 24 Apr 2016 19:47:02 +0200 Subject: [PATCH] perf_counter: add function to set a count This needed the set function which sets elapsed to change the name to avoid ambiguities. --- src/modules/systemlib/perf_counter.c | 21 ++++++++++++++++++++- src/modules/systemlib/perf_counter.h | 12 +++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/modules/systemlib/perf_counter.c b/src/modules/systemlib/perf_counter.c index a9d9db9748..36b3ba8580 100644 --- a/src/modules/systemlib/perf_counter.c +++ b/src/modules/systemlib/perf_counter.c @@ -299,7 +299,7 @@ perf_end(perf_counter_t handle) #include void -perf_set(perf_counter_t handle, int64_t elapsed) +perf_set_elapsed(perf_counter_t handle, int64_t elapsed) { if (handle == NULL) { return; @@ -342,6 +342,25 @@ perf_set(perf_counter_t handle, int64_t elapsed) } } +void +perf_set_count(perf_counter_t handle, uint64_t count) +{ + if (handle == NULL) { + return; + } + + switch (handle->type) { + case PC_COUNT: { + ((struct perf_ctr_count *)handle)->event_count = count; + } + break; + + default: + break; + } + +} + void perf_cancel(perf_counter_t handle) { diff --git a/src/modules/systemlib/perf_counter.h b/src/modules/systemlib/perf_counter.h index 0a5ca94cb9..55931576ce 100644 --- a/src/modules/systemlib/perf_counter.h +++ b/src/modules/systemlib/perf_counter.h @@ -122,7 +122,17 @@ __EXPORT extern void perf_end(perf_counter_t handle); * @param handle The handle returned from perf_alloc. * @param elapsed The time elapsed. Negative values lead to incrementing the overrun counter. */ -__EXPORT extern void perf_set(perf_counter_t handle, int64_t elapsed); +__EXPORT extern void perf_set_elapsed(perf_counter_t handle, int64_t elapsed); + +/** + * Set a counter + * + * This call applies to counters of type PC_COUNT. It (re-)sets the count. + * + * @param handle The handle returned from perf_alloc. + * @param count The counter value to be set. + */ +__EXPORT extern void perf_set_count(perf_counter_t handle, uint64_t count); /** * Cancel a performance event.