aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/counter.h
diff options
context:
space:
mode:
authorAndrey V. Elsukov <ae@FreeBSD.org>2013-07-09 09:37:21 +0000
committerAndrey V. Elsukov <ae@FreeBSD.org>2013-07-09 09:37:21 +0000
commit7daad711df788ed9ff68f2ca151f5f625cb1dcb0 (patch)
treebb1321b60c85eceb0561d4bd22fdd6629839f34d /sys/sys/counter.h
parentc80211e3cf59276683fe85db8142f09fbc97e2cc (diff)
downloadsrc-7daad711df788ed9ff68f2ca151f5f625cb1dcb0.tar.gz
src-7daad711df788ed9ff68f2ca151f5f625cb1dcb0.zip
Add several macros to help migrate statistics structures to PCPU counters.
Notes
Notes: svn path=/head/; revision=253082
Diffstat (limited to 'sys/sys/counter.h')
-rw-r--r--sys/sys/counter.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/sys/counter.h b/sys/sys/counter.h
index ee500b5b078a..ec5cbfe9d36b 100644
--- a/sys/sys/counter.h
+++ b/sys/sys/counter.h
@@ -39,4 +39,23 @@ void counter_u64_free(counter_u64_t);
void counter_u64_zero(counter_u64_t);
uint64_t counter_u64_fetch(counter_u64_t);
+#define COUNTER_ARRAY_ALLOC(a, n, wait) do { \
+ for (int i = 0; i < (n); i++) \
+ (a)[i] = counter_u64_alloc(wait); \
+} while (0)
+
+#define COUNTER_ARRAY_FREE(a, n) do { \
+ for (int i = 0; i < (n); i++) \
+ counter_u64_free((a)[i]); \
+} while (0)
+
+#define COUNTER_ARRAY_COPY(a, dstp, n) do { \
+ for (int i = 0; i < (n); i++) \
+ ((uint64_t *)(dstp))[i] = counter_u64_fetch((a)[i]);\
+} while (0)
+
+#define COUNTER_ARRAY_ZERO(a, n) do { \
+ for (int i = 0; i < (n); i++) \
+ counter_u64_zero((a)[i]); \
+} while (0)
#endif /* ! __SYS_COUNTER_H__ */