Add example on SYSCTL_NODE expansion for _bsd_sysctl__net_children

This commit is contained in:
Joel Sherrill 2012-03-27 13:51:45 -05:00
parent 9fe8c97ccd
commit 00ee241553

View File

@ -272,3 +272,46 @@ time and the various initialization routines will thus be executed in'
the correct order.
XXX This needs more details.
=== SYSCTL_NODE Example
During development, we had an undefined reference to
_bsd_sysctl__net_children that we had trouble tracking down. Thanks to
Chris Johns, we located it. He explained how to read SYSCTL_NODE
definitions. This line from freebsd/netinet/in_proto.c is attempting
to add the "inet" node to the parent node "_net".
[listing]
----
SYSCTL_NODE(_net, PF_INET, inet, CTLFLAG_RW, 0,
"Internet Family");
----
Our problem was that we could not find where _bsd_sysctl__net_children
was defined. Chris suggested that when in doubt compile with -save-temps
and look at the preprocessed .i files. But he did not need that. He
explained that this the symbol name _bsd_sysctl__net_children was
automatically generated by a SYSCTL_NODE as follows:
* _bsd_ - added by RTEMS modifications to SYSCTL_NODE macro
* sysctl_ - boilerplace added by SYSCTL_NODE macro
* "" - empty string for parent node
* net - name of SYSCTL_NODE
* children - added by SYSCTL macros
This was all generated by a support macro declaring the node as this:
[listing]
----
struct sysctl_oid_list SYSCTL_NODE_CHILDREN(parent, name);
----
Given this information, we located this SYSCTL_NODE declaration in
kern/kern_mib.c
[listing]
----
SYSCTL_NODE(, CTL_KERN, kern, CTLFLAG_RW, 0,
"High kernel, proc, limits &c");
----