Improve the implementation and documentation of the
SYSCTL_COUNTER_U64_ARRAY() macro. - Add proper asserts to the SYSCTL_COUNTER_U64_ARRAY() macro that checks the size of the first element of the array. - Add an example to the counter(9) manual page how to use the SYSCTL_COUNTER_U64_ARRAY() macro. - Add some missing symbolic links for counter(9) while at it.
This commit is contained in:
parent
0d8c93313e
commit
a435d46fdf
@ -639,7 +639,11 @@ MLINKS+=counter.9 counter_u64_alloc.9 \
|
||||
counter.9 counter_exit.9 \
|
||||
counter.9 counter_u64_add_protected.9 \
|
||||
counter.9 counter_u64_fetch.9 \
|
||||
counter.9 counter_u64_zero.9
|
||||
counter.9 counter_u64_zero.9 \
|
||||
counter.9 SYSCTL_COUNTER_U64.9 \
|
||||
counter.9 SYSCTL_ADD_COUNTER_U64.9 \
|
||||
counter.9 SYSCTL_COUNTER_U64_ARRAY.9 \
|
||||
counter.9 SYSCTL_ADD_COUNTER_U64_ARRAY.9
|
||||
MLINKS+=cpuset.9 CPUSET_T_INITIALIZER.9 \
|
||||
cpuset.9 CPUSET_FSET.9 \
|
||||
cpuset.9 CPU_CLR.9 \
|
||||
|
@ -215,6 +215,16 @@ amd64 single-instruction implementation.
|
||||
On some architectures updating a counter require a
|
||||
.Xr critical 9
|
||||
section.
|
||||
.Sh EXAMPLES
|
||||
The following example creates a static counter array exported to
|
||||
userspace through a sysctl:
|
||||
.Bd -literal -offset indent
|
||||
#define MY_SIZE 8
|
||||
static counter_u64_t array[MY_SIZE];
|
||||
SYSCTL_COUNTER_U64_ARRAY(_debug, OID_AUTO, counter_array, CTLFLAG_RW,
|
||||
&array[0], MY_SIZE, "Test counter array");
|
||||
.Ed
|
||||
.Pp
|
||||
.Sh SEE ALSO
|
||||
.Xr atomic 9 ,
|
||||
.Xr critical 9 ,
|
||||
|
@ -654,8 +654,10 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
|
||||
SYSCTL_OID(parent, nbr, name, \
|
||||
CTLTYPE_OPAQUE | CTLFLAG_MPSAFE | (access), \
|
||||
(ptr), (len), sysctl_handle_counter_u64_array, "S", descr); \
|
||||
CTASSERT(((access) & CTLTYPE) == 0 || \
|
||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE)
|
||||
CTASSERT((((access) & CTLTYPE) == 0 || \
|
||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE) && \
|
||||
sizeof(counter_u64_t) == sizeof(*(ptr)) && \
|
||||
sizeof(uint64_t) == sizeof(**(ptr)))
|
||||
|
||||
#define SYSCTL_ADD_COUNTER_U64_ARRAY(ctx, parent, nbr, name, access, \
|
||||
ptr, len, descr) \
|
||||
|
Loading…
Reference in New Issue
Block a user