perf_counter: add function to set a count

This needed the set function which sets elapsed to change the name to
avoid ambiguities.
This commit is contained in:
Julian Oes
2016-04-24 19:47:02 +02:00
committed by Lorenz Meier
parent 08a1941fd6
commit 662c097803
2 changed files with 31 additions and 2 deletions

View File

@@ -299,7 +299,7 @@ perf_end(perf_counter_t handle)
#include <systemlib/err.h>
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)
{

View File

@@ -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.