perf metric: Move runtime value to the expr context
[linux-2.6-block.git] / tools / perf / util / expr.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
07516736
AK
2#ifndef PARSE_CTX_H
3#define PARSE_CTX_H 1
4
ded80bda 5// There are fixes that need to land upstream before we can use libbpf's headers,
4d39c89f 6// for now use our copy unconditionally, since the data structures at this point
ded80bda
IR
7// are exactly the same, no problem.
8//#ifdef HAVE_LIBBPF_SUPPORT
9//#include <bpf/hashmap.h>
10//#else
11#include "util/hashmap.h"
12//#endif
07516736 13
fc393839
JO
14struct metric_ref;
15
f6fb0960
JO
16struct expr_id {
17 char *id;
18 struct expr_id *parent;
19};
20
aecce63e 21struct expr_parse_ctx {
cb94a02e 22 struct hashmap *ids;
f6fb0960 23 struct expr_id *parent;
fa831fbb 24 int runtime;
07516736
AK
25};
26
29396cd5 27struct expr_id_data;
070b3b5a 28
871f9f59 29struct expr_scanner_ctx {
1e1a873d 30 int runtime;
871f9f59
JO
31};
32
114a9d6e
IR
33struct hashmap *ids__new(void);
34void ids__free(struct hashmap *ids);
35int ids__insert(struct hashmap *ids, const char *id, struct expr_id *parent);
36/*
37 * Union two sets of ids (hashmaps) and construct a third, freeing ids1 and
38 * ids2.
39 */
40struct hashmap *ids__union(struct hashmap *ids1, struct hashmap *ids2);
41
cb94a02e 42struct expr_parse_ctx *expr__ctx_new(void);
ded80bda 43void expr__ctx_clear(struct expr_parse_ctx *ctx);
cb94a02e 44void expr__ctx_free(struct expr_parse_ctx *ctx);
114a9d6e 45
3fd29fa6 46void expr__del_id(struct expr_parse_ctx *ctx, const char *id);
332603c2 47int expr__add_id(struct expr_parse_ctx *ctx, const char *id);
2c46f542 48int expr__add_id_val(struct expr_parse_ctx *ctx, const char *id, double val);
fc393839 49int expr__add_ref(struct expr_parse_ctx *ctx, struct metric_ref *ref);
5c5f5e83
JO
50int expr__get_id(struct expr_parse_ctx *ctx, const char *id,
51 struct expr_id_data **data);
acf71b05
JO
52int expr__resolve_id(struct expr_parse_ctx *ctx, const char *id,
53 struct expr_id_data **datap);
114a9d6e 54
ded80bda 55int expr__parse(double *final_val, struct expr_parse_ctx *ctx,
fa831fbb 56 const char *expr);
114a9d6e 57
7e06a5e3 58int expr__find_ids(const char *expr, const char *one,
fa831fbb 59 struct expr_parse_ctx *ids);
07516736 60
29396cd5
IR
61double expr_id_data__value(const struct expr_id_data *data);
62struct expr_id *expr_id_data__parent(struct expr_id_data *data);
63
07516736 64#endif