1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-04-19 18:26:32 +02:00

*** empty log message ***

This commit is contained in:
Jim Meyering
2000-11-05 09:52:55 +00:00
parent aea44f3fa0
commit 983cd11143

39
lib/tru-knlist-demo.c Normal file
View File

@@ -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);
}