Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef PARSE_CTX_H
3#define PARSE_CTX_H 1
4
5// There are fixes that need to land upstream before we can use libbpf's headers,
6// for now use our copy unconditionally, since the data structures at this point
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
13
14struct metric_ref;
15
16struct expr_parse_ctx {
17 struct hashmap *ids;
18 int runtime;
19};
20
21struct expr_id_data;
22
23struct expr_scanner_ctx {
24 int runtime;
25};
26
27struct hashmap *ids__new(void);
28void ids__free(struct hashmap *ids);
29int ids__insert(struct hashmap *ids, const char *id);
30/*
31 * Union two sets of ids (hashmaps) and construct a third, freeing ids1 and
32 * ids2.
33 */
34struct hashmap *ids__union(struct hashmap *ids1, struct hashmap *ids2);
35
36struct expr_parse_ctx *expr__ctx_new(void);
37void expr__ctx_clear(struct expr_parse_ctx *ctx);
38void expr__ctx_free(struct expr_parse_ctx *ctx);
39
40void expr__del_id(struct expr_parse_ctx *ctx, const char *id);
41int expr__add_id(struct expr_parse_ctx *ctx, const char *id);
42int expr__add_id_val(struct expr_parse_ctx *ctx, const char *id, double val);
43int expr__add_id_val_source_count(struct expr_parse_ctx *ctx, const char *id,
44 double val, int source_count);
45int expr__add_ref(struct expr_parse_ctx *ctx, struct metric_ref *ref);
46int expr__get_id(struct expr_parse_ctx *ctx, const char *id,
47 struct expr_id_data **data);
48bool expr__subset_of_ids(struct expr_parse_ctx *haystack,
49 struct expr_parse_ctx *needles);
50int expr__resolve_id(struct expr_parse_ctx *ctx, const char *id,
51 struct expr_id_data **datap);
52
53int expr__parse(double *final_val, struct expr_parse_ctx *ctx,
54 const char *expr);
55
56int expr__find_ids(const char *expr, const char *one,
57 struct expr_parse_ctx *ids);
58
59double expr_id_data__value(const struct expr_id_data *data);
60double expr_id_data__source_count(const struct expr_id_data *data);
61double expr__get_literal(const char *literal);
62
63#endif