summaryrefslogtreecommitdiffstats
path: root/runtime/docs/examples
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/docs/examples')
-rw-r--r--runtime/docs/examples/argv.c5
-rw-r--r--runtime/docs/examples/foreach.c10
-rw-r--r--runtime/docs/examples/list.c7
-rw-r--r--runtime/docs/examples/map.c2
4 files changed, 14 insertions, 10 deletions
diff --git a/runtime/docs/examples/argv.c b/runtime/docs/examples/argv.c
index 609ad74f..0acd41e0 100644
--- a/runtime/docs/examples/argv.c
+++ b/runtime/docs/examples/argv.c
@@ -8,6 +8,7 @@ int inst_do_execve (char * filename, char __user *__user *argv, char __user *__u
_stp_copy_argv_from_user (arglist, argv);
foreach (arglist, ptr)
- printk ("%s ", ptr->str);
- printk ("\n");
+ _stp_printf ("%s ", _stp_get_str(ptr));
+ _stp_print("\n");
+
}
diff --git a/runtime/docs/examples/foreach.c b/runtime/docs/examples/foreach.c
index fc110674..8000d60b 100644
--- a/runtime/docs/examples/foreach.c
+++ b/runtime/docs/examples/foreach.c
@@ -1,9 +1,9 @@
/* example showing how to print all the stats in a map using foreach() */
-struct map_node_stat *ptr;
+ struct map_node *ptr;
+
+ foreach (mapsst, ptr)
+ _stp_printf ("mapsst[%09s,%09s] = %llX\n", key1str(ptr), key2str(ptr), _stp_get_stat(ptr)->sum);
+
-foreach (map, ptr)
- printf ("map[%s,%ld] = [c=%lld s=%lld min=%lld max=%lld]\n", key1str(ptr),
- key2int(ptr), ptr->stats.count, ptr->stats.sum, ptr->stats.min,
- ptr->stats.max);
diff --git a/runtime/docs/examples/list.c b/runtime/docs/examples/list.c
index 15d13d4b..6294cccb 100644
--- a/runtime/docs/examples/list.c
+++ b/runtime/docs/examples/list.c
@@ -1,5 +1,5 @@
-struct map_node_str *ptr;
+struct map_node *ptr;
MAP map = _stp_list_new(10, STRING);
@@ -8,7 +8,10 @@ for (i = 0; i < 10; i++) {
_stp_list_add (map, buf);
}
+/* old way to print a list of strings */
foreach (map, ptr)
- printf ("map[%ld] = %s\n", key1int(ptr), ptr->str);
+ _stp_printf ("list[%ld] = %s\n", key1int(ptr), _stp_get_str(ptr));
+/* new way to print a list of strings */
+ _stp_map_print(map, "list[%1d] = %s");
diff --git a/runtime/docs/examples/map.c b/runtime/docs/examples/map.c
index ca661d05..f5f6f19f 100644
--- a/runtime/docs/examples/map.c
+++ b/runtime/docs/examples/map.c
@@ -1,6 +1,6 @@
/* create a map with a max of 100 elements */
-MAP mymap = map_new(100, INT64);
+MAP mymap = _stp_map_new(100, INT64);
/* mymap[birth year] = 2000 */
map_key_str (mymap, "birth year");