Commit | Line | Data |
---|---|---|
ebabbf58 | 1 | /* |
c0c0989a | 2 | * SPDX-License-Identifier: MIT |
ebabbf58 MD |
3 | * |
4 | * Copyright (C) 2020 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
5 | * | |
c0c0989a | 6 | * LTTng Counters API |
ebabbf58 MD |
7 | */ |
8 | ||
9 | #ifndef _LTTNG_COUNTER_H | |
10 | #define _LTTNG_COUNTER_H | |
11 | ||
12 | #include <stdint.h> | |
bb84a1ec | 13 | #include <stdbool.h> |
ebabbf58 MD |
14 | #include <lttng/ust-config.h> |
15 | #include "counter-types.h" | |
3d5db36a | 16 | #include "helper.h" |
ebabbf58 MD |
17 | |
18 | /* max_nr_elem is for each dimension. */ | |
3d5db36a | 19 | LTTNG_HIDDEN |
ebabbf58 MD |
20 | struct lib_counter *lttng_counter_create(const struct lib_counter_config *config, |
21 | size_t nr_dimensions, | |
22 | const size_t *max_nr_elem, | |
23 | int64_t global_sum_step, | |
24 | int global_counter_fd, | |
25 | int nr_counter_cpu_fds, | |
26 | const int *counter_cpu_fds, | |
27 | bool is_daemon); | |
3d5db36a | 28 | LTTNG_HIDDEN |
ebabbf58 MD |
29 | void lttng_counter_destroy(struct lib_counter *counter); |
30 | ||
3d5db36a | 31 | LTTNG_HIDDEN |
ebabbf58 | 32 | int lttng_counter_set_global_shm(struct lib_counter *counter, int fd); |
3d5db36a | 33 | LTTNG_HIDDEN |
ebabbf58 MD |
34 | int lttng_counter_set_cpu_shm(struct lib_counter *counter, int cpu, int fd); |
35 | ||
3d5db36a | 36 | LTTNG_HIDDEN |
ebabbf58 | 37 | int lttng_counter_get_global_shm(struct lib_counter *counter, int *fd, size_t *len); |
3d5db36a | 38 | LTTNG_HIDDEN |
ebabbf58 MD |
39 | int lttng_counter_get_cpu_shm(struct lib_counter *counter, int cpu, int *fd, size_t *len); |
40 | ||
bb84a1ec MD |
41 | /* |
42 | * Has counter received all expected shm ? | |
43 | */ | |
44 | LTTNG_HIDDEN | |
45 | bool lttng_counter_ready(struct lib_counter *counter); | |
46 | ||
3d5db36a | 47 | LTTNG_HIDDEN |
ebabbf58 MD |
48 | int lttng_counter_read(const struct lib_counter_config *config, |
49 | struct lib_counter *counter, | |
50 | const size_t *dimension_indexes, | |
51 | int cpu, int64_t *value, | |
52 | bool *overflow, bool *underflow); | |
3d5db36a | 53 | LTTNG_HIDDEN |
ebabbf58 MD |
54 | int lttng_counter_aggregate(const struct lib_counter_config *config, |
55 | struct lib_counter *counter, | |
56 | const size_t *dimension_indexes, | |
57 | int64_t *value, | |
58 | bool *overflow, bool *underflow); | |
3d5db36a | 59 | LTTNG_HIDDEN |
ebabbf58 MD |
60 | int lttng_counter_clear(const struct lib_counter_config *config, |
61 | struct lib_counter *counter, | |
62 | const size_t *dimension_indexes); | |
63 | ||
64 | #endif /* _LTTNG_COUNTER_H */ |