summaryrefslogtreecommitdiffstats
path: root/runtime/map-gen.c
diff options
context:
space:
mode:
authorhunt <hunt>2005-12-14 21:06:57 +0000
committerhunt <hunt>2005-12-14 21:06:57 +0000
commitc5a2dde1672adc9e326fda6533e9dd90f69dc2f1 (patch)
tree69db3e637edec2e4ffcc1aec241e4cd53be4e50b /runtime/map-gen.c
parent51566dc440ab46954f4bfc96048ca1576867297d (diff)
downloadsystemtap-steved-c5a2dde1672adc9e326fda6533e9dd90f69dc2f1.tar.gz
systemtap-steved-c5a2dde1672adc9e326fda6533e9dd90f69dc2f1.tar.xz
systemtap-steved-c5a2dde1672adc9e326fda6533e9dd90f69dc2f1.zip
2005-12-14 Martin Hunt <hunt@redhat.com>
* pmap-gen.c (_stp_pmap_new_*): Initialize lock. (_stp_pmap_set_*): Lock map while in use. (_stp_pmap_add_*): Lock map while in use. (_stp_pmap_get_cpu): Ditto. (_stp_pmap_get): Lock each per-cpu map. * map-gen.c: Define and use NULLRET for a NULL return value. * map.c (_stp_pmap_clear): New function. (_stp_pmap_agg): Lock each per-cpu map as it gets aggregated.
Diffstat (limited to 'runtime/map-gen.c')
-rw-r--r--runtime/map-gen.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/runtime/map-gen.c b/runtime/map-gen.c
index fccdecdc..66654913 100644
--- a/runtime/map-gen.c
+++ b/runtime/map-gen.c
@@ -41,6 +41,7 @@
#define MAP_SET_VAL(a,b,c,d) _new_map_set_str(a,b,c,d)
#define MAP_GET_VAL(n) _stp_get_str(n)
#define VAL_IS_ZERO(val,add) (val == 0 || *val == 0)
+#define NULLRET ""
#elif VALUE_TYPE == INT64
#define VALTYPE int64_t
#define VSTYPE int64_t
@@ -49,6 +50,7 @@
#define MAP_SET_VAL(a,b,c,d) _new_map_set_int64(a,b,c,d)
#define MAP_GET_VAL(n) _stp_get_int64(n)
#define VAL_IS_ZERO(val,add) (val == 0)
+#define NULLRET (int64_t)0
#elif VALUE_TYPE == STAT
#define VALTYPE stat*
#define VSTYPE int64_t
@@ -57,6 +59,7 @@
#define MAP_SET_VAL(a,b,c,d) _new_map_set_stat(a,b,c,d)
#define MAP_GET_VAL(n) _stp_get_stat(n)
#define VAL_IS_ZERO(val,add) (val == 0 && !add)
+#define NULLRET (stat*)0
#else
#error Need to define VALUE_TYPE as STRING, STAT, or INT64
#endif /* VALUE_TYPE */
@@ -466,7 +469,7 @@ VALTYPE KEYSYM(_stp_map_get) (MAP map, ALLKEYSD(key))
struct KEYSYM(map_node) *n;
if (map == NULL)
- return (VALTYPE)0;
+ return NULLRET;
hv = KEYSYM(hash) (ALLKEYS(key));
head = &map->hashes[hv];
@@ -492,11 +495,7 @@ VALTYPE KEYSYM(_stp_map_get) (MAP map, ALLKEYSD(key))
}
}
/* key not found */
-#if VALUE_TYPE == STRING
- return "";
-#else
- return (VALTYPE)0;
-#endif
+ return NULLRET;
}
@@ -550,4 +549,4 @@ VALTYPE KEYSYM(_stp_map_get) (MAP map, ALLKEYSD(key))
#undef MAP_SET_VAL
#undef MAP_GET_VAL
#undef VAL_IS_ZERO
-
+#undef NULLRET