ac32cda42006fa6cbd338ef2f33cc2d06d7b91c4
[linux-2.6-microblaze.git] / tools / perf / util / expr.h
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 uncoditionally, 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
14 struct expr_parse_ctx {
15         struct hashmap ids;
16 };
17
18 struct expr_id_data {
19         double  val;
20 };
21
22 struct expr_scanner_ctx {
23         int start_token;
24         int runtime;
25 };
26
27 void expr__ctx_init(struct expr_parse_ctx *ctx);
28 void expr__ctx_clear(struct expr_parse_ctx *ctx);
29 int expr__add_id(struct expr_parse_ctx *ctx, const char *id);
30 int expr__add_id_val(struct expr_parse_ctx *ctx, const char *id, double val);
31 int expr__get_id(struct expr_parse_ctx *ctx, const char *id, double *val_ptr);
32 int expr__parse(double *final_val, struct expr_parse_ctx *ctx,
33                 const char *expr, int runtime);
34 int expr__find_other(const char *expr, const char *one,
35                 struct expr_parse_ctx *ids, int runtime);
36
37 #endif