On 03/15/16 01:05, Gleb Smirnoff wrote:
Author: glebius
Date: Tue Mar 15 00:05:00 2016
New Revision: 296880
URL: https://svnweb.freebsd.org/changeset/base/296880
Log:
Provide sysctl(9) macro to deal with array of counter(9).
Modified:
head/share/man/man9/counter.9
head/sys/kern/subr_counter.c
head/sys/sys/sysctl.h
Modified: head/sys/sys/sysctl.h
==============================================================================
--- head/sys/sys/sysctl.h Mon Mar 14 23:49:16 2016 (r296879)
+++ head/sys/sys/sysctl.h Tue Mar 15 00:05:00 2016 (r296880)
@@ -204,6 +204,7 @@ int sysctl_handle_long(SYSCTL_HANDLER_AR
int sysctl_handle_string(SYSCTL_HANDLER_ARGS);
int sysctl_handle_opaque(SYSCTL_HANDLER_ARGS);
int sysctl_handle_counter_u64(SYSCTL_HANDLER_ARGS);
+int sysctl_handle_counter_u64_array(SYSCTL_HANDLER_ARGS);
int sysctl_handle_uma_zone_max(SYSCTL_HANDLER_ARGS);
int sysctl_handle_uma_zone_cur(SYSCTL_HANDLER_ARGS);
@@ -648,6 +649,26 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e
__ptr, 0, sysctl_handle_counter_u64, "QU", __DESCR(descr)); \
})
+/* Oid for an array of counter(9)s. The pointer and length must be non zero.
*/
+#define SYSCTL_COUNTER_U64_ARRAY(parent, nbr, name, access, ptr, len,
descr) \
+ 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)
+
Gleb: I suggest you follow the example of the other static SYSCTLs, and
extend the CTASSERT to also cover the size of the array:
CTASSERT(((access) & CTLTYPE) == 0 || \
(((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE && \
(sizeof(*(ptr)) == 8 * (len))))
+#define SYSCTL_ADD_COUNTER_U64_ARRAY(ctx, parent, nbr, name, access,
\
+ ptr, len, descr) \
+({ \
+ counter_u64_t *__ptr = (ptr); \
+ CTASSERT(((access) & CTLTYPE) == 0 || \
+ ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE); \
Same here possibly. Maybe extend the CTASSERT() to also cover the size
of the array? Would limit the "len" to a constant argument though.
+ sysctl_add_oid(ctx, parent, nbr, name, \
+ CTLTYPE_OPAQUE | CTLFLAG_MPSAFE | (access), \
+ __ptr, len, sysctl_handle_counter_u64_array, "S", \
+ __DESCR(descr)); \
+})
+
/* Oid for an opaque object. Specified by a pointer and a length. */
#define SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr)
\
SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|(access), \
--HPS
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"