From 43614f5d7e0d18f553c0ee2a4e195d7b8f63be1f Mon Sep 17 00:00:00 2001 From: hunt Date: Tue, 17 May 2005 08:02:30 +0000 Subject: Rewritten maps and other updated files. --- runtime/map.h | 157 ++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 104 insertions(+), 53 deletions(-) (limited to 'runtime/map.h') diff --git a/runtime/map.h b/runtime/map.h index 6b21e299..e48ec574 100644 --- a/runtime/map.h +++ b/runtime/map.h @@ -6,29 +6,47 @@ */ /** @addtogroup maps * @todo Needs to be made SMP-safe for when the big lock is removed from kprobes. - * @{ + * @{ */ -#include +#ifndef HASH_TABLE_BITS +#define HASH_TABLE_BITS 8 +#define HASH_TABLE_SIZE (1<n.key1.str) +#define key1str(ptr) (_stp_key_get_str(ptr,1)) /** Extracts string from key2 union */ -#define key2str(ptr) (ptr->n.key2.str) +#define key2str(ptr) (_stp_key_get_str(ptr,2)) /** Extracts int from key1 union */ -#define key1int(ptr) (ptr->n.key1.val) +#define key1int(ptr) (_stp_key_get_int64(ptr,1)) /** Extracts int from key2 union */ -#define key2int(ptr) (ptr->n.key2.val) +#define key2int(ptr) (_stp_key_get_int64(ptr,2)) /** Macro to call the proper _stp_map_key functions based on the * types of the arguments. @@ -143,7 +150,7 @@ typedef struct map_root *MAP; if (__builtin_types_compatible_p (typeof (key), char[])) \ _stp_map_key_str (map, (char *)(key)); \ else \ - _stp_map_key_long (map, (long)(key)); \ + _stp_map_key_int64 (map, (int64_t)(key)); \ }) /** Macro to call the proper _stp_map_set function based on the @@ -180,6 +187,7 @@ typedef struct map_root *MAP; * * @note May cause compiler warning on some GCCs */ + #define _stp_list_add(map, val) \ ({ \ if (__builtin_types_compatible_p (typeof (val), char[])) \ @@ -190,4 +198,47 @@ typedef struct map_root *MAP; _stp_list_add_int64 (map, (int64_t)(val)); \ }) + +/************* prototypes for map.c ****************/ + +int int64_eq_p(int64_t key1, int64_t key2); +void int64_copy(void *dest, int64_t val); +void int64_add(void *dest, int64_t val); +int64_t int64_get(void *ptr); +void stat_copy(void *dest, stat *src); +void stat_add(void *dest, stat *src); +stat * stat_get(void *ptr); +int64_t _stp_key_get_int64(struct map_node *mn, int n); +char * _stp_key_get_str(struct map_node *mn, int n); +unsigned int int64_hash(const int64_t v); +char * str_get(void *ptr); +void str_copy(char *dest, char *src); +void str_add(void *dest, char *val); +int str_eq_p(char *key1, char *key2); +int64_t _stp_get_int64(struct map_node *m); +char * _stp_get_str(struct map_node *m); +stat * _stp_get_stat(struct map_node *m); +int msb64(int64_t x); +unsigned int str_hash(const char *key1); +static MAP _stp_map_new(unsigned max_entries, int type, int key_size, int data_size); +MAP _stp_map_new_hstat_log(unsigned max_entries, int key_size, int buckets); +MAP _stp_map_new_hstat_linear(unsigned max_entries, int ksize, int start, int stop, int interval); +void _stp_map_key_del(MAP map); +struct map_node * _stp_map_start(MAP map); +struct map_node * _stp_map_iter(MAP map, struct map_node *m); +void _stp_map_del(MAP map); +void _stp_map_print_histogram(MAP map, stat *s); +void _stp_map_print(MAP map, const char *name); +static struct map_node * __stp_map_create(MAP map); + +/* these prototypes suppress warnings from macros */ +void _stp_map_key_str(MAP, char *); +void _stp_map_set_str(MAP, char *); +void _stp_map_set_string(MAP, String); +void _stp_list_add_str(MAP, char*); +void _stp_list_add_string(MAP, String); + +void _stp_map_key_int64(MAP, int64_t); +void _stp_map_set_int64(MAP, int64_t); +int64_t _stp_map_get_int64(MAP); #endif /* _MAP_H_ */ -- cgit