Merge tag 'dlm-6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/linux-dlm
[linux-2.6-block.git] / tools / perf / util / expr.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
07516736
AK
2#ifndef PARSE_CTX_H
3#define PARSE_CTX_H 1
4
bd560973 5struct hashmap;
fc393839
JO
6struct metric_ref;
7
1a6abdde 8struct expr_scanner_ctx {
1725e9cd 9 char *user_requested_cpu_list;
1a6abdde 10 int runtime;
1725e9cd 11 bool system_wide;
3340a083 12 bool is_test;
1a6abdde
IR
13};
14
aecce63e 15struct expr_parse_ctx {
cb94a02e 16 struct hashmap *ids;
1a6abdde 17 struct expr_scanner_ctx sctx;
07516736
AK
18};
19
29396cd5 20struct expr_id_data;
070b3b5a 21
114a9d6e
IR
22struct hashmap *ids__new(void);
23void ids__free(struct hashmap *ids);
80be6434 24int ids__insert(struct hashmap *ids, const char *id);
114a9d6e
IR
25/*
26 * Union two sets of ids (hashmaps) and construct a third, freeing ids1 and
27 * ids2.
28 */
29struct hashmap *ids__union(struct hashmap *ids1, struct hashmap *ids2);
30
cb94a02e 31struct expr_parse_ctx *expr__ctx_new(void);
ded80bda 32void expr__ctx_clear(struct expr_parse_ctx *ctx);
cb94a02e 33void expr__ctx_free(struct expr_parse_ctx *ctx);
114a9d6e 34
3fd29fa6 35void expr__del_id(struct expr_parse_ctx *ctx, const char *id);
332603c2 36int expr__add_id(struct expr_parse_ctx *ctx, const char *id);
2c46f542 37int expr__add_id_val(struct expr_parse_ctx *ctx, const char *id, double val);
9aba0ada
IR
38int expr__add_id_val_source_count(struct expr_parse_ctx *ctx, const char *id,
39 double val, int source_count);
fc393839 40int expr__add_ref(struct expr_parse_ctx *ctx, struct metric_ref *ref);
5c5f5e83
JO
41int expr__get_id(struct expr_parse_ctx *ctx, const char *id,
42 struct expr_id_data **data);
798c3f4a
IR
43bool expr__subset_of_ids(struct expr_parse_ctx *haystack,
44 struct expr_parse_ctx *needles);
acf71b05
JO
45int expr__resolve_id(struct expr_parse_ctx *ctx, const char *id,
46 struct expr_id_data **datap);
114a9d6e 47
ded80bda 48int expr__parse(double *final_val, struct expr_parse_ctx *ctx,
fa831fbb 49 const char *expr);
114a9d6e 50
7e06a5e3 51int expr__find_ids(const char *expr, const char *one,
fa831fbb 52 struct expr_parse_ctx *ids);
07516736 53
29396cd5 54double expr_id_data__value(const struct expr_id_data *data);
9aba0ada 55double expr_id_data__source_count(const struct expr_id_data *data);
1725e9cd 56double expr__get_literal(const char *literal, const struct expr_scanner_ctx *ctx);
4a4a9bf9 57double expr__has_event(const struct expr_parse_ctx *ctx, bool compute_ids, const char *id);
9d5da30e 58double expr__strcmp_cpuid_str(const struct expr_parse_ctx *ctx, bool compute_ids, const char *id);
29396cd5 59
07516736 60#endif