diff options
author | hunt <hunt> | 2005-03-21 21:47:54 +0000 |
---|---|---|
committer | hunt <hunt> | 2005-03-21 21:47:54 +0000 |
commit | 33776f4955fa52ae3e4dc87ab6ac484a3ebc9a71 (patch) | |
tree | 3d5346f8ba9553804b71806b94654ffe703f3b29 /runtime/map.c | |
parent | d14648baf61205e4259da53b383931f20c41c5bb (diff) | |
download | systemtap-steved-33776f4955fa52ae3e4dc87ab6ac484a3ebc9a71.tar.gz systemtap-steved-33776f4955fa52ae3e4dc87ab6ac484a3ebc9a71.tar.xz systemtap-steved-33776f4955fa52ae3e4dc87ab6ac484a3ebc9a71.zip |
*** empty log message ***
Diffstat (limited to 'runtime/map.c')
-rw-r--r-- | runtime/map.c | 49 |
1 files changed, 36 insertions, 13 deletions
diff --git a/runtime/map.c b/runtime/map.c index 9b264c3a..8341233e 100644 --- a/runtime/map.c +++ b/runtime/map.c @@ -458,17 +458,7 @@ static void map_copy_keys(MAP map, struct map_node *m) map->num++; } -/** Set the current element's value to an int64. - * This sets the current element's value to an int64. The map must have been created - * to hold int64s using _stp_map_new() - * - * If the element doesn't exist, it is created. If no current element (key) - * is set for the map, this function does nothing. - * @param map - * @param val new value - */ - -void _stp_map_set_int64(MAP map, int64_t val) +static void __stp_map_set_int64(MAP map, int64_t val, int add) { struct map_node_int64 *m; @@ -512,14 +502,47 @@ void _stp_map_set_int64(MAP map, int64_t val) if (val) { m = (struct map_node_int64 *)map->key; - m->val = val; - } else { + if (add) + m->val += val; + else + m->val = val; + } else if (!add) { /* setting value to 0 is the same as deleting */ _stp_map_key_del(map); } } } +/** Set the current element's value to an int64. + * This sets the current element's value to an int64. The map must have been created + * to hold int64s using _stp_map_new() + * + * If the element doesn't exist, it is created. If no current element (key) + * is set for the map, this function does nothing. + * @param map + * @param val new value + */ +void _stp_map_set_int64(MAP map, int64_t val) +{ + __stp_map_set_int64 (map, val, 0); +} + + +/** Adds an int64 to the current element's value. + * This adds an int64 to the current element's value. The map must have been created + * to hold int64s using _stp_map_new() + * + * If the element doesn't exist, it is created. If no current element (key) + * is set for the map, this function does nothing. + * @param map + * @param val value + */ + +void _stp_map_add_int64(MAP map, int64_t val) +{ + __stp_map_set_int64 (map, val, 1); +} + /** Gets the current element's value. * @param map * @returns The value. If the current element is not set or doesn't exist, returns 0. |