diff options
author | ae <ae@FreeBSD.org> | 2013-07-09 09:37:21 +0000 |
---|---|---|
committer | ae <ae@FreeBSD.org> | 2013-07-09 09:37:21 +0000 |
commit | 027c687189cc0647592f671691e0a08064401c1d (patch) | |
tree | bb1321b60c85eceb0561d4bd22fdd6629839f34d /sys/sys/counter.h | |
parent | 1a36dfcc879833c6fdc45e20d39db618b110f55c (diff) | |
download | FreeBSD-src-027c687189cc0647592f671691e0a08064401c1d.zip FreeBSD-src-027c687189cc0647592f671691e0a08064401c1d.tar.gz |
Add several macros to help migrate statistics structures to PCPU counters.
Diffstat (limited to 'sys/sys/counter.h')
-rw-r--r-- | sys/sys/counter.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/sys/counter.h b/sys/sys/counter.h index ee500b5..ec5cbfe 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__ */ |