Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

map.h File Reference

Header file for maps and lists. More...

#include <linux/types.h>

Go to the source code of this file.

Defines

#define key1str(ptr)   (ptr->n.key1.str)
 Extracts string from key1 union.
#define key2str(ptr)   (ptr->n.key2.str)
 Extracts string from key2 union.
#define key1int(ptr)   (ptr->n.key1.val)
 Extracts int from key1 union.
#define key2int(ptr)   (ptr->n.key2.val)
 Extracts int from key2 union.
#define _stp_map_key2(map, key1, key2)
 Macro to call the proper _stp_map_key functions based on the types of the arguments.
#define _stp_map_key(map, key)
 Macro to call the proper _stp_map_key function based on the type of the argument.
#define _stp_map_set(map, val)
 Macro to call the proper _stp_map_set function based on the type of the argument.
#define _stp_list_add(map, val)
 Macro to call the proper _stp_list_add function based on the types of the argument.
#define foreach(map, ptr)
 Loop through all elements of a map.

Typedefs

typedef map_rootMAP
 All maps are of this type.

Enumerations

enum  keytype { NONE, LONG, STR }
 keys can be longs or strings
enum  valtype { INT64, STAT, STRING, END }
 values can be either int64, stats or strings

Variables

enum keytype packed
 keys can be longs or strings


Detailed Description

Header file for maps and lists.

Definition in file map.h.


Define Documentation

#define _stp_list_add map,
val   ) 
 

Value:

({                                                              \
    if (__builtin_types_compatible_p (typeof (val), char[]))    \
      _stp_list_add_str (map, (char *)(val));                           \
    else                                                        \
      _stp_list_add_int64 (map, (int64_t)(val));                        \
  })
Macro to call the proper _stp_list_add function based on the types of the argument.

Note:
May cause compiler warning on some GCCs

Definition at line 159 of file map.h.

#define _stp_map_key map,
key   ) 
 

Value:

({                                                              \
    if (__builtin_types_compatible_p (typeof (key), char[]))    \
      _stp_map_key_str (map, (char *)(key));                            \
    else                                                        \
      _stp_map_key_long (map, (long)(key));                             \
  })
Macro to call the proper _stp_map_key function based on the type of the argument.

Note:
May cause compiler warning on some GCCs

Definition at line 135 of file map.h.

#define _stp_map_key2 map,
key1,
key2   ) 
 

Value:

({                                                              \
    if (__builtin_types_compatible_p (typeof (key1), char[]))   \
      if (__builtin_types_compatible_p (typeof (key2), char[])) \
        _stp_map_key_str_str (map, (char *)(key1), (char *)(key2));     \
      else                                                      \
        _stp_map_key_str_long (map, (char *)(key1), (long)(key2));      \
    else                                                        \
      if (__builtin_types_compatible_p (typeof (key2), char[])) \
        _stp_map_key_long_str (map, (long)(key1), (char *)(key2));      \
      else                                                      \
        _stp_map_key_long_long (map, (long)(key1), (long)(key2));       \
  })
Macro to call the proper _stp_map_key functions based on the types of the arguments.

Note:
May cause compiler warning on some GCCs

Definition at line 117 of file map.h.

#define _stp_map_set map,
val   ) 
 

Value:

({                                                              \
    if (__builtin_types_compatible_p (typeof (val), char[]))    \
      _stp_map_set_str (map, (char *)(val));                            \
    else                                                        \
      _stp_map_set_int64 (map, (int64_t)(val));                 \
  })
Macro to call the proper _stp_map_set function based on the type of the argument.

Note:
May cause compiler warning on some GCCs

Definition at line 147 of file map.h.

#define foreach map,
ptr   ) 
 

Value:

for (ptr = (typeof(ptr))_stp_map_start(map); ptr; \
       ptr = (typeof(ptr))_stp_map_iter (map, (struct map_node *)ptr))
Loop through all elements of a map.

Parameters:
map 
ptr pointer to a map_node_stat, map_node_int64 or map_node_str
Example:
/* example showing how to print all the stats in a map using foreach() */

struct map_node_stat *ptr;

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);

Definition at line 176 of file map.h.


Generated on Tue Mar 22 10:27:36 2005 for SystemTap.