Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/sysctl.h
Show All 33 Lines | |||||
* @(#)sysctl.h 8.1 (Berkeley) 6/2/93 | * @(#)sysctl.h 8.1 (Berkeley) 6/2/93 | ||||
* $FreeBSD$ | * $FreeBSD$ | ||||
*/ | */ | ||||
#ifndef _SYS_SYSCTL_H_ | #ifndef _SYS_SYSCTL_H_ | ||||
#define _SYS_SYSCTL_H_ | #define _SYS_SYSCTL_H_ | ||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
#include <sys/queue.h> | #include <sys/tree.h> | ||||
#include <sys/systm.h> | |||||
#endif | #endif | ||||
/* | /* | ||||
* Definitions for sysctl call. The sysctl call uses a hierarchical name | * Definitions for sysctl call. The sysctl call uses a hierarchical name | ||||
* for objects that can be examined or modified. The name is expressed as | * for objects that can be examined or modified. The name is expressed as | ||||
* a sequence of integers. Like a file path name, the meaning of each | * a sequence of integers. Like a file path name, the meaning of each | ||||
* component depends on its place in the hierarchy. The top-level and kern | * component depends on its place in the hierarchy. The top-level and kern | ||||
* identifiers are defined here, and other identifiers are defined in the | * identifiers are defined here, and other identifiers are defined in the | ||||
▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | struct sysctl_req { | ||||
const void *newptr; | const void *newptr; | ||||
size_t newlen; | size_t newlen; | ||||
size_t newidx; | size_t newidx; | ||||
int (*newfunc)(struct sysctl_req *, void *, size_t); | int (*newfunc)(struct sysctl_req *, void *, size_t); | ||||
size_t validlen; | size_t validlen; | ||||
int flags; | int flags; | ||||
}; | }; | ||||
SLIST_HEAD(sysctl_oid_list, sysctl_oid); | struct sysctl_oid; | ||||
/* RB Tree handling */ | |||||
RB_HEAD(sysctl_oid_list, sysctl_oid); | |||||
/* | /* | ||||
* This describes one "oid" in the MIB tree. Potentially more nodes can | * This describes one "oid" in the MIB tree. Potentially more nodes can | ||||
* be hidden behind it, expanded by the handler. | * be hidden behind it, expanded by the handler. | ||||
*/ | */ | ||||
struct sysctl_oid { | struct sysctl_oid { | ||||
struct sysctl_oid_list oid_children; | struct sysctl_oid_list oid_children; | ||||
struct sysctl_oid_list *oid_parent; | struct sysctl_oid_list* oid_parent; | ||||
SLIST_ENTRY(sysctl_oid) oid_link; | RB_ENTRY(sysctl_oid) oid_link; | ||||
/* Sort key for all siblings, and lookup key for userland */ | |||||
int oid_number; | int oid_number; | ||||
u_int oid_kind; | u_int oid_kind; | ||||
void *oid_arg1; | void *oid_arg1; | ||||
intmax_t oid_arg2; | intmax_t oid_arg2; | ||||
/* Must be unique amongst all siblings. */ | |||||
const char *oid_name; | const char *oid_name; | ||||
int (*oid_handler)(SYSCTL_HANDLER_ARGS); | int (*oid_handler)(SYSCTL_HANDLER_ARGS); | ||||
const char *oid_fmt; | const char *oid_fmt; | ||||
int oid_refcnt; | int oid_refcnt; | ||||
u_int oid_running; | u_int oid_running; | ||||
const char *oid_descr; | const char *oid_descr; | ||||
const char *oid_label; | const char *oid_label; | ||||
}; | }; | ||||
static inline int | |||||
cmp_sysctl_oid(struct sysctl_oid *a, struct sysctl_oid *b) | |||||
{ | |||||
hselasky: Please move the opening curly bracket to the next line.
This way of comparing integers leads… | |||||
if (a->oid_number > b->oid_number) | |||||
return (1); | |||||
else if (a->oid_number < b->oid_number) | |||||
return (-1); | |||||
else | |||||
return (0); | |||||
} | |||||
RB_PROTOTYPE(sysctl_oid_list, sysctl_oid, oid_link, cmp_sysctl_oid); | |||||
#define SYSCTL_IN(r, p, l) (r->newfunc)(r, p, l) | #define SYSCTL_IN(r, p, l) (r->newfunc)(r, p, l) | ||||
#define SYSCTL_OUT(r, p, l) (r->oldfunc)(r, p, l) | #define SYSCTL_OUT(r, p, l) (r->oldfunc)(r, p, l) | ||||
#define SYSCTL_OUT_STR(r, p) (r->oldfunc)(r, p, strlen(p) + 1) | #define SYSCTL_OUT_STR(r, p) (r->oldfunc)(r, p, strlen(p) + 1) | ||||
int sysctl_handle_bool(SYSCTL_HANDLER_ARGS); | int sysctl_handle_bool(SYSCTL_HANDLER_ARGS); | ||||
int sysctl_handle_8(SYSCTL_HANDLER_ARGS); | int sysctl_handle_8(SYSCTL_HANDLER_ARGS); | ||||
int sysctl_handle_16(SYSCTL_HANDLER_ARGS); | int sysctl_handle_16(SYSCTL_HANDLER_ARGS); | ||||
int sysctl_handle_32(SYSCTL_HANDLER_ARGS); | int sysctl_handle_32(SYSCTL_HANDLER_ARGS); | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
#else | #else | ||||
#define SYSCTL_ENFORCE_FLAGS(x) | #define SYSCTL_ENFORCE_FLAGS(x) | ||||
#endif | #endif | ||||
/* This macro is only for internal use */ | /* This macro is only for internal use */ | ||||
#define SYSCTL_OID_RAW(id, parent_child_head, nbr, name, kind, a1, a2, handler, fmt, descr, label) \ | #define SYSCTL_OID_RAW(id, parent_child_head, nbr, name, kind, a1, a2, handler, fmt, descr, label) \ | ||||
struct sysctl_oid id = { \ | struct sysctl_oid id = { \ | ||||
.oid_parent = (parent_child_head), \ | .oid_parent = (parent_child_head), \ | ||||
.oid_children = SLIST_HEAD_INITIALIZER(&id.oid_children), \ | .oid_children = RB_INITIALIZER(&id.oid_children), \ | ||||
.oid_number = (nbr), \ | .oid_number = (nbr), \ | ||||
.oid_kind = (kind), \ | .oid_kind = (kind), \ | ||||
.oid_arg1 = (a1), \ | .oid_arg1 = (a1), \ | ||||
.oid_arg2 = (a2), \ | .oid_arg2 = (a2), \ | ||||
.oid_name = (name), \ | .oid_name = (name), \ | ||||
.oid_handler = (handler), \ | .oid_handler = (handler), \ | ||||
.oid_fmt = (fmt), \ | .oid_fmt = (fmt), \ | ||||
.oid_descr = __DESCR(descr), \ | .oid_descr = __DESCR(descr), \ | ||||
▲ Show 20 Lines • Show All 906 Lines • Show Last 20 Lines |
Please move the opening curly bracket to the next line.
This way of comparing integers leads to a signed bit overflow.
Comparing integers for sort, must be done exactly like this: