Mercurial > hg > octave-kai > gnulib-hg
changeset 2960:2b6b3728f6f6
*** empty log message ***
author | Jim Meyering <jim@meyering.net> |
---|---|
date | Sun, 05 Nov 2000 09:52:55 +0000 |
parents | 039105c82820 |
children | 6f34939d48af |
files | lib/tru-knlist-demo.c |
diffstat | 1 files changed, 39 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/lib/tru-knlist-demo.c @@ -0,0 +1,39 @@ +/* From the knlist manpage */ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <nlist.h> +main () +{ + struct nlist nl[3]; + int retval, i; + nl[0].n_name = (char *)malloc(10); + nl[1].n_name = (char *)malloc(10); + nl[2].n_name = ""; + + /*******************************************************/ + /* Store names of kernel symbols in the nl array */ + strcpy (nl[0].n_name, "ncpus"); + strcpy (nl[1].n_name, "lockmode"); + + /*******************************************************/ + /* Call the knlist routine */ + retval = knlist(nl); + + /******************************************************/ + /* Display addresses if returned. Otherwise, display */ + /* the appropriate error message. */ + if (retval < 0) + printf ("No kernel symbol addresses returned.\n"); + else + if (retval >= 0 ) + for (i=0; i<2; i++) + if (nl[i].n_type == 0) + printf ("Unable to return address of symbol %s\n", + nl[i].n_name); + else + printf ("The address of symbol %s is %lx\n", + nl[i].n_name, nl[i].n_value); + free (nl[0].n_name); + free (nl[1].n_name); +}