return;
}
+/**
+ * \brief Decrements the local counter
+ *
+ * \param id Index of the counter in the counter array
+ * \param pca Counter array that holds the local counters for this TM
+ */
+void StatsDecr(ThreadVars *tv, uint16_t id)
+{
+ StatsPrivateThreadContext *pca = &tv->perf_private_ctx;
+#if defined(UNITTESTS) || defined(FUZZ)
+ if (pca->initialized == 0)
+ return;
+#endif
+#ifdef DEBUG
+ BUG_ON((id < 1) || (id > pca->size));
+#endif
+ pca->head[id].value--;
+ pca->head[id].updates++;
+ return;
+}
+
/**
* \brief Sets a value of type double to the local counter
*
BUG_ON ((id < 1) || (id > pca->size));
#endif
- if ((pca->head[id].pc->type == STATS_TYPE_MAXIMUM) &&
- (x > pca->head[id].value)) {
+ if ((pca->head[id].pc->type == STATS_TYPE_MAXIMUM) && ((int64_t)x > pca->head[id].value)) {
pca->head[id].value = x;
} else if (pca->head[id].pc->type == STATS_TYPE_NORMAL) {
pca->head[id].value = x;
* especially needed for the average counters */
struct CountersMergeTable {
int type;
- uint64_t value;
+ int64_t value;
uint64_t updates;
} merge_table[max_id];
memset(&merge_table, 0x00,
uint16_t gid;
/* counter value(s): copies from the 'private' counter */
- uint64_t value; /**< sum of updates/increments, or 'set' value */
+ int64_t value; /**< sum of updates/increments, or 'set' value */
uint64_t updates; /**< number of updates (for avg) */
/* when using type STATS_TYPE_Q_FUNC this function is called once
uint16_t id;
/* total value of the adds/increments, or exact value in case of 'set' */
- uint64_t value;
+ int64_t value;
/* no of times the local counter has been updated */
uint64_t updates;
void StatsAddUI64(struct ThreadVars_ *, uint16_t, uint64_t);
void StatsSetUI64(struct ThreadVars_ *, uint16_t, uint64_t);
void StatsIncr(struct ThreadVars_ *, uint16_t);
+void StatsDecr(struct ThreadVars_ *, uint16_t);
/* utility functions */
int StatsUpdateCounterArray(StatsPrivateThreadContext *, StatsPublicThreadContext *);
continue;
char line[256];
- size_t len = snprintf(line, sizeof(line), "%-45s | %-25s | %-" PRIu64 "\n",
+ size_t len = snprintf(line, sizeof(line), "%-45s | %-25s | %-" PRIi64 "\n",
st->tstats[u].name, st->tstats[u].tm_name, st->tstats[u].value);
/* since we can have many threads, the buffer might not be big enough.
typedef struct StatsRecord_ {
const char *name;
const char *tm_name;
- uint64_t value; /**< total value */
- uint64_t pvalue; /**< prev value (may be higher for memuse counters) */
+ int64_t value; /**< total value */
+ int64_t pvalue; /**< prev value (may be higher for memuse counters) */
} StatsRecord;
typedef struct StatsTable_ {