Loading...
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef PARSE_CTX_H
3#define PARSE_CTX_H 1
4
5#define EXPR_MAX_OTHER 15
6#define MAX_PARSE_ID EXPR_MAX_OTHER
7
8struct parse_id {
9 const char *name;
10 double val;
11};
12
13struct parse_ctx {
14 int num_ids;
15 struct parse_id ids[MAX_PARSE_ID];
16};
17
18void expr__ctx_init(struct parse_ctx *ctx);
19void expr__add_id(struct parse_ctx *ctx, const char *id, double val);
20#ifndef IN_EXPR_Y
21int expr__parse(double *final_val, struct parse_ctx *ctx, const char **pp);
22#endif
23int expr__find_other(const char *p, const char *one, const char ***other,
24 int *num_other);
25
26#endif
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_id {
17 char *id;
18 struct expr_id *parent;
19};
20
21struct expr_parse_ctx {
22 struct hashmap ids;
23 struct expr_id *parent;
24};
25
26struct expr_id_data;
27
28struct expr_scanner_ctx {
29 int start_token;
30 int runtime;
31};
32
33void expr__ctx_init(struct expr_parse_ctx *ctx);
34void expr__ctx_clear(struct expr_parse_ctx *ctx);
35void expr__del_id(struct expr_parse_ctx *ctx, const char *id);
36int expr__add_id(struct expr_parse_ctx *ctx, const char *id);
37int expr__add_id_val(struct expr_parse_ctx *ctx, const char *id, double val);
38int expr__add_ref(struct expr_parse_ctx *ctx, struct metric_ref *ref);
39int expr__get_id(struct expr_parse_ctx *ctx, const char *id,
40 struct expr_id_data **data);
41int expr__resolve_id(struct expr_parse_ctx *ctx, const char *id,
42 struct expr_id_data **datap);
43int expr__parse(double *final_val, struct expr_parse_ctx *ctx,
44 const char *expr, int runtime);
45int expr__find_other(const char *expr, const char *one,
46 struct expr_parse_ctx *ids, int runtime);
47
48double expr_id_data__value(const struct expr_id_data *data);
49struct expr_id *expr_id_data__parent(struct expr_id_data *data);
50
51#endif