Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/sysctl.h
Show First 20 Lines • Show All 340 Lines • ▼ Show 20 Lines | |||||
#define SYSCTL_STRING(parent, nbr, name, access, arg, len, descr) \ | #define SYSCTL_STRING(parent, nbr, name, access, arg, len, descr) \ | ||||
SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING|(access), \ | SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING|(access), \ | ||||
arg, len, sysctl_handle_string, "A", descr); \ | arg, len, sysctl_handle_string, "A", descr); \ | ||||
CTASSERT(((access) & CTLTYPE) == 0 || \ | CTASSERT(((access) & CTLTYPE) == 0 || \ | ||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING) | ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING) | ||||
#define SYSCTL_ADD_STRING(ctx, parent, nbr, name, access, arg, len, descr) \ | #define SYSCTL_ADD_STRING(ctx, parent, nbr, name, access, arg, len, descr) \ | ||||
({ \ | ({ \ | ||||
char *__arg = (arg); \ | char *__arg = (arg); \ | ||||
CTASSERT(((access) & CTLTYPE) == 0 || \ | CTASSERT(((access) & CTLTYPE) == 0 || \ | ||||
jacob.e.keller_intel.com: This could be reduced to __drop_const(__arg = (arg)), i'm not sure if that's better or not.
I… | |||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING); \ | ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING); \ | ||||
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING|(access), \ | sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING|(access), \ | ||||
__arg, len, sysctl_handle_string, "A", __DESCR(descr), \ | __arg, len, sysctl_handle_string, "A", __DESCR(descr), \ | ||||
NULL); \ | NULL); \ | ||||
}) | }) | ||||
/* Oid for a constant '\0' terminated string. */ | |||||
#define SYSCTL_CONST_STRING(parent, nbr, name, access, arg, descr) \ | |||||
SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING|(access), \ | |||||
__DECONST(char *, arg), 0, sysctl_handle_string, "A", descr); \ | |||||
CTASSERT(!(access & CTLFLAG_WR)); \ | |||||
CTASSERT(((access) & CTLTYPE) == 0 || \ | |||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING) | |||||
#define SYSCTL_ADD_CONST_STRING(ctx, parent, nbr, name, access, arg, descr) \ | |||||
({ \ | |||||
char *__arg = __DECONST(char *, arg); \ | |||||
CTASSERT(!(access & CTLFLAG_WR)); \ | |||||
CTASSERT(((access) & CTLTYPE) == 0 || \ | |||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING); \ | |||||
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING|(access), \ | |||||
__arg, 0, sysctl_handle_string, "A", __DESCR(descr), \ | |||||
NULL); \ | |||||
}) | |||||
/* Oid for a bool. If ptr is NULL, val is returned. */ | /* Oid for a bool. If ptr is NULL, val is returned. */ | ||||
#define SYSCTL_NULL_BOOL_PTR ((bool *)NULL) | #define SYSCTL_NULL_BOOL_PTR ((bool *)NULL) | ||||
#define SYSCTL_BOOL(parent, nbr, name, access, ptr, val, descr) \ | #define SYSCTL_BOOL(parent, nbr, name, access, ptr, val, descr) \ | ||||
SYSCTL_OID(parent, nbr, name, \ | SYSCTL_OID(parent, nbr, name, \ | ||||
CTLTYPE_U8 | CTLFLAG_MPSAFE | (access), \ | CTLTYPE_U8 | CTLFLAG_MPSAFE | (access), \ | ||||
ptr, val, sysctl_handle_bool, "CU", descr); \ | ptr, val, sysctl_handle_bool, "CU", descr); \ | ||||
CTASSERT(((access) & CTLTYPE) == 0 && \ | CTASSERT(((access) & CTLTYPE) == 0 && \ | ||||
sizeof(bool) == sizeof(*(ptr))) | sizeof(bool) == sizeof(*(ptr))) | ||||
▲ Show 20 Lines • Show All 743 Lines • Show Last 20 Lines |
This could be reduced to drop_const(arg = (arg)), i'm not sure if that's better or not.
I tried using __builtin_constant_p(len) && len==0 as a way to decide which expression to use, but clang wasn't smart enough to constant-fold that check, so it didn't work.