[rtems-libbsd commit] Add example on SYSCTL_NODE expansion for _bsd_sysctl__net_children

Joel Sherrill joel at rtems.org
Tue Mar 27 18:51:09 UTC 2012


Module:    rtems-libbsd
Branch:    master
Commit:    00ee241553768a40a356208e0402fefb93a508bf
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=00ee241553768a40a356208e0402fefb93a508bf

Author:    Joel Sherrill <joel.sherrill at oarcorp.com>
Date:      Tue Mar 27 13:51:45 2012 -0500

Add example on SYSCTL_NODE expansion for _bsd_sysctl__net_children

---

 libbsd.txt |   43 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/libbsd.txt b/libbsd.txt
index 32e120b..56b47f1 100644
--- a/libbsd.txt
+++ b/libbsd.txt
@@ -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");
+----
+




More information about the vc mailing list