summaryrefslogtreecommitdiffstats
path: root/runtime/map-values.c
blob: d41d85b1d0933b3d6e555512d9e33beb9c5da837 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* -*- linux-c -*- 
 * Map value functions
 * Copyright (C) 2005 Red Hat Inc.
 *
 * This file is part of systemtap, and is free software.  You can
 * redistribute it and/or modify it under the terms of the GNU General
 * Public License (GPL); either version 2, or (at your option) any
 * later version.
 */

#ifndef _MAP_VALUES_C_
#define _MAP_VALUES_C_

/** @file map-values.c
 * @brief Includes the proper value functions for maps.
 */

#include "map.h"
#include "map-str.c"
#include "map-stat.c"
#include "map-int.c"

/** 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 or stats.
 *
 * 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
 * @returns \li \c 0 on success \li \c -1 on overflow \li \c -2 on bad map or key
 * @ingroup map_set
 */
int _stp_map_add_int64 (MAP map, int64_t val)
{
	if (map == NULL)
		return -2;

	if (map->type == INT64) 
		return __stp_map_set_int64 (map, val, 1);

	if (map->type == STAT) 
		return _stp_map_add_stat (map, val);

	/* shouldn't get here */
	return -2;
}

unsigned _stp_map_entry_exists (MAP map)
{
	if (map == NULL || map->create || map->key == NULL)
		return 0;
	return 1;
}


#endif /* _MAP_VALUES_C_ */