1 /* SPDX-License-Identifier: GPL-2.0 */
5 #ifdef HAVE_LIBBPF_SUPPORT
6 #include <bpf/hashmap.h>
8 #include "util/hashmap.h"
13 struct expr_scanner_ctx {
14 char *user_requested_cpu_list;
19 struct expr_parse_ctx {
21 struct expr_scanner_ctx sctx;
26 struct hashmap *ids__new(void);
27 void ids__free(struct hashmap *ids);
28 int ids__insert(struct hashmap *ids, const char *id);
30 * Union two sets of ids (hashmaps) and construct a third, freeing ids1 and
33 struct hashmap *ids__union(struct hashmap *ids1, struct hashmap *ids2);
35 struct expr_parse_ctx *expr__ctx_new(void);
36 void expr__ctx_clear(struct expr_parse_ctx *ctx);
37 void expr__ctx_free(struct expr_parse_ctx *ctx);
39 void expr__del_id(struct expr_parse_ctx *ctx, const char *id);
40 int expr__add_id(struct expr_parse_ctx *ctx, const char *id);
41 int expr__add_id_val(struct expr_parse_ctx *ctx, const char *id, double val);
42 int expr__add_id_val_source_count(struct expr_parse_ctx *ctx, const char *id,
43 double val, int source_count);
44 int expr__add_ref(struct expr_parse_ctx *ctx, struct metric_ref *ref);
45 int expr__get_id(struct expr_parse_ctx *ctx, const char *id,
46 struct expr_id_data **data);
47 bool expr__subset_of_ids(struct expr_parse_ctx *haystack,
48 struct expr_parse_ctx *needles);
49 int expr__resolve_id(struct expr_parse_ctx *ctx, const char *id,
50 struct expr_id_data **datap);
52 int expr__parse(double *final_val, struct expr_parse_ctx *ctx,
55 int expr__find_ids(const char *expr, const char *one,
56 struct expr_parse_ctx *ids);
58 double expr_id_data__value(const struct expr_id_data *data);
59 double expr_id_data__source_count(const struct expr_id_data *data);
60 double expr__get_literal(const char *literal, const struct expr_scanner_ctx *ctx);