Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Andi Kleen | 0751673 | 2017-03-20 13:17:05 -0700 | [diff] [blame] | 2 | #ifndef PARSE_CTX_H |
| 3 | #define PARSE_CTX_H 1 |
| 4 | |
Ian Rogers | ded80bd | 2020-05-15 15:17:32 -0700 | [diff] [blame] | 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 |
Andi Kleen | 0751673 | 2017-03-20 13:17:05 -0700 | [diff] [blame] | 13 | |
Jiri Olsa | aecce63 | 2020-04-02 02:03:34 +0530 | [diff] [blame] | 14 | struct expr_parse_ctx { |
Ian Rogers | ded80bd | 2020-05-15 15:17:32 -0700 | [diff] [blame] | 15 | struct hashmap ids; |
Andi Kleen | 0751673 | 2017-03-20 13:17:05 -0700 | [diff] [blame] | 16 | }; |
| 17 | |
Jiri Olsa | 871f9f5 | 2020-04-02 02:03:35 +0530 | [diff] [blame] | 18 | struct expr_scanner_ctx { |
| 19 | int start_token; |
Kajol Jain | 1e1a873 | 2020-04-02 02:03:37 +0530 | [diff] [blame] | 20 | int runtime; |
Jiri Olsa | 871f9f5 | 2020-04-02 02:03:35 +0530 | [diff] [blame] | 21 | }; |
| 22 | |
Jiri Olsa | aecce63 | 2020-04-02 02:03:34 +0530 | [diff] [blame] | 23 | void expr__ctx_init(struct expr_parse_ctx *ctx); |
Ian Rogers | ded80bd | 2020-05-15 15:17:32 -0700 | [diff] [blame] | 24 | void expr__ctx_clear(struct expr_parse_ctx *ctx); |
| 25 | int expr__add_id(struct expr_parse_ctx *ctx, const char *id, double val); |
| 26 | int expr__get_id(struct expr_parse_ctx *ctx, const char *id, double *val_ptr); |
| 27 | int expr__parse(double *final_val, struct expr_parse_ctx *ctx, |
| 28 | const char *expr, int runtime); |
| 29 | int expr__find_other(const char *expr, const char *one, |
| 30 | struct expr_parse_ctx *ids, int runtime); |
Andi Kleen | 0751673 | 2017-03-20 13:17:05 -0700 | [diff] [blame] | 31 | |
| 32 | #endif |