Add new kernel config option. NO_SYSCTL_DESCR to omit the descriptions for

the sysctls.  This saves a lot of space in the resulting kernel which is
important for embedded systems.  This change was done in a ABI compatible
way.  The pointer is still there, it just points to an empty string instead
of the description.

MFC After: 3 days
This commit is contained in:
Warner Losh 2006-07-18 17:00:51 +00:00
parent 845b8cbcbf
commit 16c84e5e51
2 changed files with 21 additions and 12 deletions

View File

@ -56,6 +56,8 @@ KDB_TRACE opt_kdb.h
KDB_UNATTENDED opt_kdb.h
SYSCTL_DEBUG opt_sysctl.h
NO_SYSCTL_DESCR opt_global.h
# Miscellaneous options.
ADAPTIVE_GIANT opt_adaptive_mutexes.h
NO_ADAPTIVE_MUTEXES opt_adaptive_mutexes.h
@ -206,6 +208,7 @@ FFS opt_ffs_broken_fixme.h
# filesystems will be enabled - but look below.
NFSCLIENT opt_nfs.h
NFSSERVER opt_nfs.h
NFS4CLIENT opt_nfs.h
# filesystems and libiconv bridge
CD9660_ICONV opt_dontuse.h

View File

@ -205,15 +205,21 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
#define SYSCTL_NODE_CHILDREN(parent, name) \
sysctl_##parent##_##name##_children
#ifndef NO_SYSCTL_DESCR
#define __DESCR(d) d
#else
#define __DESCR(d) ""
#endif
/* This constructs a "raw" MIB oid. */
#define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \
static struct sysctl_oid sysctl__##parent##_##name = { \
&sysctl_##parent##_children, { 0 }, \
nbr, kind, a1, a2, #name, handler, fmt, 0, descr }; \
nbr, kind, a1, a2, #name, handler, fmt, 0, __DESCR(descr) }; \
DATA_SET(sysctl_set, sysctl__##parent##_##name)
#define SYSCTL_ADD_OID(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, descr) \
sysctl_add_oid(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, descr)
sysctl_add_oid(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, __DESCR(descr))
/* This constructs a node from which other oids can hang. */
#define SYSCTL_NODE(parent, nbr, name, access, handler, descr) \
@ -224,7 +230,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
#define SYSCTL_ADD_NODE(ctx, parent, nbr, name, access, handler, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_NODE|(access), \
0, 0, handler, "N", descr)
0, 0, handler, "N", __DESCR(descr))
/* Oid for a string. len can be 0 to indicate '\0' termination. */
#define SYSCTL_STRING(parent, nbr, name, access, arg, len, descr) \
@ -233,7 +239,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
#define SYSCTL_ADD_STRING(ctx, parent, nbr, name, access, arg, len, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING|(access), \
arg, len, sysctl_handle_string, "A", descr)
arg, len, sysctl_handle_string, "A", __DESCR(descr))
/* Oid for an int. If ptr is NULL, val is returned. */
#define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr) \
@ -242,7 +248,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
#define SYSCTL_ADD_INT(ctx, parent, nbr, name, access, ptr, val, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_INT|(access), \
ptr, val, sysctl_handle_int, "I", descr)
ptr, val, sysctl_handle_int, "I", __DESCR(descr))
/* Oid for an unsigned int. If ptr is NULL, val is returned. */
#define SYSCTL_UINT(parent, nbr, name, access, ptr, val, descr) \
@ -251,7 +257,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
#define SYSCTL_ADD_UINT(ctx, parent, nbr, name, access, ptr, val, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UINT|(access), \
ptr, val, sysctl_handle_int, "IU", descr)
ptr, val, sysctl_handle_int, "IU", __DESCR(descr))
/* Oid for a long. The pointer must be non NULL. */
#define SYSCTL_LONG(parent, nbr, name, access, ptr, val, descr) \
@ -260,16 +266,16 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
#define SYSCTL_ADD_LONG(ctx, parent, nbr, name, access, ptr, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_LONG|(access), \
ptr, 0, sysctl_handle_long, "L", descr)
ptr, 0, sysctl_handle_long, "L", __DESCR(descr))
/* Oid for an unsigned long. The pointer must be non NULL. */
#define SYSCTL_ULONG(parent, nbr, name, access, ptr, val, descr) \
SYSCTL_OID(parent, nbr, name, CTLTYPE_ULONG|(access), \
ptr, val, sysctl_handle_long, "LU", descr)
ptr, val, sysctl_handle_long, "LU", __DESCR(descr))
#define SYSCTL_ADD_ULONG(ctx, parent, nbr, name, access, ptr, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_ULONG|(access), \
ptr, 0, sysctl_handle_long, "LU", descr)
ptr, 0, sysctl_handle_long, "LU", __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) \
@ -278,7 +284,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
#define SYSCTL_ADD_OPAQUE(ctx, parent, nbr, name, access, ptr, len, fmt, descr)\
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \
ptr, len, sysctl_handle_opaque, fmt, descr)
ptr, len, sysctl_handle_opaque, fmt, __DESCR(descr))
/* Oid for a struct. Specified by a pointer and a type. */
#define SYSCTL_STRUCT(parent, nbr, name, access, ptr, type, descr) \
@ -288,7 +294,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
#define SYSCTL_ADD_STRUCT(ctx, parent, nbr, name, access, ptr, type, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \
ptr, sizeof(struct type), sysctl_handle_opaque, "S," #type, descr)
ptr, sizeof(struct type), sysctl_handle_opaque, "S," #type, __DESCR(descr))
/* Oid for a procedure. Specified by a pointer and an arg. */
#define SYSCTL_PROC(parent, nbr, name, access, ptr, arg, handler, fmt, descr) \
@ -297,7 +303,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
#define SYSCTL_ADD_PROC(ctx, parent, nbr, name, access, ptr, arg, handler, fmt, descr) \
sysctl_add_oid(ctx, parent, nbr, name, (access), \
ptr, arg, handler, fmt, descr)
ptr, arg, handler, fmt, __DESCR(descr))
#endif /* _KERNEL */