blob: 8a2c1074f90f1001d6de4b3bf2ede342d01a4782 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Andi Kleen07516732017-03-20 13:17:05 -07002#ifndef PARSE_CTX_H
3#define PARSE_CTX_H 1
4
Ian Rogersded80bd2020-05-15 15:17:32 -07005// 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 Kleen07516732017-03-20 13:17:05 -070013
Jiri Olsaaecce632020-04-02 02:03:34 +053014struct expr_parse_ctx {
Ian Rogersded80bd2020-05-15 15:17:32 -070015 struct hashmap ids;
Andi Kleen07516732017-03-20 13:17:05 -070016};
17
Jiri Olsa871f9f52020-04-02 02:03:35 +053018struct expr_scanner_ctx {
19 int start_token;
Kajol Jain1e1a8732020-04-02 02:03:37 +053020 int runtime;
Jiri Olsa871f9f52020-04-02 02:03:35 +053021};
22
Jiri Olsaaecce632020-04-02 02:03:34 +053023void expr__ctx_init(struct expr_parse_ctx *ctx);
Ian Rogersded80bd2020-05-15 15:17:32 -070024void expr__ctx_clear(struct expr_parse_ctx *ctx);
25int expr__add_id(struct expr_parse_ctx *ctx, const char *id, double val);
26int expr__get_id(struct expr_parse_ctx *ctx, const char *id, double *val_ptr);
27int expr__parse(double *final_val, struct expr_parse_ctx *ctx,
28 const char *expr, int runtime);
29int expr__find_other(const char *expr, const char *one,
30 struct expr_parse_ctx *ids, int runtime);
Andi Kleen07516732017-03-20 13:17:05 -070031
32#endif