at v5.13 1.5 kB view raw
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