This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

New runtime Map API


Part 1 of the Runtime MAP API changes is now checked in.
I'll be checking in pmaps with this new API next.

THE OLD API IS DEPRECATED AND WILL BE DELETED AS SOON AS THE TRANSLATOR
USES THE NEW API.

I still have documentation to update. Meanwhile, you can see examples of
the old vs new in runtime/tests/maps. Filenames ending with 2 use the
new API. For example, ii.c amd ii2.c.

OLD
#define NEED_INT64_VALS
#define KEY1_TYPE INT64
#include "map-keys.c"

#include "map.c"

int main ()
{
  MAP map = _stp_map_new_int64(4, INT64);

  /* map[1] = 2 */
  _stp_map_key_int64 (map, 1);
  _stp_map_set_int64 (map, 2);
--------------
NEW
#define VALUE_TYPE INT64
#define KEY1_TYPE INT64
#include "map-gen.c"

#include "map.c"

int main ()
{
  MAP map = _stp_map_new_ii(4);

  /* map[1] = 2 */
  _stp_map_set_ii(map, 1, 2);
------------

For every combination of keys and values, #define VALUE_TYPE and
KEYn_TYPE then include "map-gen.c"

generated function names are now as follows
_stp_map_new_[isx]+
_stp_map_set_[isx]+
_stp_map_add_[isx]+
_stp_map_get_[isx]+

i = int64
s = string
x = stat

So to create a map with keys of string, string, int64 and values of
stat:
#define VALUE_TYPE STAT
#define KEY1_TYPE STRING
#define KEY2_TYPE STRING
#define KEY3_TYPE INT64
#include "map-gen.c"
and
_stp_map_new_ssix(...)
_stp_map_add_ssix(...)

See map_format2.c, isx2.c, and setadd.c  for examples of stats and
histograms.
-------------------

maps no longer wrap by default. In case anyone depended on this, the
default behavior is now to return an error if a set call cannot get a
free node. You can restore wrapping  with "map->wrap = 1"









Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]