public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* New runtime Map API
@ 2005-10-26  8:47 Martin Hunt
  0 siblings, 0 replies; only message in thread
From: Martin Hunt @ 2005-10-26  8:47 UTC (permalink / raw)
  To: systemtap

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"








^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-10-26  8:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-26  8:47 New runtime Map API Martin Hunt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).