summaryrefslogtreecommitdiffstats
path: root/freebsd/sys/sys/counter.h
diff options
context:
space:
mode:
Diffstat (limited to 'freebsd/sys/sys/counter.h')
-rw-r--r--freebsd/sys/sys/counter.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/freebsd/sys/sys/counter.h b/freebsd/sys/sys/counter.h
index 2ce71341..5046d41d 100644
--- a/freebsd/sys/sys/counter.h
+++ b/freebsd/sys/sys/counter.h
@@ -59,5 +59,18 @@ uint64_t counter_u64_fetch(counter_u64_t);
for (int i = 0; i < (n); i++) \
counter_u64_zero((a)[i]); \
} while (0)
+
+/*
+ * counter(9) based rate checking.
+ */
+struct counter_rate {
+ counter_u64_t cr_rate; /* Events since last second */
+ volatile int cr_lock; /* Lock to clean the struct */
+ int cr_ticks; /* Ticks on last clean */
+ int cr_over; /* Over limit since cr_ticks? */
+};
+
+int64_t counter_ratecheck(struct counter_rate *, int64_t);
+
#endif /* _KERNEL */
#endif /* ! __SYS_COUNTER_H__ */