diff options
author | Mark Johnston <markj@FreeBSD.org> | 2020-03-06 19:09:01 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2020-03-06 19:09:01 +0000 |
commit | fffcb56f7a7b1ee6fb1a91584ba69b62d133c2d5 (patch) | |
tree | 77b799209f34c69f7b4f9f60202c32118bc658fc /sys/sys/counter.h | |
parent | f15ccf8836d9d42b92f999dbd6c4746c9547f8a6 (diff) | |
download | src-fffcb56f7a7b1ee6fb1a91584ba69b62d133c2d5.tar.gz src-fffcb56f7a7b1ee6fb1a91584ba69b62d133c2d5.zip |
Add COUNTER_U64_SYSINIT() and COUNTER_U64_DEFINE_EARLY().
The aim is to reduce the boilerplate needed today to define and
initialize global counters. Also add SI_SUB_COUNTER to the sysinit
ordering.
Reviewed by: kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D23977
Notes
Notes:
svn path=/head/; revision=358715
Diffstat (limited to 'sys/sys/counter.h')
-rw-r--r-- | sys/sys/counter.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/sys/sys/counter.h b/sys/sys/counter.h index 9960a2c39d8e..3e1b7828d5d4 100644 --- a/sys/sys/counter.h +++ b/sys/sys/counter.h @@ -74,5 +74,18 @@ struct counter_rate { int64_t counter_ratecheck(struct counter_rate *, int64_t); +#define COUNTER_U64_SYSINIT(c) \ + SYSINIT(c##_counter_sysinit, SI_SUB_COUNTER, \ + SI_ORDER_ANY, counter_u64_sysinit, &c); \ + SYSUNINIT(c##_counter_sysuninit, SI_SUB_COUNTER, \ + SI_ORDER_ANY, counter_u64_sysuninit, &c) + +#define COUNTER_U64_DEFINE_EARLY(c) \ + counter_u64_t __read_mostly c = EARLY_COUNTER; \ + COUNTER_U64_SYSINIT(c) + +void counter_u64_sysinit(void *); +void counter_u64_sysuninit(void *); + #endif /* _KERNEL */ #endif /* ! __SYS_COUNTER_H__ */ |