Round out SYSCTL macros to the full set of fixed-width types
Add S8, S16, S32, and U32 types; add SYSCTL*() macros for them, as well as for the existing 64-bit types. (While SYSCTL*QUAD and UQUAD macros already exist, they do not take the same sort of 'val' parameter that the other macros do.) Clean up the documented "types" in the sysctl.9 document. (These are macros and thus not real types, but the manual page documents intent.) The sysctl_add_oid(9) arg2 has been bumped from intptr_t to intmax_t to accommodate 64-bit types on 32-bit pointer architectures. This is just the kernel support piece; the userspace sysctl(1) support will follow in a later patch. Submitted by: Ravi Pokala <rpokala@panasas.com> Reviewed by: cem Relnotes: no Sponsored by: Panasas Differential Revision: https://reviews.freebsd.org/D4091
This commit is contained in:
parent
11c209f341
commit
65f14c5699
@ -1631,10 +1631,16 @@ MLINKS+=sysctl.9 SYSCTL_DECL.9 \
|
||||
sysctl.9 SYSCTL_ADD_PROC.9 \
|
||||
sysctl.9 SYSCTL_ADD_QUAD.9 \
|
||||
sysctl.9 SYSCTL_ADD_ROOT_NODE.9 \
|
||||
sysctl.9 SYSCTL_ADD_S8.9 \
|
||||
sysctl.9 SYSCTL_ADD_S16.9 \
|
||||
sysctl.9 SYSCTL_ADD_S32.9 \
|
||||
sysctl.9 SYSCTL_ADD_S64.9 \
|
||||
sysctl.9 SYSCTL_ADD_STRING.9 \
|
||||
sysctl.9 SYSCTL_ADD_STRUCT.9 \
|
||||
sysctl.9 SYSCTL_ADD_U8.9 \
|
||||
sysctl.9 SYSCTL_ADD_U16.9 \
|
||||
sysctl.9 SYSCTL_ADD_U32.9 \
|
||||
sysctl.9 SYSCTL_ADD_U64.9 \
|
||||
sysctl.9 SYSCTL_ADD_UAUTO.9 \
|
||||
sysctl.9 SYSCTL_ADD_UINT.9 \
|
||||
sysctl.9 SYSCTL_ADD_ULONG.9 \
|
||||
@ -1650,10 +1656,16 @@ MLINKS+=sysctl.9 SYSCTL_DECL.9 \
|
||||
sysctl.9 SYSCTL_PROC.9 \
|
||||
sysctl.9 SYSCTL_QUAD.9 \
|
||||
sysctl.9 SYSCTL_ROOT_NODE.9 \
|
||||
sysctl.9 SYSCTL_S8.9 \
|
||||
sysctl.9 SYSCTL_S16.9 \
|
||||
sysctl.9 SYSCTL_S32.9 \
|
||||
sysctl.9 SYSCTL_S64.9 \
|
||||
sysctl.9 SYSCTL_STRING.9 \
|
||||
sysctl.9 SYSCTL_STRUCT.9 \
|
||||
sysctl.9 SYSCTL_U8.9 \
|
||||
sysctl.9 SYSCTL_U16.9 \
|
||||
sysctl.9 SYSCTL_U32.9 \
|
||||
sysctl.9 SYSCTL_U64.9 \
|
||||
sysctl.9 SYSCTL_UINT.9 \
|
||||
sysctl.9 SYSCTL_ULONG.9 \
|
||||
sysctl.9 SYSCTL_UQUAD.9
|
||||
|
@ -37,10 +37,16 @@
|
||||
.Nm SYSCTL_ADD_PROC ,
|
||||
.Nm SYSCTL_ADD_QUAD ,
|
||||
.Nm SYSCTL_ADD_ROOT_NODE ,
|
||||
.Nm SYSCTL_ADD_S8 ,
|
||||
.Nm SYSCTL_ADD_S16 ,
|
||||
.Nm SYSCTL_ADD_S32 ,
|
||||
.Nm SYSCTL_ADD_S64 ,
|
||||
.Nm SYSCTL_ADD_STRING ,
|
||||
.Nm SYSCTL_ADD_STRUCT ,
|
||||
.Nm SYSCTL_ADD_U8 ,
|
||||
.Nm SYSCTL_ADD_U16 ,
|
||||
.Nm SYSCTL_ADD_U32 ,
|
||||
.Nm SYSCTL_ADD_U64 ,
|
||||
.Nm SYSCTL_ADD_UAUTO ,
|
||||
.Nm SYSCTL_ADD_UINT ,
|
||||
.Nm SYSCTL_ADD_ULONG ,
|
||||
@ -56,10 +62,16 @@
|
||||
.Nm SYSCTL_PROC ,
|
||||
.Nm SYSCTL_QUAD ,
|
||||
.Nm SYSCTL_ROOT_NODE ,
|
||||
.Nm SYSCTL_S8 ,
|
||||
.Nm SYSCTL_S16 ,
|
||||
.Nm SYSCTL_S32 ,
|
||||
.Nm SYSCTL_S64 ,
|
||||
.Nm SYSCTL_STRING ,
|
||||
.Nm SYSCTL_STRUCT ,
|
||||
.Nm SYSCTL_U8 ,
|
||||
.Nm SYSCTL_U16 ,
|
||||
.Nm SYSCTL_U32 ,
|
||||
.Nm SYSCTL_U64 ,
|
||||
.Nm SYSCTL_UINT ,
|
||||
.Nm SYSCTL_ULONG ,
|
||||
.Nm SYSCTL_UQUAD
|
||||
@ -76,7 +88,7 @@
|
||||
.Fa "const char *name"
|
||||
.Fa "int ctlflags"
|
||||
.Fa "int *ptr"
|
||||
.Fa "intptr_t val"
|
||||
.Fa "int val"
|
||||
.Fa "const char *descr"
|
||||
.Fc
|
||||
.Ft struct sysctl_oid *
|
||||
@ -131,7 +143,7 @@
|
||||
.Fa "int number"
|
||||
.Fa "const char *name"
|
||||
.Fa "int ctlflags"
|
||||
.Fa "quad_t *ptr"
|
||||
.Fa "int64_t *ptr"
|
||||
.Fa "const char *descr"
|
||||
.Fc
|
||||
.Ft struct sysctl_oid *
|
||||
@ -144,6 +156,50 @@
|
||||
.Fa "const char *descr"
|
||||
.Fc
|
||||
.Ft struct sysctl_oid *
|
||||
.Fo SYSCTL_ADD_S8
|
||||
.Fa "struct sysctl_ctx_list *ctx"
|
||||
.Fa "struct sysctl_oid_list *parent"
|
||||
.Fa "int number"
|
||||
.Fa "const char *name"
|
||||
.Fa "int ctlflags"
|
||||
.Fa "int8_t *ptr"
|
||||
.Fa "int8_t val"
|
||||
.Fa "const char *descr"
|
||||
.Fc
|
||||
.Ft struct sysctl_oid *
|
||||
.Fo SYSCTL_ADD_S16
|
||||
.Fa "struct sysctl_ctx_list *ctx"
|
||||
.Fa "struct sysctl_oid_list *parent"
|
||||
.Fa "int number"
|
||||
.Fa "const char *name"
|
||||
.Fa "int ctlflags"
|
||||
.Fa "int16_t *ptr"
|
||||
.Fa "int16_t val"
|
||||
.Fa "const char *descr"
|
||||
.Fc
|
||||
.Ft struct sysctl_oid *
|
||||
.Fo SYSCTL_ADD_S32
|
||||
.Fa "struct sysctl_ctx_list *ctx"
|
||||
.Fa "struct sysctl_oid_list *parent"
|
||||
.Fa "int number"
|
||||
.Fa "const char *name"
|
||||
.Fa "int ctlflags"
|
||||
.Fa "int32_t *ptr"
|
||||
.Fa "int32_t val"
|
||||
.Fa "const char *descr"
|
||||
.Fc
|
||||
.Ft struct sysctl_oid *
|
||||
.Fo SYSCTL_ADD_S64
|
||||
.Fa "struct sysctl_ctx_list *ctx"
|
||||
.Fa "struct sysctl_oid_list *parent"
|
||||
.Fa "int number"
|
||||
.Fa "const char *name"
|
||||
.Fa "int ctlflags"
|
||||
.Fa "int64_t *ptr"
|
||||
.Fa "int64_t val"
|
||||
.Fa "const char *descr"
|
||||
.Fc
|
||||
.Ft struct sysctl_oid *
|
||||
.Fo SYSCTL_ADD_STRING
|
||||
.Fa "struct sysctl_ctx_list *ctx"
|
||||
.Fa "struct sysctl_oid_list *parent"
|
||||
@ -172,8 +228,8 @@
|
||||
.Fa "int number"
|
||||
.Fa "const char *name"
|
||||
.Fa "int ctlflags"
|
||||
.Fa "unsigned int *ptr"
|
||||
.Fa "intptr_t val"
|
||||
.Fa "uint8_t *ptr"
|
||||
.Fa "uint8_t val"
|
||||
.Fa "const char *descr"
|
||||
.Fc
|
||||
.Ft struct sysctl_oid *
|
||||
@ -183,8 +239,30 @@
|
||||
.Fa "int number"
|
||||
.Fa "const char *name"
|
||||
.Fa "int ctlflags"
|
||||
.Fa "unsigned int *ptr"
|
||||
.Fa "intptr_t val"
|
||||
.Fa "uint16_t *ptr"
|
||||
.Fa "uint16_t val"
|
||||
.Fa "const char *descr"
|
||||
.Fc
|
||||
.Ft struct sysctl_oid *
|
||||
.Fo SYSCTL_ADD_U32
|
||||
.Fa "struct sysctl_ctx_list *ctx"
|
||||
.Fa "struct sysctl_oid_list *parent"
|
||||
.Fa "int number"
|
||||
.Fa "const char *name"
|
||||
.Fa "int ctlflags"
|
||||
.Fa "uint32_t *ptr"
|
||||
.Fa "uint32_t val"
|
||||
.Fa "const char *descr"
|
||||
.Fc
|
||||
.Ft struct sysctl_oid *
|
||||
.Fo SYSCTL_ADD_U64
|
||||
.Fa "struct sysctl_ctx_list *ctx"
|
||||
.Fa "struct sysctl_oid_list *parent"
|
||||
.Fa "int number"
|
||||
.Fa "const char *name"
|
||||
.Fa "int ctlflags"
|
||||
.Fa "uint64_t *ptr"
|
||||
.Fa "uint64_t val"
|
||||
.Fa "const char *descr"
|
||||
.Fc
|
||||
.Ft struct sysctl_oid *
|
||||
@ -195,7 +273,7 @@
|
||||
.Fa "const char *name"
|
||||
.Fa "int ctlflags"
|
||||
.Fa "unsigned int *ptr"
|
||||
.Fa "intptr_t val"
|
||||
.Fa "unsigned int val"
|
||||
.Fa "const char *descr"
|
||||
.Fc
|
||||
.Ft struct sysctl_oid *
|
||||
@ -215,7 +293,7 @@
|
||||
.Fa "int number"
|
||||
.Fa "const char *name"
|
||||
.Fa "int ctlflags"
|
||||
.Fa "u_quad_t *ptr"
|
||||
.Fa "uint64_t *ptr"
|
||||
.Fa "const char *descr"
|
||||
.Fc
|
||||
.Ft struct sysctl_oid *
|
||||
@ -251,11 +329,17 @@
|
||||
.Fn SYSCTL_OPAQUE parent number name ctlflags ptr len format descr
|
||||
.Fn SYSCTL_PROC parent number name ctlflags arg1 arg2 handler format descr
|
||||
.Fn SYSCTL_QUAD parent number name ctlflags ptr val descr
|
||||
.Fn SYSCTL_ROOT_NODE number name ctlflags handler descr
|
||||
.Fn SYSCTL_S8 parent number name ctlflags ptr val descr
|
||||
.Fn SYSCTL_S16 parent number name ctlflags ptr val descr
|
||||
.Fn SYSCTL_S32 parent number name ctlflags ptr val descr
|
||||
.Fn SYSCTL_S64 parent number name ctlflags ptr val descr
|
||||
.Fn SYSCTL_STRING parent number name ctlflags arg len descr
|
||||
.Fn SYSCTL_STRUCT parent number name ctlflags ptr struct_type descr
|
||||
.Fn SYSCTL_ROOT_NODE number name ctlflags handler descr
|
||||
.Fn SYSCTL_U8 parent number name ctlflags ptr val descr
|
||||
.Fn SYSCTL_U16 parent number name ctlflags ptr val descr
|
||||
.Fn SYSCTL_U32 parent number name ctlflags ptr val descr
|
||||
.Fn SYSCTL_U64 parent number name ctlflags ptr val descr
|
||||
.Fn SYSCTL_UINT parent number name ctlflags ptr val descr
|
||||
.Fn SYSCTL_ULONG parent number name ctlflags ptr val descr
|
||||
.Fn SYSCTL_UQUAD parent number name ctlflags ptr val descr
|
||||
@ -439,10 +523,16 @@ Static sysctls are declared using one of the
|
||||
.Fn SYSCTL_PROC ,
|
||||
.Fn SYSCTL_QUAD ,
|
||||
.Fn SYSCTL_ROOT_NODE ,
|
||||
.Fn SYSCTL_S8 ,
|
||||
.Fn SYSCTL_S16 ,
|
||||
.Fn SYSCTL_S32 ,
|
||||
.Fn SYSCTL_S64 ,
|
||||
.Fn SYSCTL_STRING ,
|
||||
.Fn SYSCTL_STRUCT ,
|
||||
.Fn SYSCTL_U8 ,
|
||||
.Fn SYSCTL_U16 ,
|
||||
.Fn SYSCTL_U32 ,
|
||||
.Fn SYSCTL_U64 ,
|
||||
.Fn SYSCTL_UINT ,
|
||||
.Fn SYSCTL_ULONG
|
||||
or
|
||||
@ -457,10 +547,16 @@ Dynamic nodes are created using one of the
|
||||
.Fn SYSCTL_ADD_PROC ,
|
||||
.Fn SYSCTL_ADD_QUAD ,
|
||||
.Fn SYSCTL_ADD_ROOT_NODE ,
|
||||
.Fn SYSCTL_ADD_S8 ,
|
||||
.Fn SYSCTL_ADD_S16 ,
|
||||
.Fn SYSCTL_ADD_S32 ,
|
||||
.Fn SYSCTL_ADD_S64 ,
|
||||
.Fn SYSCTL_ADD_STRING ,
|
||||
.Fn SYSCTL_ADD_STRUCT ,
|
||||
.Fn SYSCTL_ADD_U8 ,
|
||||
.Fn SYSCTL_ADD_U16 ,
|
||||
.Fn SYSCTL_ADD_U32 ,
|
||||
.Fn SYSCTL_ADD_U64 ,
|
||||
.Fn SYSCTL_ADD_UAUTO ,
|
||||
.Fn SYSCTL_ADD_UINT ,
|
||||
.Fn SYSCTL_ADD_ULONG ,
|
||||
@ -484,6 +580,12 @@ This is a node intended to be a parent for other nodes.
|
||||
This is a signed integer.
|
||||
.It Dv CTLTYPE_STRING
|
||||
This is a nul-terminated string stored in a character array.
|
||||
.It Dv CTLTYPE_S8
|
||||
This is an 8-bit signed integer.
|
||||
.It Dv CTLTYPE_S16
|
||||
This is a 16-bit signed integer.
|
||||
.It Dv CTLTYPE_S32
|
||||
This is a 32-bit signed integer.
|
||||
.It Dv CTLTYPE_S64
|
||||
This is a 64-bit signed integer.
|
||||
.It Dv CTLTYPE_OPAQUE
|
||||
@ -495,14 +597,16 @@ Alias for
|
||||
This is an 8-bit unsigned integer.
|
||||
.It Dv CTLTYPE_U16
|
||||
This is a 16-bit unsigned integer.
|
||||
.It Dv CTLTYPE_U32
|
||||
This is a 32-bit unsigned integer.
|
||||
.It Dv CTLTYPE_U64
|
||||
This is a 64-bit unsigned integer.
|
||||
.It Dv CTLTYPE_UINT
|
||||
This is an unsigned integer.
|
||||
.It Dv CTLTYPE_LONG
|
||||
This is a signed long.
|
||||
.It Dv CTLTYPE_ULONG
|
||||
This is an unsigned long.
|
||||
.It Dv CTLTYPE_U64
|
||||
This is a 64-bit unsigned integer.
|
||||
.El
|
||||
.Pp
|
||||
All sysctl types except for new node declarations require one of the following
|
||||
|
@ -47,7 +47,7 @@
|
||||
.Fa "const char *name"
|
||||
.Fa "int kind"
|
||||
.Fa "void *arg1"
|
||||
.Fa "intptr_t arg2"
|
||||
.Fa "intmax_t arg2"
|
||||
.Fa "int (*handler) (SYSCTL_HANDLER_ARGS)"
|
||||
.Fa "const char *format"
|
||||
.Fa "const char *descr"
|
||||
|
@ -643,7 +643,7 @@ sysctl_remove_oid_locked(struct sysctl_oid *oidp, int del, int recurse)
|
||||
*/
|
||||
struct sysctl_oid *
|
||||
sysctl_add_oid(struct sysctl_ctx_list *clist, struct sysctl_oid_list *parent,
|
||||
int number, const char *name, int kind, void *arg1, intptr_t arg2,
|
||||
int number, const char *name, int kind, void *arg1, intmax_t arg2,
|
||||
int (*handler)(SYSCTL_HANDLER_ARGS), const char *fmt, const char *descr)
|
||||
{
|
||||
struct sysctl_oid *oidp;
|
||||
@ -1191,6 +1191,38 @@ sysctl_handle_16(SYSCTL_HANDLER_ARGS)
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle an int32_t, signed or unsigned.
|
||||
* Two cases:
|
||||
* a variable: point arg1 at it.
|
||||
* a constant: pass it in arg2.
|
||||
*/
|
||||
|
||||
int
|
||||
sysctl_handle_32(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
int32_t tmpout;
|
||||
int error = 0;
|
||||
|
||||
/*
|
||||
* Attempt to get a coherent snapshot by making a copy of the data.
|
||||
*/
|
||||
if (arg1)
|
||||
tmpout = *(int32_t *)arg1;
|
||||
else
|
||||
tmpout = arg2;
|
||||
error = SYSCTL_OUT(req, &tmpout, sizeof(tmpout));
|
||||
|
||||
if (error || !req->newptr)
|
||||
return (error);
|
||||
|
||||
if (!arg1)
|
||||
error = EPERM;
|
||||
else
|
||||
error = SYSCTL_IN(req, arg1, sizeof(tmpout));
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle an int, signed or unsigned.
|
||||
* Two cases:
|
||||
|
129
sys/sys/sysctl.h
129
sys/sys/sysctl.h
@ -75,6 +75,10 @@ struct ctlname {
|
||||
#define CTLTYPE_U64 9 /* name describes an unsigned 64-bit number */
|
||||
#define CTLTYPE_U8 0xa /* name describes an unsigned 8-bit number */
|
||||
#define CTLTYPE_U16 0xb /* name describes an unsigned 16-bit number */
|
||||
#define CTLTYPE_S8 0xc /* name describes a signed 8-bit number */
|
||||
#define CTLTYPE_S16 0xd /* name describes a signed 16-bit number */
|
||||
#define CTLTYPE_S32 0xe /* name describes a signed 32-bit number */
|
||||
#define CTLTYPE_U32 0xf /* name describes an unsigned 32-bit number */
|
||||
|
||||
#define CTLFLAG_RD 0x80000000 /* Allow reads of variable */
|
||||
#define CTLFLAG_WR 0x40000000 /* Allow writes to the variable */
|
||||
@ -192,10 +196,11 @@ struct sysctl_oid {
|
||||
|
||||
int sysctl_handle_8(SYSCTL_HANDLER_ARGS);
|
||||
int sysctl_handle_16(SYSCTL_HANDLER_ARGS);
|
||||
int sysctl_handle_32(SYSCTL_HANDLER_ARGS);
|
||||
int sysctl_handle_64(SYSCTL_HANDLER_ARGS);
|
||||
int sysctl_handle_int(SYSCTL_HANDLER_ARGS);
|
||||
int sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS);
|
||||
int sysctl_handle_long(SYSCTL_HANDLER_ARGS);
|
||||
int sysctl_handle_64(SYSCTL_HANDLER_ARGS);
|
||||
int sysctl_handle_string(SYSCTL_HANDLER_ARGS);
|
||||
int sysctl_handle_opaque(SYSCTL_HANDLER_ARGS);
|
||||
int sysctl_handle_counter_u64(SYSCTL_HANDLER_ARGS);
|
||||
@ -323,6 +328,26 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
|
||||
__arg, len, sysctl_handle_string, "A", __DESCR(descr)); \
|
||||
})
|
||||
|
||||
/* Oid for a signed 8-bit int. If ptr is NULL, val is returned. */
|
||||
#define SYSCTL_NULL_S8_PTR ((unsigned *)NULL)
|
||||
#define SYSCTL_S8(parent, nbr, name, access, ptr, val, descr) \
|
||||
SYSCTL_OID(parent, nbr, name, \
|
||||
CTLTYPE_S8 | CTLFLAG_MPSAFE | (access), \
|
||||
ptr, val, sysctl_handle_8, "C", descr); \
|
||||
CTASSERT((((access) & CTLTYPE) == 0 || \
|
||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S8) && \
|
||||
sizeof(int8_t) == sizeof(*(ptr)))
|
||||
|
||||
#define SYSCTL_ADD_S8(ctx, parent, nbr, name, access, ptr, val, descr) \
|
||||
({ \
|
||||
int8_t *__ptr = (ptr); \
|
||||
CTASSERT(((access) & CTLTYPE) == 0 || \
|
||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S8); \
|
||||
sysctl_add_oid(ctx, parent, nbr, name, \
|
||||
CTLTYPE_S8 | CTLFLAG_MPSAFE | (access), \
|
||||
__ptr, val, sysctl_handle_8, "C", __DESCR(descr)); \
|
||||
})
|
||||
|
||||
/* Oid for an unsigned 8-bit int. If ptr is NULL, val is returned. */
|
||||
#define SYSCTL_NULL_U8_PTR ((unsigned *)NULL)
|
||||
#define SYSCTL_U8(parent, nbr, name, access, ptr, val, descr) \
|
||||
@ -343,6 +368,26 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
|
||||
__ptr, val, sysctl_handle_8, "CU", __DESCR(descr)); \
|
||||
})
|
||||
|
||||
/* Oid for a signed 16-bit int. If ptr is NULL, val is returned. */
|
||||
#define SYSCTL_NULL_S16_PTR ((unsigned *)NULL)
|
||||
#define SYSCTL_S16(parent, nbr, name, access, ptr, val, descr) \
|
||||
SYSCTL_OID(parent, nbr, name, \
|
||||
CTLTYPE_S16 | CTLFLAG_MPSAFE | (access), \
|
||||
ptr, val, sysctl_handle_16, "S", descr); \
|
||||
CTASSERT((((access) & CTLTYPE) == 0 || \
|
||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S16) && \
|
||||
sizeof(int16_t) == sizeof(*(ptr)))
|
||||
|
||||
#define SYSCTL_ADD_S16(ctx, parent, nbr, name, access, ptr, val, descr) \
|
||||
({ \
|
||||
int16_t *__ptr = (ptr); \
|
||||
CTASSERT(((access) & CTLTYPE) == 0 || \
|
||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S16); \
|
||||
sysctl_add_oid(ctx, parent, nbr, name, \
|
||||
CTLTYPE_S16 | CTLFLAG_MPSAFE | (access), \
|
||||
__ptr, val, sysctl_handle_16, "S", __DESCR(descr)); \
|
||||
})
|
||||
|
||||
/* Oid for an unsigned 16-bit int. If ptr is NULL, val is returned. */
|
||||
#define SYSCTL_NULL_U16_PTR ((unsigned *)NULL)
|
||||
#define SYSCTL_U16(parent, nbr, name, access, ptr, val, descr) \
|
||||
@ -355,7 +400,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
|
||||
|
||||
#define SYSCTL_ADD_U16(ctx, parent, nbr, name, access, ptr, val, descr) \
|
||||
({ \
|
||||
uint16_t *__ptr = (ptr); \
|
||||
uint16_t *__ptr = (ptr); \
|
||||
CTASSERT(((access) & CTLTYPE) == 0 || \
|
||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U16); \
|
||||
sysctl_add_oid(ctx, parent, nbr, name, \
|
||||
@ -363,6 +408,86 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
|
||||
__ptr, val, sysctl_handle_16, "SU", __DESCR(descr)); \
|
||||
})
|
||||
|
||||
/* Oid for a signed 32-bit int. If ptr is NULL, val is returned. */
|
||||
#define SYSCTL_NULL_S32_PTR ((unsigned *)NULL)
|
||||
#define SYSCTL_S32(parent, nbr, name, access, ptr, val, descr) \
|
||||
SYSCTL_OID(parent, nbr, name, \
|
||||
CTLTYPE_S32 | CTLFLAG_MPSAFE | (access), \
|
||||
ptr, val, sysctl_handle_32, "I", descr); \
|
||||
CTASSERT((((access) & CTLTYPE) == 0 || \
|
||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S32) && \
|
||||
sizeof(int32_t) == sizeof(*(ptr)))
|
||||
|
||||
#define SYSCTL_ADD_S32(ctx, parent, nbr, name, access, ptr, val, descr) \
|
||||
({ \
|
||||
int32_t *__ptr = (ptr); \
|
||||
CTASSERT(((access) & CTLTYPE) == 0 || \
|
||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S32); \
|
||||
sysctl_add_oid(ctx, parent, nbr, name, \
|
||||
CTLTYPE_S32 | CTLFLAG_MPSAFE | (access), \
|
||||
__ptr, val, sysctl_handle_32, "I", __DESCR(descr)); \
|
||||
})
|
||||
|
||||
/* Oid for an unsigned 32-bit int. If ptr is NULL, val is returned. */
|
||||
#define SYSCTL_NULL_U32_PTR ((unsigned *)NULL)
|
||||
#define SYSCTL_U32(parent, nbr, name, access, ptr, val, descr) \
|
||||
SYSCTL_OID(parent, nbr, name, \
|
||||
CTLTYPE_U32 | CTLFLAG_MPSAFE | (access), \
|
||||
ptr, val, sysctl_handle_32, "IU", descr); \
|
||||
CTASSERT((((access) & CTLTYPE) == 0 || \
|
||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U32) && \
|
||||
sizeof(uint32_t) == sizeof(*(ptr)))
|
||||
|
||||
#define SYSCTL_ADD_U32(ctx, parent, nbr, name, access, ptr, val, descr) \
|
||||
({ \
|
||||
uint32_t *__ptr = (ptr); \
|
||||
CTASSERT(((access) & CTLTYPE) == 0 || \
|
||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U32); \
|
||||
sysctl_add_oid(ctx, parent, nbr, name, \
|
||||
CTLTYPE_U32 | CTLFLAG_MPSAFE | (access), \
|
||||
__ptr, val, sysctl_handle_32, "IU", __DESCR(descr)); \
|
||||
})
|
||||
|
||||
/* Oid for a signed 64-bit int. If ptr is NULL, val is returned. */
|
||||
#define SYSCTL_NULL_S64_PTR ((unsigned *)NULL)
|
||||
#define SYSCTL_S64(parent, nbr, name, access, ptr, val, descr) \
|
||||
SYSCTL_OID(parent, nbr, name, \
|
||||
CTLTYPE_S64 | CTLFLAG_MPSAFE | (access), \
|
||||
ptr, val, sysctl_handle_64, "Q", descr); \
|
||||
CTASSERT((((access) & CTLTYPE) == 0 || \
|
||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64) && \
|
||||
sizeof(int64_t) == sizeof(*(ptr)))
|
||||
|
||||
#define SYSCTL_ADD_S64(ctx, parent, nbr, name, access, ptr, val, descr) \
|
||||
({ \
|
||||
int64_t *__ptr = (ptr); \
|
||||
CTASSERT(((access) & CTLTYPE) == 0 || \
|
||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64); \
|
||||
sysctl_add_oid(ctx, parent, nbr, name, \
|
||||
CTLTYPE_S64 | CTLFLAG_MPSAFE | (access), \
|
||||
__ptr, val, sysctl_handle_64, "Q", __DESCR(descr)); \
|
||||
})
|
||||
|
||||
/* Oid for an unsigned 64-bit int. If ptr is NULL, val is returned. */
|
||||
#define SYSCTL_NULL_U64_PTR ((unsigned *)NULL)
|
||||
#define SYSCTL_U64(parent, nbr, name, access, ptr, val, descr) \
|
||||
SYSCTL_OID(parent, nbr, name, \
|
||||
CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \
|
||||
ptr, val, sysctl_handle_64, "QU", descr); \
|
||||
CTASSERT((((access) & CTLTYPE) == 0 || \
|
||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64) && \
|
||||
sizeof(uint64_t) == sizeof(*(ptr)))
|
||||
|
||||
#define SYSCTL_ADD_U64(ctx, parent, nbr, name, access, ptr, val, descr) \
|
||||
({ \
|
||||
uint64_t *__ptr = (ptr); \
|
||||
CTASSERT(((access) & CTLTYPE) == 0 || \
|
||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64); \
|
||||
sysctl_add_oid(ctx, parent, nbr, name, \
|
||||
CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \
|
||||
__ptr, val, sysctl_handle_64, "QU", __DESCR(descr)); \
|
||||
})
|
||||
|
||||
/* Oid for an int. If ptr is SYSCTL_NULL_INT_PTR, val is returned. */
|
||||
#define SYSCTL_NULL_INT_PTR ((int *)NULL)
|
||||
#define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr) \
|
||||
|
Loading…
Reference in New Issue
Block a user